Sign in and create a Virtual Key in token management.
Use one key for multi-model APIs
The page automatically uses the China or Global API root from the current domain, then lets you copy text, image, and video API examples. The temporary key only replaces examples in memory and is never uploaded or saved.
Visible URLs and copied examples follow the current domain.
Pick the API shape that matches your integration.
Error codes, environment checks, and client troubleshooting now live on a dedicated FAQ page.
Open FAQEnvironment & Auth
Display and copy output automatically use the base URL for the current domain.
https://api.tokenstar.iohttps://api.tokenstar.io/v1https://api.tokenstar.ioAll APIs use a platform API key. OpenAI-compatible APIs use Authorization: Bearer ${API_KEY}; Claude / Anthropic APIs use x-api-key: ${API_KEY}.
OpenAI-compatible clients usually use a URL ending in /v1. Claude Code ANTHROPIC_BASE_URL uses the gateway root without /v1.
TokenStar Agent Skill
Package the public TokenStar docs into an AI-readable SKILL.md covering text, image, video, assets, callbacks, and client config.
tokenstar-codex-gateway/SKILL.mdAfter downloading, place the file in this folder shape or pass the content to your agent or skill manager.
SKILL.md preview
Text Generation APIs
Text generation supports OpenAI-compatible and Claude / Anthropic protocols. Choose by client or scenario.
/v1/chat/completionsOpenAI Chat CompletionsSyncChat Completions
Call the OpenAI-compatible chat API with a platform API key.
Authentication
Authorization: Bearer <API_KEY>Content-Type: application/json
Request parameters
| Field | Required | Description |
|---|---|---|
model | Yes | Built-in model ID |
messages | Yes | OpenAI-compatible message array |
stream | No | Whether to return an SSE-style stream |
max_tokens / temperature / top_p | No | Compatible parameters passed through to the upstream model |
curl -sS "https://api.tokenstar.io/v1/chat/completions" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.7-plus",
"messages": [
{"role": "user", "content": "Reply only OK"}
]
}'- Use this API for clients that support OpenAI Chat Completions.
- Only verified built-in models should be used in runnable examples.
/v1/responsesOpenAI ResponsesSyncResponses API
Call the OpenAI Responses-compatible API, suitable for Codex custom providers.
Authentication
Authorization: Bearer <API_KEY>Content-Type: application/json
Request parameters
| Field | Required | Description |
|---|---|---|
model | Yes | Built-in model ID |
input | Yes | Text input or Responses-compatible input array |
stream | No | Whether to stream the response |
curl -sS "https://api.tokenstar.io/v1/responses" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"input": "Reply only OK"
}'- OpenAI-compatible clients should use a Base URL ending in /v1.
- Codex custom providers can use wire_api = "responses".
/v1/messagesAnthropic MessagesSyncClaude Messages
Call Claude models through the Anthropic Messages protocol.
Authentication
x-api-key: <API_KEY>anthropic-version: 2023-06-01
Request parameters
| Field | Required | Description |
|---|---|---|
model | Yes | Claude-compatible model ID |
messages | Yes | Anthropic-compatible messages |
max_tokens | Yes | Maximum output tokens |
- The Claude Code Base URL uses the gateway root and must not include /v1.
- This module remains preview unless the backend contract is verified.
See Model Plaza for the full model list, context windows, and input capabilities. Model Plaza
Image Generation APIs
Image APIs usually return synchronously. Read image data from the response field for each model family.
gpt-image
POST /v1/images/generations · POST /v1/images/editsResponse location: data[].b64_json
- Applicable model: gpt-image-2.
- Image generation uses JSON requests. Image edits and masked inpainting use multipart/form-data to upload image and optionally mask.
- Common sizes include 1024x1024 and 2048x2048. Pass output formats within the model-supported range.
Gemini-compatible image models
POST /v1beta/models/{model}:generateContentResponse location: candidates[].content.parts[].inlineData
- Applicable models: gemini-3-pro-image-preview, gemini-3.1-flash-image-preview, and gemini-2.5-flash-image.
- parts may contain both text and images. Iterate through parts to find inlineData.
Video Generation APIs
Integration details for async tasks, assets, and callbacks.
Seedance video generation
After creating a Seedance task, poll by task ID until it reaches a terminal state, or pass callback_url for status callbacks.
POST /v1/video/generations · GET /v1/video/generations/{task_id}Result: result_url
- The no-reference-person entry uses seedance-2.0 or seedance-2.0-fast.
- After task creation, store the returned id or task_id and poll the query API for results.
POST /volc/asset/CreateAssetGroup · POST /volc/asset/ListAssetGroups · POST /volc/asset/CreateAsset · POST /volc/asset/GetAsset · POST /v1/video/generationsResult: asset://<Id> · result_url
- The reference-person entry uses seedance-2.0-asset or seedance-2.0-asset-fast.
- Assets support images, videos, and audio. CreateAsset accepts only a publicly accessible URL, not embedded encodings or form file uploads.
- CreateAsset uses AssetType, GroupId, Name, and URL.
- Save the returned Id after creating an asset and validate it with GetAsset by Id. Do not depend on name-based asset lookup.
- Video generation requests reference assets in content with asset://<Id>.
- When generating video from assets, content must strictly follow the order text, image_url, video_url, audio_url. Do not reorder them, or the request may fail.
Kling video generation
The current Kling video API uses separate paths for text-to-video, image-to-video, Omni video edit, and motion control.
POST /v1/videos/text2video · GET /v1/videos/text2video/{task_id}Result: data.task_result.videos[].url
- Applicable models: kling-v2-6 and kling-v3.
- Create calls return data.task_id. Query tasks with GET /v1/videos/text2video/{task_id}.
- Use model_name, prompt, duration, mode, aspect_ratio, and sound. Current smoke checks use mode=std.
- For subject consistency, avoid text-to-video and use element_list with image2video, omni-video, or motion-control.
- Store request_id for troubleshooting. Successful responses may also include videos[].duration and final_unit_deduction.
POST /v1/videos/image2video · GET /v1/videos/image2video/{task_id}Result: data.task_result.videos[].url
- Applicable models: kling-v2-6 and kling-v3.
- Use the top-level image field, not image_url and not legacy Image.Url.
- image2video does not support aspect_ratio. Sending it returns UnknownParameter.
- For subject consistency, pass element_list and use the subj_... returned by /v1/general/advanced-custom-elements as element_id.
- Current video APIs must not use elem_... IDs returned by legacy /aigc/element; mixing them returns invalid_subject_id.
- Image URLs must be public HTTPS addresses directly downloadable by the service.
POST /v1/videos/omni-video · GET /v1/videos/omni-video/{task_id}Result: data.task_result.videos[].url
- Applicable model: kling-v3-omni.
- Video edit uses video_list, and video_list[].video_url must be downloadable.
- For subject consistency, pass element_list and use a subj_... element_id returned by the current subject API.
- Current smoke checks cover kling-v3-omni + std + element_list.
- Omni jobs usually take longer; do not recreate them merely because processing lasts longer.
POST /v1/videos/motion-control · GET /v1/videos/motion-control/{task_id}Result: data.task_result.videos[].url
- Basic motion control supports kling-v2-6 and kling-v3. Subject-consistency motion control supports kling-v3.
- Pass both image_url and video_url. video_url is the motion reference video, and image_url is the subject image.
- prompt and character_orientation are required. Use character_orientation=video for kling-v3 + element_list.
- Do not pass duration or StaticMask; they may return UnknownParameter or fail the task.
- kling-v2-6 + element_list is not supported and returns subject reference is not supported for model 'kling-v2-6'.
POST /v1/general/advanced-custom-elements · GET /v1/general/advanced-custom-elements/{task_id}Result: data.task_result.elements[].element_id
- Subject creation is asynchronous. Save data.task_id and poll the single-task endpoint through submitted / processing / succeed / failed.
- Use task_id to query the creation task. Use the returned element_id only in video element_list; never interchange the two IDs.
- element_name and element_description are required and limited to 20 and 100 characters. reference_type is image_refer or video_refer.
- Image-referenced subjects require one frontal image and 1-3 additional images. The current Console accepts accessible URLs only, subject to the official format, size, dimension, and aspect-ratio limits.
- Video-referenced subjects use element_video_list with one MP4/MOV video, 3-8 seconds, 1080P, 16:9 or 9:16, up to 200 MB.
- Use subj_... in video jobs only when data.task_status=succeed, the element status is succeed, and element_id is non-empty.
- Cache subj_... by environment, subject media, and API version; do not recreate immediately after a transient query failure.
- The elem_... returned by legacy /aigc/element is only for legacy /v1/video/generations.
- Subject queries must check data.task_status, elements[].status, and a non-empty elements[].element_id together.
GET /doc/kling-legacyResult: Legacy /v1/video/generations and X-TC-Action docs
- The legacy page is only for existing integrations, migration, and historical troubleshooting.
- New integrations should use the current /v1/videos/{endpoint} API in this module.
Task status, polling, and callbacks
Video jobs are asynchronous. Use callback_url only when the specific API documents support; otherwise poll the matching query endpoint.
submitted / queued / NOT_START → running / IN_PROGRESS → succeeded / SUCCESS / DONE / failed / FAILURE / FAILResult: Seedance: result_url; current Kling API: data.task_result.videos[].url
- Poll every 5 to 10 seconds generally; for the current Kling API, query every 10 to 30 seconds and stop after a terminal state.
- Handle current Kling states as submitted / processing / succeed / failed, and read video URLs only after task_status=succeed.
- Generated result URLs may expire; download or persist them promptly after success.
- Store request_id and task_id for gateway and upstream troubleshooting.
- Use callback_url only when that video API explicitly supports it. The current Kling API does not publicly provide or recommend relying on callback_url, watermark_info, or external_task_id.
- Customer callbacks should return HTTP 2xx and be idempotent by task ID.
After creating a task, store id, task_id, or Kling Response.JobId and poll the query API. Customer callbacks should be idempotent by task ID.
Third-party Agent Tool Configs
Different agent tools use different protocols and Base URL rules.
Claude Code
export ANTHROPIC_API_KEY="${API_KEY}"
export ANTHROPIC_BASE_URL="https://api.tokenstar.io"
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
export ANTHROPIC_MODEL="claude-sonnet-4-6-thinking"
claudeDo not set ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN at the same time.
Codex
model = "gpt-5.4"
model_provider = "tokenstar"
[model_providers.tokenstar]
name = "TokenStar Gateway"
base_url = "https://api.tokenstar.io/v1"
wire_api = "responses"
env_key = "TOKENSTAR_API_KEY"OpenClaw
{
env: { TOKENSTAR_API_KEY: "${API_KEY}" },
models: {
mode: "merge",
providers: {
tokenstar: {
baseUrl: "https://api.tokenstar.io/v1",
apiKey: "${TOKENSTAR_API_KEY}",
api: "openai-completions",
authHeader: true,
models: [{
id: "qwen3.7-plus",
name: "Qwen 3.7 Plus",
reasoning: true,
input: ["text", "image"],
contextWindow: 200000,
maxTokens: 32768
}]
}
}
}
}Anthropic providers use the gateway root as the Base URL.
Download the same-source SKILL.md so agents can read TokenStar API rules, Base URLs, models, media tasks, and troubleshooting without asking users to scan the docs.
