Install
openclaw skills install volcengine-sdk-generatorGenerate complete, runnable Volcengine SDK code and provide SDK configuration guidance. Supports Go, Python, PHP, Java, and Node.js. Trigger this skill whene...
openclaw skills install volcengine-sdk-generatorGenerate complete, runnable Volcengine SDK code from natural-language descriptions, and answer SDK configuration questions.
When a user describes a Volcengine API operation, follow these steps:
Parse the user's description to determine:
Target service: which Volcengine service (e.g., ECS, VPC, TOS, billing)
Target operation: what operation to perform (e.g., list instances, create a VPC, query billing)
Target language: which programming language (Go, Python, PHP, Java, Node.js). If not specified, ask the user.
Advanced configuration needs: whether the user mentions or the scenario implies any of the following:
If the user explicitly requests these, include the corresponding configuration in the generated code. If not explicitly requested but implied by the scenario (e.g., resource creation naturally warrants retry), include suggested configuration as comments.
Use the following APIs to find the correct service code, version, and action name. This step is critical because guessing often produces incorrect code — the API Explorer is the authoritative source.
2a. Find the ServiceCode
Fetch the service catalog:
GET https://api.volcengine.com/api/common/explorer/services
Response structure:
{
"Result": {
"Categories": [
{
"CategoryName": "...",
"Services": [
{
"ServiceCn": "Cloud Server",
"ServiceCode": "ecs",
"Product": "ECS",
"IsSdkAvailable": true,
"RegionType": "regional"
}
]
}
]
}
}
Match the user's intent to the correct ServiceCode based on ServiceCn, Product, and category name.
2b. Find the API version
GET https://api.volcengine.com/api/common/explorer/versions?ServiceCode={ServiceCode}
Response:
{
"Result": {
"Versions": [
{
"ServiceCode": "billing",
"Version": "2022-01-01",
"IsDefault": 0
}
]
}
}
Use the version with IsDefault == 1. If no default version exists, use the latest available.
2c. Find the Action name
GET https://api.volcengine.com/api/common/explorer/apis?ServiceCode={ServiceCode}&Version={Version}&APIVersion={Version}
Response:
{
"Result": {
"Groups": [
{
"Name": "Instance",
"Apis": [
{
"Action": "DescribeInstances",
"NameCn": "Query instance list",
"Description": "..."
}
]
}
]
}
}
Match user intent using the Action name and NameCn (Chinese name).
2c-alt: Search API (when direct lookup fails)
If the service catalog or API list cannot clearly match the user's description — for example, the user uses vague terms, Chinese names that don't map directly to a ServiceCode, or the API list doesn't seem to contain what the user wants — use the search API as a fallback:
GET https://api.volcengine.com/api/common/search/all?Query={URL-encoded search term}&Channel=api&Limit=10
Search terms can be Chinese or English — use whichever best matches the user's description.
Response structure:
{
"Result": {
"List": [
{
"BizInfo": {
"Action": "ListProjects",
"ServiceCn": "Access Control",
"ServiceCode": "iam",
"Version": "2021-08-01"
},
"Highlight": [
{"Field": "title", "Summary": "Get <em>project</em> <em>list</em>"}
]
}
],
"Total": 200
}
}
Select the best match based on ServiceCn, Action, and highlight text, then continue to step 2d.
The search API is particularly useful when:
2d. Get full API parameter details
GET https://api.volcengine.com/api/common/explorer/api-swagger?ServiceCode={ServiceCode}&Version={Version}&APIVersion={Version}&ActionName={Action}
Returns the full Swagger/OpenAPI specification, including:
x-demo field: contains requestDemo and responseDemo with official examplesRead this specification carefully — it is essential for generating accurate code.
2e. Extract parameter example values (from x-demo requestDemo)
The info.x-demo array in the Swagger response contains requestDemo — official request examples. Extract realistic parameter values from these to populate generated code.
Extraction process:
info.x-demo[0].requestDemo and parse the request body JSONcc5silum********), keep the masked format and add a comment prompting the user to replace with real valuesConfig field), format it clearly and comment each sub-fieldExample: for VKE CreateAddon, requestDemo contains:
{
"ClusterId": "cc5silum********",
"Name": "ingress-nginx",
"DeployMode": "Unmanaged",
"DeployNodeType": ["VirtualNode"],
"Config": "{\"Replica\":1,\"Resource\":{\"Request\":{\"Cpu\":\"0.25\",\"Memory\":\"512Mi\"},\"Limit\":{\"Cpu\":\"0.5\",\"Memory\":\"1024Mi\"}},\"PrivateNetwork\":{\"SubnetId\":\"subnet-2d61qn69iji****\",\"IpVersion\":\"IPV4\"}}"
}
Use these example values directly instead of empty placeholders.
2f. Retrieve detailed configuration for complex parameters
Some parameter description fields contain documentation links (e.g., https://www.volcengine.com/docs/...) pointing to detailed configuration guides. For complex parameters, fetch these links for more information:
When to consult documentation:
Config)enum values have unclear meanings that are explained in the documentationProcessing flow:
description contains a volcengine.com/docs link2g. Determine required and recommended parameters
Required-field detection relies on multiple sources, not just the required array:
required arrayParameter value priority:
example field: individual parameter example values from the Swagger spec172.16.0.0/16 for CIDR, descriptive names for instances)If Step 1 identified advanced configuration needs, read the corresponding reference file for the target language to get accurate configuration code:
| Language | Reference File |
|---|---|
| Go | references/sdk-integration-go.md |
| Python | references/sdk-integration-python.md |
| Java | references/sdk-integration-java.md |
| Node.js | references/sdk-integration-nodejs.md |
| PHP | references/sdk-integration-php.md |
These files contain verified code snippets for retry, timeout, credentials, proxy, connection pooling, and debug configuration. Use these patterns directly rather than writing from memory — SDK configuration varies significantly across languages, and the reference files ensure accuracy.
Generate a complete, runnable code example following these rules:
VOLCENGINE_ACCESS_KEY and VOLCENGINE_SECRET_KEY by default. If the user needs a different auth method (STS, AssumeRole, OIDC), use the corresponding pattern from the reference files. The exact reading mechanism varies by language — see each language section and the reference files.cn-beijing for regional services. Add a comment noting that users can change this.i-abc123****** (from requestDemo)172.16.0.0/16The Go SDK uses {Action}Input structs (not Request). Services are instantiated via {service}.New(sess).
package main
import (
"fmt"
"os"
"github.com/volcengine/volcengine-go-sdk/service/{service}"
"github.com/volcengine/volcengine-go-sdk/volcengine"
"github.com/volcengine/volcengine-go-sdk/volcengine/credentials"
"github.com/volcengine/volcengine-go-sdk/volcengine/session"
)
func main() {
ak := os.Getenv("VOLCENGINE_ACCESS_KEY")
sk := os.Getenv("VOLCENGINE_SECRET_KEY")
region := "cn-beijing"
config := volcengine.NewConfig().
WithRegion(region).
WithCredentials(credentials.NewStaticCredentials(ak, sk, ""))
// [Advanced config — add as needed, see references/sdk-integration-go.md]
// Retry: config.WithMaxRetries(5)
// Timeout: config.WithHTTPClient(&http.Client{Timeout: 60 * time.Second})
// Proxy: config.WithHTTPProxy("http://proxy:8080")
// Debug: config.WithDebug(true)
sess, err := session.NewSession(config)
if err != nil {
panic(err)
}
svc := {service}.New(sess)
input := &{service}.{Action}Input{
// Set required parameters here
}
resp, err := svc.{Action}(input)
if err != nil {
panic(err)
}
fmt.Println(resp)
}
Key points:
github.com/volcengine/volcengine-go-sdk/service/{service} (lowercase, e.g., billing, ecs, vpc)volcengine.NewConfig().WithRegion(region).WithCredentials(credentials.NewStaticCredentials(ak, sk, ""))session.NewSession(config) (returns session and error){service}.New(sess) (e.g., billing.New(sess), ecs.New(sess)){Action}Input (e.g., ListAvailableInstancesInput, DescribeInstancesInput)svc.{Action}(input), PascalCase action nameThe Python SDK uses {SERVICE}Api (uppercase service name) and {Action}Request models.
from __future__ import print_function
import os
import volcenginesdkcore
import volcenginesdk{service}
from volcenginesdkcore.rest import ApiException
if __name__ == '__main__':
configuration = volcenginesdkcore.Configuration()
configuration.ak = os.environ.get("VOLCENGINE_ACCESS_KEY")
configuration.sk = os.environ.get("VOLCENGINE_SECRET_KEY")
configuration.region = "cn-beijing"
# [Advanced config — add as needed, see references/sdk-integration-python.md]
# Retry: configuration.max_retry_attempts = 5
# Timeout: configuration.connection_timeout = 10; configuration.read_timeout = 60
# Proxy: configuration.proxy = "http://proxy:8080"
# Debug: configuration.debug = True
volcenginesdkcore.Configuration.set_default(configuration)
api_instance = volcenginesdk{service}.{SERVICE}Api()
request = volcenginesdk{service}.{Action}Request(
# Set required parameters here
)
try:
resp = api_instance.{action_snake_case}(request)
print(resp)
except ApiException as e:
print("API exception: %s\n" % e)
Key points:
volcenginesdkcore + volcenginesdk{service} (all lowercase, no separators, e.g., volcenginesdkbilling, volcenginesdkecs)volcenginesdkcore.Configuration(), set .ak, .sk, .region, then set_default()volcenginesdk{service}.{SERVICE}Api() — service name ALL CAPS (e.g., BILLINGApi, ECSApi, VPCApi)volcenginesdk{service}.{Action}Request(...) (PascalCase, e.g., ListAvailableInstancesRequest)api_instance.{action_snake_case}(request) — snake_case (e.g., list_available_instances, describe_instances)from volcenginesdkcore.rest import ApiExceptionThe Java SDK uses {ServiceName}Api and {Action}Request models under com.volcengine.{service}.
package com.volcengine.sample;
import com.volcengine.ApiClient;
import com.volcengine.ApiException;
import com.volcengine.sign.Credentials;
import com.volcengine.{service}.{ServiceName}Api;
import com.volcengine.{service}.model.*;
public class Example {
public static void main(String[] args) throws Exception {
String ak = System.getenv("VOLCENGINE_ACCESS_KEY");
String sk = System.getenv("VOLCENGINE_SECRET_KEY");
String region = "cn-beijing";
ApiClient apiClient = new ApiClient()
.setCredentials(Credentials.getCredentials(ak, sk))
.setRegion(region);
// [Advanced config — add as needed, see references/sdk-integration-java.md]
// Retry: apiClient.setRetrySettings(new RetrySettings().setMaxAttempts(5));
// Timeout: apiClient.setConnectionTimeout(5000); apiClient.setReadTimeout(30000);
// Proxy: apiClient.setHttpProxy("http://proxy:8080");
// Debug: apiClient.setDebugging(true);
{ServiceName}Api api = new {ServiceName}Api(apiClient);
{Action}Request request = new {Action}Request();
// request.setParamName(value);
try {
{Action}Response resp = api.{actionCamelCase}(request);
System.out.println(resp);
} catch (ApiException e) {
System.out.println(e.getResponseBody());
}
}
}
Key points:
com.volcengine.{service} (lowercase, e.g., com.volcengine.billing, com.volcengine.ecs)new ApiClient().setCredentials(Credentials.getCredentials(ak, sk)).setRegion(region){ServiceName}Api (PascalCase, e.g., BillingApi, EcsApi) — constructor takes apiClient{Action}Request (e.g., ListAvailableInstancesRequest) — set params via settersapi.{actionCamelCase}(request) — camelCase (e.g., listAvailableInstances, describeInstances)ApiException, use e.getResponseBody() for detailsThe Node.js SDK uses a command pattern: {SERVICE}Client + {Action}Command.
import { {SERVICE}Client, {Action}Command } from "@volcengine/{service}";
// Automatically reads VOLCENGINE_ACCESS_KEY and VOLCENGINE_SECRET_KEY from env
const client = new {SERVICE}Client({
region: "cn-beijing",
// [Advanced config — add as needed, see references/sdk-integration-nodejs.md]
// maxRetries: 5, // retry count
// autoRetry: false, // disable auto-retry
// httpOptions: { timeout: 30000 }, // timeout (ms)
// httpOptions: { proxy: { protocol: "http", host: "127.0.0.1", port: 8888 } }, // proxy
});
async function main() {
try {
const command = new {Action}Command({
// Set required parameters here
});
const response = await client.send(command);
console.log(JSON.stringify(response, null, 2));
} catch (error) {
console.error("Error:", error);
}
}
main();
Key points:
@volcengine/{service} (lowercase, e.g., @volcengine/ecs, @volcengine/vpc){SERVICE}Client (ALL CAPS service name, e.g., ECSClient, VPCClient){Action}Command (PascalCase, e.g., DescribeInstancesCommand, CreateVpcCommand)client.send(command) — async, returns a PromiseVOLCENGINE_ACCESS_KEY and VOLCENGINE_SECRET_KEY from env; can also pass accessKeyId/secretAccessKey in the client constructorThe PHP SDK uses classes under the \Volcengine\{Service}\ namespace.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$config = \Volcengine\Common\Configuration::getDefaultConfiguration()
->setAk(getenv("VOLCENGINE_ACCESS_KEY"))
->setSk(getenv("VOLCENGINE_SECRET_KEY"))
->setRegion("cn-beijing");
// [Advanced config — add as needed, see references/sdk-integration-php.md]
// Proxy and timeout are configured via GuzzleHttp\Client options
$httpClient = new GuzzleHttp\Client([
// 'proxy' => 'http://proxy:8080', // proxy
// 'timeout' => 60, // request timeout (seconds)
// 'connect_timeout' => 10, // connection timeout (seconds)
]);
$apiInstance = new \Volcengine\{Service}\Api\{SERVICE}Api(
$httpClient,
$config
);
$request = new \Volcengine\{Service}\Model\{Action}Request();
// $request->setParamName("value");
try {
$resp = $apiInstance->{actionCamelCase}($request);
print_r($resp);
} catch (Exception $e) {
echo 'API exception: ', $e->getMessage(), PHP_EOL;
}
Key points:
\Volcengine\Common\Configuration::getDefaultConfiguration()->setAk()->setSk()->setRegion()\Volcengine\{Service}\Api\{SERVICE}Api — namespace uses PascalCase Service (e.g., Billing), class name uses ALL CAPS (e.g., BILLINGApi)GuzzleHttp\Client() and $config\Volcengine\{Service}\Model\{Action}Request (e.g., \Volcengine\Billing\Model\ListAvailableInstancesRequest)$request->setProduct("value")$apiInstance->{actionCamelCase}($request) (e.g., listAvailableInstances)After generating code:
go get, pip install, npm install, composer require, Maven/Gradle coordinates)export VOLCENGINE_ACCESS_KEY="your-access-key"
export VOLCENGINE_SECRET_KEY="your-secret-key"
WithMaxRetries"When the user asks how to configure or use the Volcengine SDK (rather than generate API call code), follow this approach:
Common configuration topics:
Read the reference file for the user's target language:
| Language | Reference File |
|---|---|
| Go | references/sdk-integration-go.md |
| Python | references/sdk-integration-python.md |
| Java | references/sdk-integration-java.md |
| Node.js | references/sdk-integration-nodejs.md |
| PHP | references/sdk-integration-php.md |
These files contain concise code examples for each major configuration topic. Read the relevant file and answer with accurate, copy-paste-ready code.
If the user's question is not covered in the reference file or requires more detail, fetch the full upstream documentation from GitHub:
| Language | Upstream Documentation URL |
|---|---|
| Go | https://raw.githubusercontent.com/volcengine/volcengine-go-sdk/master/SDK_Integration.md |
| Python | https://raw.githubusercontent.com/volcengine/volcengine-python-sdk/master/SDK_Integration.md |
| Java | https://raw.githubusercontent.com/volcengine/volcengine-java-sdk/master/SDK_Integration.md |
| Node.js | https://raw.githubusercontent.com/volcengine/volcengine-nodejs-sdk/master/SDK_Integration.md |
| PHP | https://raw.githubusercontent.com/volcengine/volcengine-php-sdk/main/SDK_Integration.md |
IsSdkAvailable: false, inform the user that the official SDK may not yet support this service, and provide a raw HTTP request example as an alternative.cn-beijing.