AI Service

Multi-model AI chat API: switch between models from several vendors with the model parameter — single-turn, multi-turn, streaming and image/video/audio understanding (on supported models).

/api/ai/

Service Description

The AI service offers chat capabilities out of the box, with models from several vendors (currently DeepSeek). The platform holds the vendor keys, so callers need no application or configuration of their own — handy for quickly validating content generation, summarisation or Q&A features.

Switching models takes only the model parameter: the endpoint, authentication and response shape stay identical. See the Model List endpoint below, or the model dropdown on the chat endpoint. New models are added by a super admin in the console; all vendor differences (upstream URL, key, capabilities) are absorbed server-side.

One endpoint covers both single-turn and multi-turn chats: send content for a quick single question, or messages (a JSON array with role and content) for multi-turn; streaming output is supported as well.

System prompts are configured per model by the platform (an admin maintains several and assigns one to each model). Callers need not — and cannot — change the generation strategy: temperature, max reply length and stop words are likewise platform-controlled and not accepted as request parameters, so every integrator gets the same, predictable behaviour.

Models marked as vision-capable also accept images (public image URLs) so they can answer about a picture; models marked as video-capable additionally accept videos (public video URLs, e.g. Doubao Seed 2.0 omni-modal) so they can watch the video and understand its audio track too; models marked as audio-capable also accept audios (public audio URLs) for speech transcription and audio understanding; models without these flags return an invalid-value error instead of silently dropping the parameter.

This service requires project signature authentication. With streaming enabled (stream=true) the response is pushed as SSE chunks rather than a single JSON body, and the live debugger on this page prints it character by character.

Response Format

Every endpoint returns the same JSON envelope; the payload is always inside data:

{
  "code": 10000,
  "msg": "成功",
  "data": { ... }
}
  • code: business status code. 10000 means success; anything else is an error — see the Error Codes page for the full list.
  • msg: a human-readable message you can show to end users, but never use it for program logic.
  • data: the payload; usually null on error. Each endpoint's Response section lists its data fields.

Judge success by code, not by the HTTP status code. View all error codes

Built-in Models

Platform-managed keys (DeepSeek / Moonshot / Volcengine Ark / Alibaba Bailian and more, extendable in the console) Signature Required

A single chat endpoint covers every model: switching models only changes the model parameter, while platform keys, upstream URLs, system prompts and sampling parameters are maintained by admins in the console.

POST /api/ai/BuiltInModel/chat Total calls: 0

AI Chat (unified entry)

Start a chat with the model of your choice: supports a single message, a full message list, a caller-supplied system prompt, image/video/audio understanding and streaming output.

Optional: omit to use the platform default model. Candidates come from the platform (see the Model List endpoint).

Optional: message content for a simple single-turn chat (provide at least one of content or messages)

Optional: for multi-turn chat, formatted as a JSON array with role set to user/assistant; takes precedence over content

Optional: temporarily override the platform setting; omit to use the prompt configured for the model; empty string to use no system prompt

Optional: only for models marked as vision-capable. Public image URLs as a JSON array or plain text (newline/comma separated); the per-model image cap is configured on the platform (adjustable in the console).

Optional: only for models marked as video-capable (e.g. Doubao Seed 2.0 omni-modal). Public video URLs as a JSON array or plain text (newline/comma separated); the per-model video cap is configured on the platform (adjustable in the console).

Optional: only for models marked as audio-capable (e.g. Doubao Seed 2.0 omni-modal). Public audio URLs as a JSON array or plain text (newline/comma separated); the per-model audio cap is configured on the platform (adjustable in the console). Upload the audio via the File Upload service first, then pass the returned URL here.

Optional: pass your own key (it must belong to the vendor of the chosen model); otherwise the platform key is used.

Optional: when true, the response is SSE (text/event-stream), pushed chunk by chunk

  • The request body is an application/x-www-form-urlencoded form; this service requires the project signature.
  • Provide at least one of content or messages, otherwise a missing parameter error is returned.
  • The images parameter works only for vision-capable models; other models return an invalid-value error (20003). The number of images is capped per model on the platform (adjustable in the console); exceeding the cap returns the same invalid-value error.
  • videos works only for video-capable models (e.g. Doubao Seed 2.0 omni-modal, which understands both the picture and the audio track); other models return an invalid-value error (20003). The video count limit is likewise configured per model by the platform, and going over it returns an invalid-value error.
  • audios works only for audio-capable models (e.g. Doubao Seed 2.0 omni-modal, for speech transcription and audio understanding); other models return an invalid-value error (20003). The audio count limit is likewise configured per model by the platform, and going over it returns an invalid-value error.
  • Temperature, max reply length and stop words are configured per model by the platform and are not accepted from callers; passing one returns an invalid-value error (20003).
  • Streaming mode returns SSE: each frame is either data: {"content": "chunk"} (the answer) or data: {"reasoning": "chunk"} (a reasoning model's thinking; only such models emit it, and it is sent separately from the answer, so ignore it if you only care about the answer), terminated by data: [DONE]. The live debugger renders the answer as Markdown and prints it character by character; a reasoning model's thinking goes into a collapsible "Reasoning" block that is expanded while it streams and collapses once the answer starts.
  • Live debugging really consumes upstream quota — make sure the platform key works first.
  • The former prefix-completion capability (prefix / prefix_content) has been retired; passing it returns an invalid-value error.
Response Common envelope

The fields below describe data when stream=false; with stream=true the response becomes an SSE text stream (pushed frame by frame, see above) and does not use this structure.

Field Type Description
reply string Model reply text (Markdown)
model string Public model identifier
usage object Token usage; null when not returned by upstream
usage.prompt_tokens int Prompt tokens
usage.completion_tokens int Completion tokens
usage.total_tokens int Total tokens
finish_reason string Finish reason; may be null
Example response
{
  "reply": "示例回复内容",
  "model": "deepseek-chat",
  "usage": {"prompt_tokens": 10, "completion_tokens": 20, "total_tokens": 30},
  "finish_reason": "stop"
}
GET /api/ai/BuiltInModel/models Total calls: 0

Model List

List the models currently available on the platform (key, display name, vision/video/audio support, whether it is the default).

  • Lets callers discover available models dynamically instead of hardcoding model names in the client.
  • Returns model information only: no vendor, upstream URL or key.
  • Requests that omit model use the entry whose is_default is true.
Response Common envelope
Field Type Description
models array Available model list
models[].model string Model identifier (the value of the model param)
models[].name string Display name
models[].supports_vision bool Whether vision is supported (images allowed)
models[].supports_video bool Whether video understanding is supported (videos allowed)
models[].supports_audio bool Whether audio understanding is supported (audios allowed)
models[].context_window int Context length; null when unknown
models[].is_default bool Whether it is the default model
Example response
{
  "models": [
    {"model": "deepseek-chat", "name": "DeepSeek Chat", "supports_vision": false,
     "supports_video": false, "supports_audio": false, "context_window": 65536,
     "is_default": true}
  ]
}
XiaoYingAPI · Unified API Aggregation Service