Chat completions
Headers
Body
Model ID used to generate the response. See the list of available options
A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, images, and audio.
1Developer-provided instructions that the model should follow, regardless of messages sent by the user.
- Developer message
- System message
- User message
- Assistant message
- Tool message
- Function message
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
We generally recommend altering this or top_p but not both.
0 <= x <= 21
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
0 <= x <= 11
An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
Modify the likelihood of specified tokens appearing in the completion.
Accepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time. This is most common when you are regenerating a file with only minor changes to most of the content.
Optional response format. JSON and JSON Schema modes, accepted schemas, and output behavior depend on the selected model and connection. Verify provider acceptance and validate each response; a request field or schema does not guarantee valid or schema-conformant output.
- Text
- JSON Object
- JSON Schema
A list of tools the model may call. You can provide either custom tools or function tools.
A function tool that can be used to generate a response.
- Function Tool
- Custom tool
Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool.
none is the default when no tools are present.
auto is the default if tools are present.
none, auto, required Deprecated in favor of tool_choice.
Controls which (if any) function is called by the model.
none means the model will not call a function and instead generates a message.
auto means the model can pick between generating a message or calling a function.
Specifying a particular function via {"name": "my_function"} forces the model to call that function.
none is the default when no functions are present. auto is the default if functions are present.
none, auto The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.
This value is now deprecated in favor of max_completion_tokens.
Whether to enable parallel function calling during tool use.
Response
OK
Represents a chat completion response returned by model, based on the provided input.