Create chat completions
Changed onThis function processes chat completion requests by determining whether to use streaming or non-streaming response handling based on the request payload. For streaming requests, it configures additional options to track token usage.
Returns
Returns a Response containing either:
- A streaming SSE connection for real-time completions
- A single JSON response for non-streaming completions
Errors
Returns an error status code if:
- The request processing fails
- The streaming/non-streaming handlers encounter errors
- The underlying inference service returns an error
Request
- Base URLhttps://api.atoma.network
- AuthHTTP bearer
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Request body
Example request
{
"functions": [
{
"name": "get_current_weather",
"description": "Get the current weather in a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The location to get the weather for"
}
},
"required": [
"location"
]
}
}
],
"logit_bias": {
"1234567890": 0.5,
"1234567891": -0.5
},
"max_completion_tokens": 4096,
"max_tokens": 4096,
"messages": [
{
"role": "system",
"content": "You are a helpful AI assistant"
},
{
"role": "user",
"content": "Hello!"
},
{
"role": "assistant",
"content": "I'm here to help you with any questions you have. How can I assist you today?"
}
],
"model": "meta-llama/Llama-3.3-70B-Instruct",
"n": 1,
"parallel_tool_calls": true,
"seed": 123,
"service_tier": "auto",
"temperature": 0.7,
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The location to get the weather for"
}
},
"required": [
"location"
]
}
}
}
],
"top_logprobs": 1,
"top_p": 1,
"user": "user-1234"
}Response
Chat completions
Changes
- info
added the required property
//////////to the response with the status
- info
- breaking
removed
subschema #1subschema #2subschema #3subschema #4from the/////request propertyoneOflist - breaking
added
subschema #1: Systemsubschema #2: Usersubschema #3: Assistantsubschema #4: Toolto the//response propertyoneOflist for the response status - info
added
subschema #1: Systemsubschema #2: Usersubschema #3: Assistantsubschema #4: Toolto the/////request propertyoneOflist - info
removed
subschema #1subschema #2subschema #3subschema #4from the//response propertyoneOflist for the response status
- breaking