您的浏览器不支持JavaScript,请启用JavaScript以获得最佳体验。
AI Model API
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

FieldTypeRequiredDescription
modelstringYesSupported model identifier available to the current account
messagesRelayChatMessage[]YesOpenAI-compatible messages with text and supported image_url content
streambooleanNoWhen true, returns incremental SSE content; defaults to false
max_tokensintegerNoMaximum output tokens
thinking.typeenabled | disabledNoEnable 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.

FieldTypeRequiredDescription
idstringNo—
modelstringNo—
choicesobject[]Yes—
choices[].indexintegerYes—
choices[].messageobjectYes—
choices[].message.rolestringYesFixed value: assistant
choices[].message.contentstringYes—
choices[].finish_reasonstring | nullNo—
choices[].deltaobjectYes—
choices[].delta.contentstringNo—
  • 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