Create Chat Completion
Create a chat completion with automatic session creation if enabled.
Authorization
AuthorizationRequiredBearer <token>🚀 OAuth2 authentication via secure identity provider
In: header
Scope: openid, email, profile
AuthorizationRequiredBearer <token>🎫 JWT Bearer token from OAuth2 login or direct token
In: header
Authorization<token>🗝️ API key in format: 'Bearer sk-xxxxxx'
In: header
Request Body
application/jsonRequiredmodelstring | null | nullmessagesRequiredMessagestemperaturenumber | null | nulltop_pnumber | null | nullninteger | null | nullstreamboolean | null | nullstopstring | array<unknown> | null | nullmax_tokensinteger | null | nullpresence_penaltynumber | null | nullfrequency_penaltynumber | null | nulltoolsarray<unknown> | null | nulltool_choicestring | object | null | nullsession_idstring | null | nullResponse Body
Successful Response
TypeScript Definitions
Use the response body type in TypeScript.
responseRequiredunknownValidation Error
TypeScript Definitions
Use the response body type in TypeScript.
detailDetail@minItems 0
curl -X POST "https://example.com/api/v1/chat/completions" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "string",
"messages": [
{
"role": "string",
"content": "string",
"name": "string",
"tool_calls": [
{}
],
"tool_call_id": "string"
}
],
"temperature": 1,
"top_p": 1,
"n": 1,
"stream": false,
"stop": "string",
"max_tokens": 0,
"presence_penalty": 0,
"frequency_penalty": 0,
"tools": [
{
"type": "function",
"function": {
"name": "string",
"description": "string",
"parameters": {}
}
}
],
"tool_choice": "string",
"session_id": "string"
}'const body = JSON.stringify({
"model": "string",
"messages": [
{
"role": "string",
"content": "string",
"name": "string",
"tool_calls": [
{}
],
"tool_call_id": "string"
}
],
"temperature": 1,
"top_p": 1,
"n": 1,
"stream": false,
"stop": "string",
"max_tokens": 0,
"presence_penalty": 0,
"frequency_penalty": 0,
"tools": [
{
"type": "function",
"function": {
"name": "string",
"description": "string",
"parameters": {}
}
}
],
"tool_choice": "string",
"session_id": "string"
})
fetch("https://example.com/api/v1/chat/completions", {
headers: {
"Authorization": "Bearer <token>"
},
body
})package main
import (
"fmt"
"net/http"
"io/ioutil"
"strings"
)
func main() {
url := "https://example.com/api/v1/chat/completions"
body := strings.NewReader(`{
"model": "string",
"messages": [
{
"role": "string",
"content": "string",
"name": "string",
"tool_calls": [
{}
],
"tool_call_id": "string"
}
],
"temperature": 1,
"top_p": 1,
"n": 1,
"stream": false,
"stop": "string",
"max_tokens": 0,
"presence_penalty": 0,
"frequency_penalty": 0,
"tools": [
{
"type": "function",
"function": {
"name": "string",
"description": "string",
"parameters": {}
}
}
],
"tool_choice": "string",
"session_id": "string"
}`)
req, _ := http.NewRequest("POST", url, body)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}import requests
url = "https://example.com/api/v1/chat/completions"
body = {
"model": "string",
"messages": [
{
"role": "string",
"content": "string",
"name": "string",
"tool_calls": [
{}
],
"tool_call_id": "string"
}
],
"temperature": 1,
"top_p": 1,
"n": 1,
"stream": false,
"stop": "string",
"max_tokens": 0,
"presence_penalty": 0,
"frequency_penalty": 0,
"tools": [
{
"type": "function",
"function": {
"name": "string",
"description": "string",
"parameters": {}
}
}
],
"tool_choice": "string",
"session_id": "string"
}
response = requests.request("POST", url, json = body, headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
})
print(response.text)null{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}How is this guide?
Update Automation Settings PUT
Update automation settings for the authenticated user.
Create Chat Completion POST
Create a chat completion with automatic session creation if enabled. Set Accept header to 'text/event-stream' for streaming responses, especially for tool calls. Set Accept header to 'application/json' for non-streaming responses. Note: Tool calling requires streaming mode and 'text/event-stream' Accept header.