curl -N -X POST https://www.token-nova.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{ "role": "system", "content": "You are a concise technical assistant." },
{ "role": "user", "content": "Explain the role of an API gateway in three points." }
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"role":"assistant","content":"API"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":" gateway"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":26,"completion_tokens":38,"total_tokens":64}}
data: [DONE]
{
"error": {
"message": "field model is required",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "Insufficient user quota",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "The current request rate is too high. Please try again later.",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
OpenAI Format
Chat Completions API (Default Streaming)
Start a conversation using the OpenAI Chat Completions-compatible format and return model output via SSE streaming.
POST
https://www.token-nova.com
/
v1
/
chat
/
completions
curl -N -X POST https://www.token-nova.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{ "role": "system", "content": "You are a concise technical assistant." },
{ "role": "user", "content": "Explain the role of an API gateway in three points." }
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"role":"assistant","content":"API"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":" gateway"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":26,"completion_tokens":38,"total_tokens":64}}
data: [DONE]
{
"error": {
"message": "field model is required",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "Insufficient user quota",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "The current request rate is too high. Please try again later.",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
Chat Completions API (Default Streaming)
Use a unified conversation format to call upstream models such as OpenAI, Claude, Gemini, DeepSeek, and Qwen. This document uses streaming output as the default, making it suitable for chat, Agent, and long-text generation scenarios where output needs to be displayed as it is generated.If
stream is not provided in this project’s route, it is handled as non-streaming. If you want to always receive a streaming response, explicitly pass "stream": true.Request Body
string
required
Model name. You can check the models available to the current API Key via Model List.
array<object>
required
Conversation messages arranged in chronological order. Common roles are
system, user, assistant, and tool.string | array
required
Message content. A string indicates plain text; an array indicates multimodal content and supports
text, image_url, input_audio, file, and video_url.boolean
required
When set to
true, the response is text/event-stream, with each chunk pushed as data: and data: [DONE] returned at the end.boolean
Includes token usage statistics in the last message of the stream. Supported by only some upstream models.
integer
Limits the maximum number of generated tokens. For some reasoning models, it is recommended to use
max_completion_tokens instead.integer
Limits the maximum number of completion tokens, including reasoning tokens. Suitable for models that support reasoning.
number
Sampling temperature, commonly in the range
0 to 2. Lower values are more stable, higher values are more diverse.number
Nucleus sampling parameter, commonly in the range
0 to 1. It is generally not recommended to adjust temperature and top_p significantly at the same time.array<object>
Function-calling tool list, compatible with OpenAI
tools.string | object
Controls whether the model calls tools. Common values are
auto, none, and required; you can also specify a particular function.object
Specifies the output format, such as
{ "type": "json_object" } or json_schema.string
Reasoning effort. Common values are
low, medium, and high; whether it takes effect depends on the model.Request Example
curl -N -X POST https://www.token-nova.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{ "role": "system", "content": "You are a concise technical assistant." },
{ "role": "user", "content": "Explain the role of an API gateway in three points." }
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'
Multimodal Streaming
curl -N -X POST https://www.token-nova.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Summarize the main conclusions of this chart." },
{ "type": "image_url", "image_url": { "url": "https://.../chart.png", "detail": "high" } }
]
}
],
"stream": true
}'
Response Example
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"role":"assistant","content":"API"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":" gateway"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":26,"completion_tokens":38,"total_tokens":64}}
data: [DONE]
{
"error": {
"message": "field model is required",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "Insufficient user quota",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "The current request rate is too high. Please try again later.",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
Response Fields
string
The response ID generated for this request.
string
The streaming response is always
chat.completion.chunk.object
Incremental content. May include
role, content, reasoning_content, or tool_calls.string
Reason for completion. Common values are
stop, length, and tool_calls.object
Usage statistics. It is guaranteed to appear only when the upstream returns usage data and
stream_options.include_usage is enabled.