Create a chat completion
Creates a model response for the given chat conversation. Learn more in the text generation guide.
Returns a chat completion object or, if the request is streamed, a sequence of server-sent events; chat completion chunks arrive as data: lines, and a completed stream ends with data: [DONE].
Streaming responses
Withstream: true, the response is a sequence of server-sent events
instead of one JSON object. Each event is a data: line holding a
chat.completion.chunk. Read the generated text from
choices[0].delta.content on each chunk, not from message, and
concatenate the pieces in order. The final chunk for each choice
carries a finish_reason. With stream_options.include_usage, one
more chunk with empty choices reports usage for the whole
request. A completed stream ends with data: [DONE].
Errors during streaming
The HTTP status is sent before generation starts, so a failure after that cannot change it. Instead, an event whose data is anerror
object, in the same shape as an error response body, reports the
failure. The request may be retried.
A stream that ends without data: [DONE], with or without an error
event, did not complete: treat the text received as partial. Lines
that begin with :, such as : keepalive, are comments that keep
an idle connection open; ignore them.Authorizations
A Reflection API key, sent in the Authorization header as Bearer <API key>. Create a key for your project from the Reflection platform.
Headers
How assistant messages without reasoning_content are handled. default applies the model's own rule: Beam-1.0-501B-A23B refuses them. auto accepts them and lets the API choose how to make up for the missing reasoning when needed, which can lower the quality of the response.
default, auto Body
Parameters not listed here are not supported: a request that includes one is refused.
ID of the model to use. Use List models to see the models available to you.
1Whether to stream the model response data to the client as it is generated using server-sent events. See the streaming guide for how to handle the streamed events.
The sampling temperature, from 0 to 2. Higher values such as 0.8 make the output more varied; lower values such as 0.2 make it more focused and consistent. Adjust this or top_p, not both. When omitted or null, the model's default_parameters.temperature from the models endpoints applies, if it lists one.
0 <= x <= 2The nucleus sampling threshold, from 0 to 1. The model samples only from the most likely tokens whose probabilities add up to top_p, so 0.1 limits it to the top 10% of probability mass. Adjust this or temperature, not both. When omitted or null, the model's default_parameters.top_p from the models endpoints applies, if it lists one.
0 <= x <= 1The maximum number of tokens that can be generated in the chat completion, including reasoning tokens.
Deprecated in favor of max_completion_tokens. The two cannot be set together. If both are omitted or null, the model's default_parameters.max_tokens applies, unreduced for the prompt. Your plan's per-request output limit applies if lower. At most 8,192 when logprobs is true.
x >= 1Maximum generated tokens, including visible output and reasoning tokens. The prompt plus this value should fit within context_length. Cannot be set together with max_tokens. If both are omitted or null, the model's default_parameters.max_tokens applies, unreduced for the prompt. Your plan's per-request output limit applies if lower. At most 8,192 when logprobs is true.
x >= 1Constrains effort on reasoning: a level name of 1 to 64 characters, such as low, medium, high, xhigh, or max. A model that lists reasoning.supported_efforts accepts only those values. When omitted or null, the default that retrieving the model reports in reasoning.default_effort applies; if it reports none, the model chooses its own effort. See the reasoning guide.
1 - 64Whether to return, in choices[].logprobs, the log probability of each output token in content. When true, the output budget, reasoning tokens included, is at most 8,192 tokens, and a larger limit is rejected. A model that does not list max_top_logprobs on the models endpoints accepts only false or null.
The maximum number of most likely tokens, from 0 to 20, to return at each token position, each with its log probability. When omitted or null, none are returned. A model accepts at most the max_top_logprobs it lists. A non-null value is allowed only when logprobs is true.
0 <= x <= 20How much to penalize a token for each time it has already appeared, from -2 to 2. Positive values reduce verbatim repetition; negative values encourage it. When omitted or null, the model's default_parameters.frequency_penalty from the models endpoints applies, if it lists one.
-2 <= x <= 2How much to penalize a token that has already appeared at least once, from -2 to 2. Positive values steer the model toward new words and topics; negative values keep it on them. When omitted or null, the model's default_parameters.presence_penalty from the models endpoints applies, if it lists one.
-2 <= x <= 2A stable identifier for the end user of your application, of at most 128 characters. Requests are attributed to it when detecting and handling misuse. The model never sees it. Send a hash of a username or email address rather than the value itself.
128Response
A chat completion, or a stream of chat completion chunks when stream is true.
Represents a chat completion response returned by the model, based on the provided input.