Skip to main content
The chat completions endpoint is the main way to generate text with the Deepshi API. It’s fully OpenAI-compatible, so your existing prompts, SDKs, and tooling work unchanged.

Basic request

Send a list of messages. Each message has a role (system, user, or assistant) and content.

Common parameters

Supported parameters vary by model. Unsupported fields are safely ignored rather than rejected.

Multi-turn conversations

The API is stateless, so it doesn’t remember previous calls. To continue a conversation, send the full message history each time and append the model’s previous reply as an assistant message:

Image input

Vision-capable models accept images alongside text. Send the message content as an array of parts: a text part and an image_url part, where the image is a URL or a base64 data: URI.

Streaming

Set "stream": true to receive the response incrementally as Server-Sent Events (SSE) instead of waiting for the full completion. This is ideal for chat UIs that render tokens as they arrive. Image requests can stream too; see Image generation.
Each event is a data: line with a partial chunk; tokens arrive in choices[0].delta.content. The final chunk carries a usage object with cost, and the stream ends with a data: [DONE] sentinel:
Streaming works the same way for tool calls: the arguments arrive incrementally in delta.tool_calls. Accumulate them until finish_reason is tool_calls.

Next steps

Tool calling

Let the model call your functions.

Reasoning

Use models that think before they answer.

Structured outputs

Force responses that match a JSON schema.