Create chat completion
Chat
Create chat completion
Call Claude, GPT, and other text models through the OpenAI-compatible protocol.
POST
Create chat completion
/v1/chat/completions is the recommended DimiLinks chat endpoint. Its request and response structures match the official OpenAI endpoint, so you can use the OpenAI SDK directly. Set model to the name of a text model available to the current key to call Claude, GPT, or another model.
Request URL
Basic example
Streaming
Add"stream": true to the request. The server returns incremental chunks as text/event-stream and ends with data: [DONE].
Parameters
The table lists common fields. Any unlisted field is passed through to the upstream provider when the model supports it.| Parameter | Type | Default | Description |
|---|---|---|---|
model | string | Required | Model ID, such as claude-sonnet-5, claude-opus-4-8, gpt-5.5, gpt-5.6-terra, or qwen3.7-max. |
messages | array | Required | Message array containing at least one role=user item. Supported roles are system / user / assistant / tool. |
stream | boolean | false | When true, returns SSE streaming chunks. |
temperature | number | Model default | Sampling temperature from 0 to 2. |
top_p | number | Model default | Nucleus sampling probability from 0 to 1. |
max_tokens | integer | Model default | Maximum tokens in one response; we recommend setting it explicitly for Claude models. |
stop | string | string[] | Empty | Stop generation when one of these sequences is matched. |
presence_penalty | number | 0 | Penalty for repeating topics, from -2 to 2. |
frequency_penalty | number | 0 | Penalty for repeating words, from -2 to 2. |
tools | array | Empty | Tool definitions compatible with OpenAI Tool Calling. |
tool_choice | string | object | auto | Controls whether a specific tool must be called. |
response_format | object | Empty | Requests JSON output, for example { "type": "json_object" }. |
user | string | Empty | End-user identifier for auditing and rate limiting. |
Recommended models
| Scenario | Models |
|---|---|
| General chat / long documents | claude-sonnet-5, claude-opus-4-8, gpt-5.5 |
| Complex reasoning / coding | claude-opus-4-8, kimi-k2.7-code, gpt-5.6-terra |
| Chinese-language and general tasks | qwen3.7-max, glm-5.2, MiniMax-M3 |
| Low-cost batch tasks | claude-haiku-4-5, gpt-5.4-mini, deepseek-v4-flash |
| Multimodal vision | gpt-image-2 is dedicated to image generation. Visual chat support varies by model; first inspect input_modalities from /v1/models. |
Call with the OpenAI SDK
Python:Tool calling
tool_calls, execute the tool, add its result to messages as a role=tool message, and call the endpoint again.
Error handling
Failed requests return the OpenAI-styleerror wrapper. See Errors. If an upstream connection closes during a streaming request, the final event may not be [DONE]; treat a closed connection as a retryable error as well.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json