Chat completions
Creates a completion for a chat conversation. Compatible with OpenAI's chat.completions.create endpoint.
POST /openai/v1/chat/completions
The full OpenAI surface — same request body, same response shape, same streaming behavior.
Request body parameters
model string Required The model ID to use. See /docs/models-api.messages array Required [{ role: "system"|"user"|"assistant", content: ... }]max_tokens int Optional Max tokens to generate. Default: model's max context.temperature float Optional Sampling temperature 0–2. Default: 1.top_p float Optional Nucleus sampling probability. Default: 1.stream bool Optional Whether to stream partial tokens via SSE. Default: false.response_format object Optional {"type":"json_object"} to force JSON output.tools array Optional List of tools the model may call. See function calling.Python
response = client.chat.completions.create( model="deepseek-ai/DeepSeek-R1-0528", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is 2+2?"}, ], temperature=0.7, max_tokens=256,) print(response.choices[0].message.content)