Skip to content
TutujinAPI

API reference

Chat Completions

Headers, parameters, request and response examples and the streaming format for POST /v1/chat/completions. OpenAI-compatible, so GPT, Claude, Gemini, DeepSeek and more run on one code path. Verified on this site, streaming included.

POST /v1/chat/completions is the endpoint you will use most: send a list of messages, get the model's reply. The format matches OpenAI Chat Completions, and every model the catalog lists for this endpoint — GPT, Claude, Gemini, DeepSeek, Qwen and others — works with the same code. We have verified this endpoint on this site, streaming included.

POSThttps://www.tutujin.com/v1/chat/completions

Headers

HeaderRequiredDescription
AuthorizationYesBearer sk-..., an API key from the console
Content-TypeYesapplication/json

Request body

ParameterTypeRequiredDescription
modelstringYesModel name, e.g. gpt-5.4-mini
messagesarrayYesThe conversation so far, oldest first — structure below
streambooleanNotrue streams the reply as server-sent events; default false
stream_optionsobjectNoWith streaming, {"include_usage": true} adds usage to the last chunk
max_tokensintegerNoMost tokens to generate. Some newer models use max_completion_tokens instead
max_completion_tokensintegerNoGeneration limit, including reasoning tokens on reasoning models
temperaturenumberNoSampling temperature, usually 0 to 2; higher is more varied. Reasoning models usually ignore or reject it
top_pnumberNoNucleus sampling; tune this or temperature, not both
nintegerNoNumber of candidate replies; each one is billed for the tokens it generates
stopstring or arrayNoStop generating when one of these strings appears
presence_penaltynumberNo-2 to 2; positive values push the model toward new topics
frequency_penaltynumberNo-2 to 2; positive values reduce repeated wording
response_formatobjectNo{"type": "json_object"} asks for JSON; some models support json_schema for strict structured output
toolsarrayNoFunction definitions the model may call (function calling)
tool_choicestring or objectNoauto, none, required, or a specific function
reasoning_effortstringNoReasoning depth such as low, medium, high; only some models support it
seedintegerNoBest-effort determinism for identical inputs; not guaranteed
userstringNoYour end-user identifier, useful when investigating abuse

Vendors support optional parameters to different degrees. A parameter a model does not support may be ignored or may return a 400, so try new models with a little traffic first.

The messages array

Each message is an object whose role is one of:

roleUse
systemSystem prompt: role, rules and output format; usually the first message
userUser input
assistantThe model's earlier replies, sent back as-is in multi-turn chats
toolThe result of a function call, with the matching tool_call_id

content is a string or an array. Use the array form for mixed text and images on models that support vision:

JSON
{
  "role": "user",
  "content": [
    { "type": "text", "text": "What is the total on this invoice?" },
    { "type": "image_url", "image_url": { "url": "https://example.com/invoice.png" } }
  ]
}

You can also inline an image in url as data:image/png;base64,....

Request example

curl https://www.tutujin.com/v1/chat/completions \
  -H "Authorization: Bearer $TUTUJIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [
      {"role": "system", "content": "You are a store support agent. Keep answers short and polite."},
      {"role": "user", "content": "How soon do orders ship?"}
    ],
    "temperature": 0.3
  }'

Response example

JSON
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1794000000,
  "model": "gpt-5.4-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "In-stock orders usually ship within 48 hours of payment."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 31,
    "completion_tokens": 22,
    "total_tokens": 53
  }
}
FieldDescription
choices[].message.contentThe model's answer
choices[].message.tool_callsPresent when the model decides to call a function: function name and JSON arguments
choices[].finish_reasonstop finished normally; length hit the generation limit; tool_calls wants you to run a function; content_filter was blocked by a safety policy
usage.prompt_tokensInput tokens, billed at the input price
usage.completion_tokensOutput tokens (including reasoning on reasoning models), billed at the output price
usage.prompt_tokens_details.cached_tokensInput tokens served from the context cache, when the model supports caching; billed at the cache-read price

Streaming

With "stream": true the server sends server-sent events. Each chunk is one data: {...} line with new text in choices[0].delta.content, and the stream ends with data: [DONE]:

Text
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":""}}]}

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"In-stock"}}]}

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

With an SDK, iterate over the stream:

stream = client.chat.completions.create(
    model="gpt-5.4-mini",
    messages=[{"role": "user", "content": "Write a 60-word product description"}],
    stream=True,
    stream_options={"include_usage": True},
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
    if chunk.usage:
        print("\n", chunk.usage)

Turn streaming on for long outputs: users see text sooner, and a single long wait is less likely to be cut off by a gateway or client timeout.

Notes

  • Model names must match the model hub exactly; they are case-sensitive.
  • A key only uses the lines of its own group. If a model returns 503 saying no channel is available, that group usually does not offer the model — try a key in another group. See Choosing a group.
  • Reasoning tokens count as output tokens, so reasoning models can cost noticeably more. Cap them with max_completion_tokens.
  • The server keeps no conversation state. Send the history with every request; longer history means more input tokens, so trim it when you can.
  • Tokens and cost for every request are listed under Usage in the console.

Models that support this endpoint

ModelVendorCheapest groupInput ¥/1MOutput ¥/1MPer request ¥
gpt-image-2OpenAIStandard——¥0.12
Claude Haiku 5.5AnthropicClaude Plus¥0.4¥2—
qwen3.5-plusQwenChina Models¥1.12¥6.72—
gemini-3.8-flashGoogleStandard¥1.5¥7.5—
gpt-5.4-miniOpenAIStandard¥1.5¥9—
deepseek-v4.1-flashDeepSeekChina Models¥2.8¥11.2—
Claude Sonnet 5.5AnthropicClaude Lite¥3.2¥16—
GPT-6.1 SolOpenAIStandard¥4¥20—
gemini-3.1-pro-previewGoogleStandard¥4¥24—
Claude Opus 5.5AnthropicClaude Lite¥8¥40—

Prices in CNY, cheapest group for each model; updated Nov 13, 2026, 1:33 AM.

681 models support this endpoint; the table shows some of them. See them all in the model hub

Still stuck? Add our WeChat support JsnonoChat and send the request id from the error message, and we will look into it.