Chat Completions
The chat completions endpoint generates responses in a conversational format. This endpoint is compatible with OpenAI’s/v1/chat/completions API.
Request
Parameters
Required
array
required
Array of message objects in the conversation.
string
required
Role of the message sender:
system, user, assistant, tool, function, or developer.string | array
required
Message content. Can be:
- A string for text-only messages
- An array of content parts for multimodal messages:
{"type": "text", "text": "..."}{"type": "image_url", "image_url": {"url": "..."}}{"type": "video_url", "video_url": {"url": "..."}}{"type": "audio_url", "audio_url": {"url": "..."}}
string
Name of the message sender.
array
Tool calls made by the assistant (for assistant messages).
string
ID of the tool call this message is responding to (for tool messages).
string
required
Model name. Supports LoRA adapters via
base-model:adapter-name syntax.Sampling Parameters
integer
Maximum number of tokens to generate. Replaces deprecated
max_tokens.integer
Deprecated: Use
max_completion_tokens instead.number
default:"1.0"
Sampling temperature between 0 and 2. Higher values make output more random.
number
default:"1.0"
Nucleus sampling threshold.
integer
Only sample from the top K tokens.
number
Minimum probability threshold for sampling.
integer
default:"1"
Number of chat completion choices to generate.
integer
Random seed for deterministic generation.
string | array
Stop sequences.
array
Stop token IDs.
Penalization
number
default:"0.0"
Penalizes tokens based on frequency. Range: [-2.0, 2.0].
number
default:"0.0"
Penalizes tokens based on presence. Range: [-2.0, 2.0].
number
default:"1.0"
Penalizes repeated tokens.
Structured Output
object
Format of the response:
{"type": "text"}- Plain text (default){"type": "json_object"}- Valid JSON object{"type": "json_schema", "json_schema": {...}}- JSON matching schema
string
Regular expression for constrained generation.
string
EBNF grammar for constrained generation.
Tools & Function Calling
array
string | object
default:"auto"
Controls tool usage:
auto: Model decides whether to call toolsnone: Model will not call toolsrequired: Model must call at least one tool{"type": "function", "function": {"name": "..."}}: Force specific tool
Logging & Debugging
boolean
default:"false"
Whether to return log probabilities.
integer
Number of top log probabilities to return (requires
logprobs=true).object
Bias certain tokens. Maps token IDs to bias values between -100 and 100.
Streaming
boolean
default:"false"
Whether to stream the response.
object
Streaming options:
include_usage: Include usage statistics in final chunkcontinuous_usage_stats: Include usage stats in each chunk
Multimodal
integer
Maximum number of dynamic patches for vision models.
integer
Minimum number of dynamic patches for vision models.
Reasoning Models
string
default:"medium"
Constrains reasoning effort for reasoning models:
low: Least effort, faster responsesmedium: Balanced efforthigh: Most effort, more thorough reasoning
boolean
default:"true"
Separate reasoning content from final response.
boolean
default:"true"
Stream reasoning tokens during generation.
SGLang Extensions
boolean
default:"false"
Continue generation even after EOS token.
boolean
default:"true"
Whether to skip special tokens in output.
boolean
default:"false"
Do not trim stop sequences from output.
string | array
Regular expression(s) to use as stop conditions.
integer
default:"0"
Minimum number of tokens to generate.
boolean
default:"false"
Continue from the last assistant message.
string
Path to LoRA adapter weights.
object
Additional kwargs to pass to the chat template.
string
Custom logit processor for advanced sampling control.
Return hidden states from the model.
boolean
default:"false"
Return expert routing information for MoE models.
boolean
default:"false"
Return detailed cache hit information.
Response
string
Unique identifier for the chat completion.
string
Always
"chat.completion".integer
Unix timestamp of creation time.
string
Model used for generation.
array
Array of chat completion choices.
integer
Choice index.
object
The generated message.
string
Role of the message (usually
"assistant").string | null
Message content.
string | null
Reasoning content for reasoning models.
object | null
string
Reason for completion end:
stop: Natural stop or stop sequencelength: Max tokens reachedtool_calls: Model called a toolcontent_filter: Content filteringabort: Request aborted
integer | string | null
The stop sequence that was matched.
object
object
Streaming Response
Whenstream=true, responses are sent as Server-Sent Events:
Examples
Basic Chat
Streaming Chat
Function Calling
JSON Output
Multimodal (Vision)
See Also
- Completions - Text completion format
- Embeddings - Generate embeddings
- Models - List available models
