Chat completions API
How to call chat models through the OpenAI-compatible /chat/completions endpoint: request format, streaming, tool calls and prompt caching.
Chat
POST /chat/completions takes the OpenAI request unchanged: messages, max_tokens, temperature, top_p, stop, tools and tool_choice, response_format, stream. Unknown fields are passed to the model. Every response carries an x-request-id header; quote it when you contact support.
Streaming
Set "stream": true to receive server-sent events. Add "stream_options": {"include_usage": true} to get token counts in the last chunk.
{
"model": "deepseek-v4-1-flash",
"stream": true,
"stream_options": { "include_usage": true },
"messages": [{ "role": "user", "content": "Hello" }]
}Prompt caching
Repeated prompt prefixes (system prompt, long documents, chat history) are cached by the provider. Cached input tokens are billed at the cheaper cache-hit price automatically. Keep the stable part of the prompt first and unchanged.
