Create and manage Volcengine cloud resources by calling Volcengine OpenAPIs through the ve command.
If the ve command is not available on the system:
Option 1: npm (recommended)
npm i -g @volcengine/cli
Option 2: GitHub Releases
Download: https://github.com/volcengine/volcengine-cli/releases
Verify the installation: ve --version
Run the identity verification command to confirm that credentials are usable:
ve sts GetCallerIdentity
Success — inform the user of the current account identity and region, then proceed with the task.
> Switching regions later: once a profile is set up, --region and VOLCENGINE_REGION do not override the region baked into it. Switch via ve configure profile --profile (use ve configure list to see profiles). This does not apply to the --region flag on ve login itself, which is required (see below).
Failure — no usable profile. Default plan: use ve login (Console Login, OAuth 2.0 + PKCE). Announce this to the user up front, and tell them they can say "use AK/SK", "use STS token", or "use SSO" to switch.
First check the ve version:
ve --version
Use ve login --remote via the helper script scripts/ve_login_remote.sh. It handles the OAuth device-flow subprocess lifecycle (FIFO-bound stdin, URL extraction, code feeding, cleanup) so the agent doesn't have to.
Resolve the login region:
VOLCENGINE_REGION is set, use it.cn-beijing.Default procedure — commit to this path; do NOT present a menu of login methods:
> "I'll start ve login --remote --region now. Say 'use AK/SK' anytime to switch."
```text
scripts/ve_login_remote.sh start
```
Prints a https://signin.volcengine.com/... URL on stdout. Forward it verbatim to the user with: "Open this URL in any browser, complete login, then send me the 'Authorization code' shown on the page."
```text
scripts/ve_login_remote.sh complete
```
The script writes the code into the FIFO bound to the still-running ve, waits for ve to exit, then runs ve sts GetCallerIdentity to verify.
```text
scripts/ve_login_remote.sh abort
```
Then switch to the chosen alternative below.
Critical rules — do NOT improvise OAuth:
--remote; let the user interrupt to switch.ve login --remote and exiting. The PKCE challenge dies with the subprocess; the URL becomes useless and the next attempt fails with PKCE mismatch.signin.volcengine.com/authorize/... URLs yourself.complete . No base64 decode (even if the string looks base64-shaped), no URL query-string parsing, no extracting code= from callback URLs.echo "" | ve login --remote). The code arrives before the user completes browser login and fails verification.ve login subprocesses. One at a time, tracked by the helper.ve login --remote directly. Always go through scripts/ve_login_remote.sh. The script binds ve's stdin to a FIFO so the still-running ve can receive the user's code via a separate complete call. Calling ve directly orphans the subprocess and breaks the code-feeding step.scripts/ve_login_remote.sh start / complete / abort.> Switching region mid-flow: scripts/ve_login_remote.sh abort, then start .
> No browser on any device (true offline / CI): skip ve login, fall back to AK/SK below.
If ve login fails (network error, non-interactive terminal, version too old), or the user explicitly asks for a different method, fall back to one of the alternatives below. If installed via npm, upgrade with npm i -g @volcengine/cli@latest.
Ask the user for AccessKey and SecretKey, then:
ve configure set --profile default --region cn-beijing \
--endpoint open.volcengineapi.com \
--access-key <AK> --secret-key <SK>
For STS (temporary) credentials, also pass --session-token .
Alternative for the current shell only: export VOLCENGINE_ACCESS_KEY, VOLCENGINE_SECRET_KEY, VOLCENGINE_REGION, optionally VOLCENGINE_SESSION_TOKEN.
Three-step setup; ask the user for the SSO start URL and session name first:
ve configure sso-session --name <session-name> \
--start-url https://<sso-host>/userportal \
--region cn-beijing \
--registration-scopes cloudidentity:account:access,offline_access
ve configure sso --profile <profile-name> --sso-session <session-name>
ve configure profile --profile <profile-name>
Then ve sso login --sso-session (use --no-browser on headless machines).
~/.volcengine/config.json — it contains AK/SK and session tokens.ve configure set with --secret-key, prefer letting the user paste and run the command in their own shell rather than executing it via Claude — secrets passed as command-line arguments end up in shell history and process listings.| Level | Operation Types | Behavior |
|---|---|---|
| ------- | ---------------- | ---------- |
| Read-only | Describe\ / List\ / Get\ / Query\ | Execute directly, no confirmation needed |
| Write | Create\ / Run\ / Allocate\ / Attach\ / Associate\ / Authorize\ | Show the full command and wait for user confirmation |
| Destructive | Delete\ / Terminate\ / Release\ / Revoke\ / Modify\ / Stop\ / Detach\* | Show command + impact summary; require user confirmation |
--DryRun true, run a DryRun to preview the plan, then confirm before executing~/.volcengine/config.json; never expose access-key, secret-key, or session-token in outputA successful DryRun validation returns exit code 1 (non-zero) with DryRunOperation in stderr. This is expected behavior:
output=$(ve <svc> <action> --DryRun true ... 2>&1)
if echo "$output" | grep -q "DryRunOperation"; then
echo "Parameter validation passed"
fi
Step 1: Service name + Action known? -> Use them directly; skip to "Retrieve parameters"
Step 2: Service name known, Action unknown?
-> ve <service> 2>&1 | grep -i <keyword>
Step 3: Service name also unknown?
-> ve 2>&1 | grep -i <service keyword>
Step 4: None of the above work?
-> python3 scripts/find_api.py <keyword>
Choose a strategy based on operation type:
| Operation Type | Strategy | Rationale |
|---|---|---|
| --------------- | ---------- | ----------- |
| Read-only (Describe/List/Get) | ve | Few, simple parameters — names alone are sufficient |
| Write/destructive (Create/Run/Delete, etc.) | scripts/fetch_swagger.py for full docs | Many parameters, nested structures — need required fields, examples, and descriptions |
Still unclear after --help | Supplement with scripts/fetch_swagger.py | Use whenever parameter meaning is uncertain |
Errors like Invalid / Missing | Recheck with scripts/fetch_swagger.py | On InvalidParameter, InvalidXxx.NotFound, or MissingParameter, verify parameter names, required fields, and value ranges |
# Read-only — --help is sufficient
ve ecs DescribeInstances --help
# Write — retrieve full documentation
python3 scripts/fetch_swagger.py --service ecs --action RunInstances
iam)service name + version without hyphens (e.g., iam v2021-08-01 -> iam20210801)ve 2>&1 | grep to confirm# Search for an API (when the service name is unknown)
python3 scripts/find_api.py <keyword> [--limit N]
# Get full API parameter documentation (when descriptions/examples are needed)
python3 scripts/fetch_swagger.py --service <ServiceCode> --action <ActionName>
# List all APIs for a service
python3 scripts/fetch_swagger.py --service <ServiceCode> --list
# Call Extension APIs that public API Explorer/ve does not expose
python3 scripts/call_extend_api.py --list
python3 scripts/call_extend_api.py --describe QueryMetrics
> Always pass the base service name to scripts/fetch_swagger.py (e.g., --service iam, not iam20210801) — the script auto-detects the version.
Some extension APIs are not exposed through ve.
For those, consult references/extend-apis.md and use:
python3 scripts/call_extend_api.py --api <APIName> --params '{"Key":"Value"}'
The helper resolves service, version, method, endpoint, content type, and credentials from its registry/environment. Credentials prefer VOLCENGINE_ACCESS_KEY/VOLCENGINE_SECRET_KEY; when those environment variables are missing, it warns the user and falls back to the Python SDK's CLIConfigCredentialProvider so ve profiles from ak, ramrolearn, oidc, ecsrole, sso, and console-login modes can be reused. Apply the same read/write/destructive confirmation rules before running extension APIs.
ve <ServiceCode> <ActionName> --ParamName "value"
Determine the format from --help output:
--help lists individual --Key type entries (e.g., ECS, VPC, IAM) -> pass with --Key "value"--help, such as --InstanceIds.1 "$instance_id" or --SubnetIds.1 "$subnet_id". Do not assume JSON-array strings are accepted by every action.--help only shows --body '{...}' (e.g., Redis, CR, and other POST APIs) -> pass with --body '{...}'# Flat parameters — nested fields use dot notation; arrays use .N index (starting from 1)
ve ecs RunInstances --ZoneId "cn-beijing-a"
ve ecs RunInstances --NetworkInterfaces.1.SubnetId "subnet-xxxx"
ve ecs RunInstances --Tags.1.Key "publish-by" --Tags.1.Value "deploy-skill"
# JSON format (when --help only shows --body)
ve redis CreateDBInstance --body '{"InstanceName":"demo","RegionId":"cn-beijing","ConfigureNodes":[{"AZ":"cn-beijing-a"}],"ShardedCluster":0,"NodeNumber":2,"ShardCapacity":1024,"ShardNumber":1,"EngineVersion":"6.0","SubnetId":"subnet-xxxx","VpcId":"vpc-xxxx","Password":"<secret>","Tags":[{"Key":"publish-by","Value":"deploy-skill"}]}'
// Success
{ "ResponseMetadata": { "RequestId": "..." }, "Result": { ... } }
// Failure
{ "ResponseMetadata": { "Error": { "Code": "...", "Message": "..." } } }
Some resources (VKE clusters, RDS instances, ECS instances, etc.) take several minutes to create. After creation, poll the Describe endpoint until the resource reaches the desired status before proceeding.
> Creating sub-resources (e.g., security groups) immediately after VPC creation may fail with InvalidVpc.InvalidStatus. Create sub-resources sequentially (subnet first, then security group), or wait a few seconds and retry.
# General polling pattern: check every 30 seconds until the target status is reached
while true; do
cur_status=$(ve <svc> Describe<Resource> --<IdParam> "xxx" 2>&1 | grep -o '"Status":"[^"]*"')
echo "$(date +%H:%M:%S) $cur_status"
echo "$cur_status" | grep -q '"Status":"Running"' && break
sleep 30
done
1. Initialize: verify credentials -> GetCallerIdentity -> confirm region
2. Understand the task: is the user querying or making changes?
3. Locate the API: ve --help first -> Python helpers as fallback
4. Query dependent resources: use Describe*/List* to obtain required IDs
5. Read operation -> execute directly and display results
Write operation -> show command -> DryRun (if supported) -> user confirmation -> execute
6. Parse the response and report results to the user
Consult or update the corresponding notes file when encountering service-specific issues:
共 4 个版本