Create
Create
Generate a chat completion for the given messages using the specified model.
Body Parameters
List of messages in the conversation.
The identifier of the model to use.
The maximum number of tokens to generate.
Controls the likelyhood and generating repetitive responses.
An object specifying the format that the model must output.
Setting to { "type": "json_schema", "json_schema": {...} } enables Structured Outputs which ensures the model will match your supplied JSON schema.
If not specified, the default is {"type": "text"}, and model will return a free-form text response.
If True, generate an SSE event stream of the response. Defaults to False.
Controls randomness of the response by setting a temperature. Higher value leads to more creative responses. Lower values will make the response more focused and deterministic.
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.
List of tool definitions available to the model
Only sample from the top K options for each subsequent token.
Controls diversity of the response by setting a probability threshold when choosing the next token.
A unique identifier representing your application end-user for monitoring abuse.
Returns
curl https://api.llama.com/v1/chat/completions \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LLAMA_API_KEY" \
-d '{
"messages": [
{
"content": "string",
"role": "user"
}
],
"model": "model"
}'{
"completion_message": {
"role": "assistant",
"content": "string",
"stop_reason": "stop",
"tool_calls": [
{
"id": "id",
"function": {
"arguments": "arguments",
"name": "name"
}
}
]
},
"id": "id",
"metrics": [
{
"metric": "metric",
"value": 0,
"unit": "unit"
}
]
}