Send messages to any model and stream responses token-by-token using the OpenAI Python SDK.
client.chat.completions.create() is the core method — it maps directly to POST /v1/chat/completions. Every model in the catalog is available through it.
The response object is a standard ChatCompletion. Check resp.usage for token counts — input and output tokens are both billed at the model's DA rate.
Set stream=True to receive delta chunks over SSE as they are generated. The stream closes with data: [DONE].
The final chunk in the stream carries usage (prompt tokens, completion tokens). Your remaining DA balance is in the X-Balance-Available response header after each request.
Pass an array of content parts to include an image alongside text. The model must support the vision capability — filter by ?capability=vision in the model catalog.
| Parameter | Type | Description |
|---|---|---|
model | string | Required. Model slug, e.g. openai/gpt-5.4. |
messages | array | Required. Array of {role, content} objects. |
stream | bool | Stream tokens as SSE. Default false. |
max_tokens | int | Cap on output tokens. |
temperature | float | 0–2. Higher = more varied output. |
top_p | float | 0–1. Nucleus sampling threshold. |
Note. Tool/function calling (
tools,tool_choice) and structured outputs (response_format) are supported and forwarded on every request — see the Tool Calling page.