Use when the user encounters VolcEngine errors or needs local troubleshooting for OpenAPI, Python SDK, CLI, IAM, billing, compute, networking, storage, database, CDN, media, AI, security, or VKE cases.
编程
volcengine-sdk-generator
试用为指定火山引擎 API 生成 Python、Go、Java、PHP、Node.js 或 cURL 的调用示例。
它能做什么
通过 API Explorer 搜索定位火山引擎 API,拉取对应 swagger,再以用户提供的 Params 调用 make-code 接口,得到可直接运行的 SDK 示例。默认生成内容只包含认证初始化、请求构造、调用与响应打印;重试、代理、调试日志等高级配置仅在用户明确要求时才会追加,相关说明位于 references/ 下的语言专属文档。需要安装命令或包版本信息时,可调用 scripts/sdk_info.py 按需获取。
什么时候用它
- 为 AssumeRole 生成带 DurationSeconds 和 RoleTrn 的 Python 调用示例
- 根据用户提供的 JSON 参数,输出某个火山引擎服务的 Go SDK 调用代码
- 为指定 API 查询 Node.js 的安装命令与包版本
- 把“角色扮演”这类中文描述解析到对应的 ServiceCode 与 Action
技能文档
Volcengine SDK Generator
Generate ordinary Volcengine API call examples by default. Keep the default output focused on the API call itself: authentication setup, request object/params, invocation, and printing the response. Do not add retry, proxy, connection pool, debug logging, or other advanced SDK configuration unless the user explicitly asks for those topics.
For advanced SDK configuration questions, use the language-specific files under references/.
These reference files are self-contained; answer from them directly.
| Topic | Reference |
|---|---|
| Go SDK configuration | references/sdk-integration-go.md |
| Python SDK configuration | references/sdk-integration-python.md |
| Java SDK configuration | references/sdk-integration-java.md |
| Node.js SDK configuration | references/sdk-integration-nodejs.md |
| PHP SDK configuration | references/sdk-integration-php.md |
Core Rules
- API discovery uses
scripts/rg_rank.py, which calls API Explorer search with bothChannel=serviceandChannel=api. After a concrete API is selected, callscripts/make_code.pyin direct mode with--service-code,--api-version, and--action. - API discovery is online-only. The search endpoint does not require cookies, login state, UID, DID, UUID, or browser-specific headers. The script sends only
Query,Channel,Limit, andOffsetas query parameters. rg_rank.pypreservesChannel=apiorder except for version selection: when the sameservice_code + actionhas multiple versions and the user did not specify one, it moves the result withIsRecommended=1ahead of the other versions in that group. It also includesChannel=serviceresults as separate service metadata.- If online search fails, report the returned search errors. Do not guess an API or fall back to a bundled catalog.
- Use the user's original request as
--query; do not rewrite it into a guessed API name or SDK method. - Extract a shorter
--queryonly when the user clearly self-corrects with words such as等等,不对,重新来,我改主意,其实想要,其实是想要,应该是, or改成; the extracted query must be a continuous substring from the user request, not a guessed API name. - When multiple resources or services appear without a clear self-correction, run
rg_rank.pyonce with the original request. If the returned candidates remain ambiguous, list them concisely and ask the user to choose. - Pure-generic queries such as
api,sdk, ordemoare sent online but are likely to be ambiguous. Refine the query with a concrete resource or action word. - ServiceCode is case-sensitive. Preserve the exact
service_codevalue from the selected API record when callingmake_code.py; for example,Kafkais notkafka. - When the same
service_code + actionappears in multiple API versions and the user did not specify a version, select the result withis_recommended=trueeven if itsremote_rankis lower. If the user specified a version, use that exact version. - Fetch
api-swaggeronly after a concrete API is selected. - The
api-swaggerfetch may include bothVersionandAPIVersionbecause that endpoint expects them; themake-codepayload must not includeVersion. - Call
make-codewithApiAction,ServiceCode,APIVersion,Region, andParams. - Do not send
Versiontomake-code. Paramsmust come from the user. Do not auto-fill from swagger demos.- Swagger is used for API metadata, required parameter hints, and lightweight validation. Do not serialize query arrays, form arrays, or
.Nparameters formake-code; pass the user’s JSON object asParams. - If the user omits required top-level parameters, mock only those top-level required parameters and clearly mark them as mock values. Do not mock optional parameters. If a required top-level parameter is an object or array, recursively fill only required child fields/items.
- Mock values must be derived from the fetched swagger first: prefer
example, thenexamples, thendefault, thenenum, then type/constraint-aware fallback. If a swagger example is masked, such as****orXX, skip it and use a valid fallback value. - Mock comments must be in Chinese by default and placed near the mocked assignment line when the target language supports line comments; do not add a duplicate mock banner at the top of the returned code.
- Returned SDK code must print the API response value. The script post-processes fixed
make-codetemplates for Python, Go, Java, and PHP to assign the response and print it. - Return the code generated by
scripts/make_code.pyas the primary SDK example. Do not rewrite SDK request construction, authentication setup, or response handling into a custom application unless the user explicitly asks for that. If optional formatting or convenience logic is added, keep the generated active response print, such asprint(resp),fmt.Println(resp),System.out.println(resp),print_r($response), orconsole.log(response). - If language is not specified, return all languages from
DemoSdk. - SDK install/dependency info is a separate, on-demand capability. Only when the user explicitly asks how to install the SDK or which package/version to use (keywords such as 依赖, 安装, install, 版本, 包, maven,
go get, pip, composer, npm), runscripts/sdk_info.pywith--service-codeand--api-version(reuse the selected API's values; add--languageto filter to one of go/python/java/php/nodejs). It returns the live install command (RunCommand) plus package and version per language. Do NOT run it during normal code generation. - If the API match is ambiguous, show concise candidates and ask the user to choose one. Do not add follow-up execution boilerplate such as saying that you will fetch swagger, mock required params, and call
make-codeafter the user chooses.
Workflow
-
Parse the user request:
- API hint: action, Chinese name, service code, or natural-language description.
- Language: Python, Go, Java, PHP, cURL, Node.js, or unspecified.
- Params: JSON object supplied by the user.
- Region: user value or default
cn-beijing.
-
Locate or validate the API once for every request. If the user already provides
service_code,api_version, andaction, use those exact values in direct mode;make_code.pyverifies them through the onlineapi-swaggerresponse. For natural-language requests, callscripts/rg_rank.pywith--queryfirst. Use the full original request unless a clear self-correction keyword points to a later target; in that case use the final target substring. -
After selecting
service_code,api_version, andaction, callscripts/make_code.pyin direct API mode with--service-code,--api-version, and--action. If top-level required params are missing, the script fills only those required top-level params with swagger-derived mock values and annotates the returned code in Chinese. Ask for clarification only when API selection is genuinely ambiguous in the online results; in that clarification, only list candidates and ask the user to choose. -
Once params are available, call
make-codethrough the script and return the official code. Do not transform the generated sample into a hand-written utility; any custom formatting must be secondary and must preserve the active response print.
Commands
Search online candidates:
python3 scripts/rg_rank.py \
--query '角色扮演' \
--limit 10 \
--format text
Direct API mode:
In TRN examples, `` is the Volcengine account ID segment, such as a masked 2134xxxyyy.
python3 scripts/make_code.py \
--service-code sts \
--api-version 2018-01-01 \
--action AssumeRole \
--language python \
--params-json '{"DurationSeconds":3600,"RoleSessionName":"demo","RoleTrn":"trn:iam:::role/demo"}'
Use --refresh-swagger when API Explorer metadata has just changed or generated code looks stale:
python3 scripts/make_code.py \
--service-code sts \
--api-version 2018-01-01 \
--action AssumeRole \
--refresh-swagger \
--params-json '{}'
Fetch SDK install/dependency info on demand (only when the user asks about install, package, or version):
python3 scripts/sdk_info.py \
--service-code sts \
--api-version 2018-01-01 \
--language go
相关技能
按需查询火山引擎 API 规范:参数、错误码、响应结构、分页方式。
通过 ve 命令行管理火山引擎云资源,内置登录、会话恢复与分级确认流程。
Use when the user asks to analyze, consult, setup, manage, configure, or design a Volcengine Landing Zone, including organization, accounts, finance, identity, cloudtrail, or network infrastructure.
Use when the user asks to purchase, subscribe, provision, open, or place an order for any Volcengine commercial product, or uses Chinese verbs such as "开通 / 购买 / 下单 / 买 / 售卖 / 想买 / 订购" together with a Volcengine product name. Trigger even when the user does not mention "sale" but expresses a clear provisioning intent.
Use Terraform/IaC for Volcengine resources only when the user explicitly chooses Terraform/IaC, already has a Terraform workflow/state, or confirms they need...