Chat completions
Request/response structure, streaming, and the equivalent endpoints in the Anthropic and Gemini protocols.
Chat completion is the most-used endpoint: send a list of messages to the model and get the generated reply back. The platform's primary entry is the OpenAI-compatible protocol; the Anthropic and Gemini protocols are isomorphic equivalents.
Request shape (OpenAI-compatible)
POST {base}/chat/completions — authentication in Authentication:
{
"model": "your-model",
"messages": [
{"role": "system", "content": "You are a support assistant."},
{"role": "user", "content": "Where is my order?"},
{"role": "assistant", "content": "Sure, may I have the order number?"},
{"role": "user", "content": "A1024"}
],
"temperature": 0.7,
"max_tokens": 1024,
"stream": false
}
messagesis the ordered conversation history;roleissystem/user/assistant. For multi-turn chats the client concatenates the full history and resends it each time;- Higher
temperaturemeans more varied output (commonly 0–1);max_tokenscaps the reply length; - Streaming: with
"stream": truethe response is pushed incrementally over SSE (choices[0].delta) — ideal for showing text as it is generated. Official SDKs: passstream=Trueand iterate.
Response shape
Key fields of a non-streaming response:
{
"choices": [
{
"message": {"role": "assistant", "content": "..."},
"finish_reason": "stop"
}
],
"usage": {"prompt_tokens": 58, "completion_tokens": 132, "total_tokens": 190}
}
choices[0].message.contentholds the reply;finish_reasonstopmeans it finished naturally,lengthmeans it was cut off bymax_tokens;usageis the token consumption of this call — billing and the "Usage" page are both based on it.
Equivalent endpoints in other protocols
- Anthropic:
POST {base}/v1/messages— field names differ (max_tokensis required, the reply lives in thecontentarray), semantics otherwise identical; - Gemini:
POST {base}/v1beta/models/{model}:generateContent— messages go in thecontentsarray.
The three protocols are isomorphic; migration is mostly field renaming. The practical move is to use the corresponding official SDK (openai / @anthropic-ai/sdk / @google/genai) with base_url pointed at the platform.

