Endpoint
Request Body
string
required
The model ID to use for generation. You can retrieve available models from the
/v1/models endpoint.array
An array of message objects for chat-style completions. Each message has:
role(string): One of “system”, “user”, or “assistant”content(string): The message content
messages or prompt must be provided.string
A raw text prompt for completion. Either
messages or prompt must be provided.integer
default:"16"
The maximum number of tokens to generate.
float
default:"1.0"
Sampling temperature. Use 0.0 for greedy decoding.
integer
default:"-1"
Top-k sampling parameter. -1 disables top-k filtering.
float
default:"1.0"
Top-p (nucleus) sampling parameter.
integer
default:"1"
Number of completions to generate (currently only n=1 is supported).
boolean
default:"false"
Whether to stream the response using Server-Sent Events (SSE).
array
default:"[]"
List of stop sequences (currently not implemented).
float
default:"0.0"
Presence penalty (currently not implemented).
float
default:"0.0"
Frequency penalty (currently not implemented).
boolean
default:"false"
Whether to ignore the end-of-sequence token and continue generation.
Response Format
Streaming Response
Whenstream=true, the endpoint returns Server-Sent Events (SSE) with the following format:
string
Unique completion ID (format:
cmpl-{uid}).string
Always “text_completion.chunk” for streaming responses.
array
Array of completion choices. Each choice contains:
delta(object): Incremental content updaterole(string): “assistant” (only in first chunk)content(string): Generated text fragment
index(integer): Choice index (always 0)finish_reason(string): null during generation, “stop” when complete
data: [DONE] message.
Examples
Chat Completion with Messages
Streaming Response
Using Python OpenAI Client
Streaming with Python OpenAI Client
Raw Prompt (Non-Chat)
Advanced Sampling Parameters
Notes
- The endpoint always returns streaming responses (Server-Sent Events format)
- Non-streaming responses are not yet implemented
- The
stop,presence_penalty, andfrequency_penaltyparameters are accepted but not yet implemented - Greedy decoding is automatically used when
temperature=0.0ortop_k=1 - Client disconnection triggers automatic request cancellation to free resources