Skip to main content
client.chat.create(...) maps to POST /chat/request. Non-streaming calls return the API JSON as a dict. Streaming calls return a ChatCompletionStream context manager.

Basic chat (non-streaming)

client.chat.completions(...) is an alias for create.

Streaming chat

Set stream=True and iterate token deltas as they arrive:

Vision (multimodal)

Tools calling

Built-in tools

Custom tools (non-streaming)

When the model returns a tool call, the API does not stream the tool-call payload even if stream=True. Handle the tool result, then continue the conversation.

Structured output

Request JSON that matches a schema with response_format:

Structured output with streaming

Reasoning

RAG with a knowledge base

In-memory chat

Pass prior turns with memoryChat so the model has conversation context: