Developer docs / AI model API
AI Model API
Call supported LINGTU text and vision models through one OpenAI-compatible endpoint with JSON or SSE streaming responses.
POST
/v1/relay/chat/completions- Authentication:
- Request header x-api-key: <YOUR_API_KEY>; keep the key on the server and never expose it in client code, logs or shared files.
- Success criteria:
- Read choices for non-streaming responses; concatenate choices[0].delta.content for streaming responses and stop after data: [DONE]; also check the HTTP status.
Request body fields
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Supported model identifier available to the current account |
messages | RelayChatMessage[] | Yes | OpenAI-compatible messages with text and supported image_url content |
stream | boolean | No | When true, returns incremental SSE content; defaults to false |
max_tokens | integer | No | Maximum output tokens |
thinking.type | enabled | disabled | No | Enable or disable thinking when supported by the selected model |
Keep API keys on the server. Never place x-api-key in browser code, logs, or public files.
With stream=true, parse each data: line and concatenate choices[0].delta.content until data: [DONE].
Compute usage depends on the selected model, input content, output length, and multimodal inputs such as images.
image_url must be reachable by the model service; choose an appropriate detail level for the task.
Success response
{
"id": "chatcmpl_2066122904659169280",
"model": "deepseek-v4-flash-vision-exp",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "请求已完成。"
},
"finish_reason": "stop"
}
]
}Response and errors
Main response fields come from the published contract; see the JSON Schema. Required refers to the constraint in the containing object.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | No | — |
model | string | No | — |
choices | object[] | Yes | — |
choices[].index | integer | Yes | — |
choices[].message | object | Yes | — |
choices[].message.role | string | Yes | Fixed value: assistant |
choices[].message.content | string | Yes | — |
choices[].finish_reason | string | null | No | — |
choices[].delta | object | Yes | — |
choices[].delta.content | string | No | — |
HTTP 400The request parameters or body are invalid. Fix them and retry.HTTP 401The API key is missing or invalid. Check x-api-key.HTTP 403The API key has no permission to call this endpoint.HTTP 429Too many requests. Retry with exponential backoff.HTTP 500The server failed. Retry transient failures with exponential backoff.
Fix parameter, permission or authorization errors before retrying. If task creation times out, query existing tasks first and do not submit duplicates after an interrupted poll.
Last updated · 2026-11-16