API
Text generation API
Text generation exposes three inbound protocols: Chat Completions, Anthropic Messages, and OpenAI Responses, plus Messages count_tokens. A channel can advertise multiple protocols; when a model has a native channel for the inbound protocol the gateway passes it through, otherwise Messages/Responses are converted to an OpenAI Chat channel. In every case model is a model ID from the catalog.
| API | Method and path | Status |
|---|---|---|
| Chat Completions | POST https://www.jytoken.net/v1/chat/completions | Available |
| Messages | POST https://www.jytoken.net/v1/messages | Available |
| Messages count_tokens | POST https://www.jytoken.net/v1/messages/count_tokens | Available |
| Responses | POST https://www.jytoken.net/v1/responses | Available |
Native protocol channels provide the highest fidelity. On an OpenAI Chat conversion channel, capabilities Chat cannot represent (Anthropic thinking, hosted/built-in tools, document/audio/video blocks) return 400 instead of being dropped silently.
There is no separate Gemini-native API and no Interactions API. gemini-3.8-flash in the Model Plaza uses Chat Completions like every other model; set model to the model ID from the catalog.
How to use
Create a key on the Platform Keys page first. The API base URL is /v1 on the current site; Chat Completions and Responses use Authorization: Bearer, while Messages accepts both x-api-key and Bearer.
| Item | Value |
|---|---|
| API Key | Platform key; Bearer or x-api-key |
| API_URL | https://www.jytoken.net/v1 |
| Chat Completions | https://www.jytoken.net/v1/chat/completions |
| Messages | https://www.jytoken.net/v1/messages |
| Messages count_tokens | https://www.jytoken.net/v1/messages/count_tokens |
| Responses | https://www.jytoken.net/v1/responses |
| Model list | GET https://www.jytoken.net/v1/models |
| Key information | GET https://www.jytoken.net/v1/key |
Vendor parameters
Vendor parameters follow the model catalog; do not infer them from the model name. Current text models have empty capabilities and reasoning_efforts, and both input and output modalities are text. Do not switch to enable_thinking, thinking.type, or thinking_config when calling. Video models are documented under Video generation.
The platform rewrites only two things: it replaces model with the upstream model name for that model, and when stream is true and the request has no stream_options, it adds {"include_usage": true}. All other fields are forwarded unchanged. Pass reasoning_effort only when the model's reasoning_efforts is non-empty, and the value must be one of the listed entries. Currently all are empty; do not send this field.
| Model ID | Vendor | Input | Output |
|---|---|---|---|
| deepseek-V4.1-flash-1017 | deepseek | text | text |
| gemini-3.8-flash | openai | text | text |
| gpt-6-astra | openai | text | text |
| gpt-6-luna | openai | text | text |
| gpt-6.1-sol | openai | text | text |
| gpt-6.1-terra | openai | text | text |
Set model to a model ID from the table above. The latest list comes from GET /v1/models, which returns model IDs available to the current key and backed by an enabled channel.
Chat Completions request parameters
Endpoint: POST https://www.jytoken.net/v1/chat/completions
| Parameter | Description | Required | Type |
|---|---|---|---|
| model | Model ID, see the previous section | Yes | string |
| messages | Conversation messages, see the next section | Yes | array |
| max_tokens | Maximum tokens for this reply. If omitted, the upstream decides | No | integer |
| temperature | Forwarded unchanged. The catalog does not specify a range | No | number |
| top_p | Forwarded unchanged. The catalog does not specify a range | No | number |
| stream | true for SSE streaming, false for a single JSON response. Defaults to false | No | boolean |
| stream_options | Streaming usage control. When omitted with stream true, the platform adds include_usage=true | No | object |
| stop | Stop sequence, string or string array, forwarded unchanged | No | string or array |
| n | Number of completions, forwarded unchanged | No | integer |
| user | End-user identifier, forwarded unchanged | No | string |
tools, tool_choice, and any other JSON fields not listed here are also forwarded unchanged. The platform does not rename fields based on the vendor.
Messages parameters
Each message is an object, and role is system, user, or assistant. Input modalities for the current catalog models are all text, so content is a string.
| Role | Fields | Description |
|---|---|---|
| system | role, content | System prompt. role is system and content is a string |
| user | role, content | User input. role is user and content is a string |
| assistant | role, content | Used when writing history. role is assistant and content is a string |
Request examples
curl https://www.jytoken.net/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [{"role": "user", "content": "Say hello in three sentences"}]
}'curl https://www.jytoken.net/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"stream": true,
"messages": [{"role": "user", "content": "Say hello in three sentences"}]
}'Response parameters
A non-streaming response is the upstream JSON. Billing only reads usage.prompt_tokens and usage.completion_tokens; if either is missing, the call returns 502 instead of being treated as successful.
| Parameter | Description | Type |
|---|---|---|
| id | Completion ID | string |
| object | Always chat.completion | string |
| created | Unix timestamp in seconds | integer |
| model | Model name in the response | string |
| choices | Reply list, see the next table | array |
| usage.prompt_tokens | Input token count | integer |
| usage.completion_tokens | Output token count | integer |
| usage.total_tokens | Input plus output | integer |
| usage.prompt_tokens_details.cached_tokens | Cached input tokens. This field may be absent when the upstream does not return it | integer |
| choices field | Description |
|---|---|
| index | Starts at 0 |
| finish_reason | stop means a normal finish, length means the length limit was reached. Other values come from the upstream unchanged |
| message.role | assistant |
| message.content | Reply text |
{
"id": "e007a136b54e49aaa0e3c2b9aa3dc27e",
"object": "chat.completion",
"created": 1793604508,
"model": "YOUR_MODEL_ID",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {"role": "assistant", "content": "Hi, how are you?"}
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 9,
"total_tokens": 21,
"prompt_tokens_details": {"cached_tokens": 0},
"completion_tokens_details": {"reasoning_tokens": 0}
}
}A streaming response uses SSE. Each data: line carries one JSON object, and data: [DONE] marks the end. Incremental text is in choices[0].delta.content.
data: {"id":"chatcmpl-example","object":"chat.completion.chunk","created":1793604511,"model":"YOUR_MODEL_ID","choices":[{"index":0,"delta":{"content":"Hi"}}]}
data: [DONE]If the stream breaks, the upstream omits complete usage, or settlement fails, you receive a data: {"error": ...} line. When the balance is insufficient, error.type is insufficient_quota and error.code is insufficient_balance or insufficient_budget.
Messages API
Endpoint: POST https://www.jytoken.net/v1/messages. Authentication accepts x-api-key and Authorization: Bearer; send anthropic-version: 2023-06-01 as well. max_tokens is required.
system, messages, content blocks, tools, and tool_choice are accepted in Anthropic Messages form. Routing is native-first: a model with an Anthropic channel passes through unchanged; otherwise the gateway converts to an OpenAI Chat channel.
On the conversion path, thinking.type=enabled, document/audio/video blocks, MCP/container, and images/documents inside tool_result return 400 unsupported_by_provider. Historical assistant thinking blocks are dropped without blocking the main flow.
curl https://www.jytoken.net/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Say hello in three sentences"}]
}'{
"id": "msg_example",
"type": "message",
"role": "assistant",
"model": "YOUR_MODEL_ID",
"content": [{"type": "text", "text": "Hi, how are you?"}],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 12,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"output_tokens": 9
}
}The streaming event order is message_start → content_block_start → content_block_delta* → content_block_stop → message_delta → message_stop, with no data: [DONE]. Tool arguments arrive through input_json_delta.
event: message_start
data: {"type":"message_start","message":{"id":"msg_example","type":"message","role":"assistant","model":"YOUR_MODEL_ID","content":[],"usage":{"input_tokens":12,"output_tokens":0}}}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hi"}}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":9}}
event: message_stop
data: {"type":"message_stop"}For context budgeting, call POST https://www.jytoken.net/v1/messages/count_tokens. With an Anthropic channel it is proxied upstream; on the conversion path it returns a local estimate and is not billed or written to usage logs.
curl https://www.jytoken.net/v1/messages/count_tokens \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [{"role": "user", "content": "Say hello in three sentences"}]
}'Responses API
Endpoint: POST https://www.jytoken.net/v1/responses. Authentication uses Authorization: Bearer. input is required and may be a string or a Responses item array; max_output_tokens, instructions, tools, and tool_choice are accepted in Responses form.
Routing is native-first: a model with a Responses channel passes through unchanged; otherwise the gateway converts to an OpenAI Chat channel. The conversion path supports text, images, function tools, and the custom/namespace tool bridge used by Codex. Hosted tools (web_search/tool_search), local_shell_call, previous_response_id, conversation, background, and store=true return 400.
curl https://www.jytoken.net/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"input": "Say hello in three sentences"
}'{
"id": "resp_example",
"object": "response",
"created_at": 1793604508,
"status": "completed",
"model": "YOUR_MODEL_ID",
"output": [
{
"type": "message",
"role": "assistant",
"content": [{"type": "output_text", "text": "Hi, how are you?"}]
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 9,
"total_tokens": 21,
"input_tokens_details": {"cached_tokens": 0},
"output_tokens_details": {"reasoning_tokens": 0}
}
}Streaming events include response.created, response.output_item.added, response.output_text.delta, response.output_item.done, and response.completed; tool calls use response.function_call_arguments.delta. There is no data: [DONE].
event: response.created
data: {"type":"response.created","sequence_number":0,"response":{"id":"resp_example","object":"response","status":"in_progress","model":"YOUR_MODEL_ID","output":[]}}
event: response.output_text.delta
data: {"type":"response.output_text.delta","sequence_number":1,"delta":"Hi"}
event: response.completed
data: {"type":"response.completed","sequence_number":2,"response":{"id":"resp_example","object":"response","status":"completed","model":"YOUR_MODEL_ID","output":[{"type":"message","role":"assistant","content":[{"type":"output_text","text":"Hi"}]}],"usage":{"input_tokens":12,"output_tokens":9,"total_tokens":21}}}Error codes
The error body is {"error": {"message", "type", "code"}}, where type and code are the same. Messages uses the Anthropic envelope {"type":"error","error":{"type","message"}}; Responses and Chat use the OpenAI envelope above.
| HTTP | type | Description |
|---|---|---|
| 400 | invalid_request_error | The request body is not valid JSON |
| 401 | invalid_api_key | The key is missing, malformed, invalid, revoked, or expired |
| 402 | insufficient_balance | The account balance is insufficient |
| 402 | insufficient_budget | This key's budget limit has been exhausted |
| 403 | model_not_allowed | The key's model scope does not include this model |
| 403 | model_not_activated | The current account has not activated this model |
| 404 | model_not_found | The model ID does not exist |
| 429 | rate_limit_exceeded | The per-minute request or token limit for this key was exceeded |
| 502 | upstream_error | The upstream failed, or the response lacked complete prompt_tokens and completion_tokens |
| 503 | no_available_channel | No channel is available for this model |
| 503 | billing_unavailable | Billing is temporarily unavailable |
Video generation
Video API
Available paths
Video generation is asynchronous. Submit a task, then query it with the returned id. Authentication is the same as text: Authorization: Bearer <platform key>.
| API | Method and path | Description |
|---|---|---|
| Create task | POST https://www.jytoken.net/v1/videos | Creates a video task and returns its id immediately |
| Get task | GET https://www.jytoken.net/v1/videos/{id} | Reads task status; returns the result URL when complete |
Only models whose input_modalities include video can be submitted. Those models currently still record output_modalities as text. The API returns a video task and result URL, not chat text.
Current video models
Catalog
These are the video models currently callable on the test site. The vendor is volcengine_ark. Set model to the model ID.
| Model ID | Vendor | Catalog input | Catalog output |
|---|---|---|---|
| doubao-seedance-2-0-260128 | volcengine_ark | video | text |
| dreamina-seedance-2-0-260128 | volcengine_ark | video | text |
| dreamina-seedance-2-0-fast-260128 | volcengine_ark | video | text |
| dreamina-seedance-2-5-260628 | volcengine_ark | video | text |
Create-task parameters
Request fields
Endpoint: POST https://www.jytoken.net/v1/videos. The body is JSON.
| Parameter | Description | Required | Type |
|---|---|---|---|
| model | Video model ID, see the previous section | Yes | string |
| prompt | Text prompt. Fill this for text-to-video | No | string |
| seconds | Duration in seconds. Values below 4 become 4; values above 30 become 30 | No | integer |
| resolution | Resolution. Billing uses 1080p when omitted. Allowed: 480p, 720p, 1080p, 1440p, 2160p, 4k | No | string |
| first_frame_image | First-frame image URL. An empty string means omitted | No | string |
| last_frame_image | Last-frame image URL | No | string |
| reference_images | List of reference image URLs | No | array |
A request with a first frame, last frame, or reference image is billed as media input; otherwise it is billed as text-to-video. Use http or https image URLs. A task is kept for at most 60 minutes. If it is still unfinished, it is marked failed and the hold is released.
Submit example and response
Request example
curl https://www.jytoken.net/v1/videos \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "dreamina-seedance-2-0-260128",
"prompt": "海边日落,镜头缓慢前推",
"seconds": 5,
"resolution": "1080p"
}'Create response
A successful submit returns immediately, before the video exists. id is the platform task ID and is the value to query. status is queued.
{
"id": "01M6VIDEOEXAMPLETASKID",
"object": "video",
"model": "dreamina-seedance-2-0-260128",
"status": "queued",
"created_at": 1793604508,
"seconds": 5,
"resolution": "1080p"
}Query a task
Query request
GET /v1/videos/{id} returns a task only to the account that created it. Use the id from the create response, not the upstream task id.
curl https://www.jytoken.net/v1/videos/01M6VIDEOEXAMPLETASKID \
-H "Authorization: Bearer YOUR_API_KEY"Status
| status | Description |
|---|---|
| queued | Submitted and waiting |
| in_progress | Generating |
| completed | Finished. url is an array of result URLs |
| failed | Failed. error is the code and message is the detail. A failure is not charged |
Completed response
{
"status": "completed",
"object": "video",
"model": "dreamina-seedance-2-0-260128",
"created_at": 1793604508,
"seconds": 5,
"resolution": "1080p",
"url": ["https://example.com/result.mp4"]
}Video error codes
Create and query errors
The error body matches the text API: {"error": {"message", "type", "code"}}.
| HTTP | type | Description |
|---|---|---|
| 400 | invalid_request_error | The body is not valid JSON, or the current channel cannot build a video request |
| 400 | invalidRequestId | The query has no task id |
| 400 | body_limit_exceeded | The body exceeds the size limit |
| 401 | invalid_api_key | The key is missing, invalid, revoked, or expired |
| 402 | insufficient_balance | The account balance cannot cover the hold |
| 402 | insufficient_budget | This key's budget limit is exhausted |
| 403 | model_not_allowed | The key's model scope does not include this model |
| 403 | model_not_activated | The account has not activated this model |
| 404 | model_not_found | The model ID does not exist |
| 404 | model_not_video | This model is not a video model |
| 404 | platform_task_id_invalid | The task id does not exist |
| 404 | platform_task_not_found | The task does not belong to the current account |
| 502 | upstream_error | Upstream submit failed, or no task id was returned. Nothing is charged |
| 503 | no_available_channel | This model has no available channel |
| 503 | price_not_configured | This model has no video price and cannot be submitted |
| 503 | billing_unavailable | Billing is temporarily unavailable |
Account balance
Balance and cumulative usage
| Endpoint | Method and path | Description |
|---|---|---|
| Account limit | GET https://www.jytoken.net/v1/dashboard/billing/subscription | Returns the account total limit, available balance, and cumulative usage |
| Cumulative usage | GET https://www.jytoken.net/v1/dashboard/billing/usage | Returns settled usage in cents |
The query is account-scoped, not key-scoped. Any active key in the same account sees the same wallet balance. Amounts are always USD.
Subscription response
curl https://www.jytoken.net/v1/dashboard/billing/subscription \
-H "Authorization: Bearer YOUR_API_KEY"{
"object": "billing_subscription",
"has_payment_method": true,
"soft_limit_usd": 100,
"hard_limit_usd": 100,
"system_hard_limit_usd": 100,
"access_until": 1796198400,
"balance_usd": 70,
"held_usd": 5.35,
"remaining_usd": 64.65,
"currency": "USD"
}hard_limit_usd is available balance plus cumulative usage. Legacy clients compute the remaining balance as hard_limit_usd - total_usage / 100, which yields the available balance. remaining_usd, balance_usd, and held_usd are platform extensions you can read directly. access_until is compatibility only; prepaid accounts have no real expiry date.
Usage response
curl https://www.jytoken.net/v1/dashboard/billing/usage \
-H "Authorization: Bearer YOUR_API_KEY"{
"object": "list",
"total_usage": 3535.0842,
"total_usage_usd": "35.350842",
"currency": "USD"
}total_usage is in cents and is cumulative settled usage for the account, not usage in the requested date range. start_date and end_date are accepted for compatibility and ignored. For range reporting, use the console usage page or export.
Agent setup
OpenCode
Setup
OpenCode can connect through Chat Completions and is available now. After installation, run /connect and enter juyuan as the provider ID. Paste the key only in this step; do not put it in the config file.
Config file
Place the config in opencode.json in your user directory or at the project root. npm must be @ai-sdk/openai-compatible so requests go to /v1/chat/completions. Set baseURL to /v1 only. Use a model ID from the catalog, for example gpt-6-sol. Save the file, run /models, and select juyuan/gpt-6-sol.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"juyuan": {
"npm": "@ai-sdk/openai-compatible",
"name": "聚元 TokenHub",
"options": {
"baseURL": "https://www.jytoken.net/v1"
},
"models": {
"YOUR_MODEL_ID": { "name": "YOUR_MODEL_ID" }
}
}
}
}providers format
If your installed version uses providers instead of provider at the top level, the fields differ: put the package name in package, the URL in settings.baseURL, and the key variable name in env. With the wrong version's fields, the config is ignored and requests never reach this site.
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"juyuan": {
"name": "聚元 TokenHub",
"env": ["JUYUAN_API_KEY"],
"package": "@opencode/ai/providers/openai-compatible",
"settings": {
"baseURL": "https://www.jytoken.net/v1"
},
"models": {
"YOUR_MODEL_ID": { "name": "YOUR_MODEL_ID" }
}
}
}
}WorkBuddy
Setup
WorkBuddy custom models use Chat Completions and are available now. Open Models in Settings, or choose Custom at the bottom of the model picker, and select Custom as the provider.
Fields
| Field | Value |
|---|---|
| Endpoint | https://www.jytoken.net/v1 |
| API Key | The platform key itself, without Bearer |
| Model name | A model ID from the catalog, for example gpt-6-sol |
| Custom protocol | Off. When off, do not append /chat/completions to the endpoint |
| Image input | Off. Input modalities for the current catalog models are text |
| Thinking mode | Off. reasoning_efforts for the current catalog is empty |
| Tool calling | Off for now. capabilities is empty and the platform only forwards tools unchanged |
After saving, test the connection, then select this model in a new task. If the endpoint already ends with /v1/chat/completions while Custom protocol is off, the path is appended twice and returns 404.
Codex
Codex only uses the Responses protocol; wire_api must be responses, and that is also the default when omitted. It requests /responses after base_url. Write the following to .codex/config.toml in your user directory. On Windows that is %USERPROFILE%\.codex\config.toml. A project-level .codex/config.toml cannot change model_providers and will not take effect. Put the key in the JUYUAN_API_KEY environment variable, not in the file.
Set model to a catalog model ID that has a channel. A native Responses channel passes through unchanged; an OpenAI Chat-only model is converted automatically, which supports text and function tools. Responses-only features such as hosted tools and previous_response_id return 400.
model = "YOUR_MODEL_ID"
model_provider = "juyuan"
[model_providers.juyuan]
name = "聚元 TokenHub"
base_url = "https://www.jytoken.net/v1"
env_key = "JUYUAN_API_KEY"
wire_api = "responses"Claude Code
Claude Code uses Anthropic Messages. ANTHROPIC_BASE_URL points to the site root, and it requests /v1/messages itself. ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer, and ANTHROPIC_API_KEY is sent as x-api-key; both are accepted. Do not commit the key to the project repository. User-level config lives in ~/.claude/settings.json; on Windows that is %USERPROFILE%\.claude\settings.json.
Set ANTHROPIC_MODEL to a catalog model ID that has a channel. A native Anthropic channel passes through unchanged; an OpenAI Chat-only model is converted automatically, which supports text, images, and tool_use/tool_result. thinking, document/audio/video, and MCP return 400. Use /status to verify the actual endpoint and key source.
{
"env": {
"ANTHROPIC_BASE_URL": "https://www.jytoken.net",
"ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
"ANTHROPIC_MODEL": "YOUR_MODEL_ID"
}
}Other clients
Chat Completions clients
For clients that only call Chat Completions, set Base URL to https://www.jytoken.net/v1, use Authorization: Bearer, and set model to a model ID from the catalog.
Messages / Responses clients
For /v1/messages, set Base URL to https://www.jytoken.net/v1 and use x-api-key or Bearer; for /v1/responses, use Bearer. Both can reuse catalog models: the gateway applies native-first routing and falls back to OpenAI Chat conversion when no native channel exists.