Chat completion (RAG-capable)
const url = 'https://example.com/v1/adapters/llm/chat/completion';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"model":"example","messages":[{"role":"example","content":"example","name":"example","function_call":{"name":"example","arguments":"example"},"tool_calls":[{"id":"example","type":"example","function":{"name":"example","arguments":"example"}}],"tool_call_id":"example"}],"max_tokens":1,"temperature":1,"top_p":1,"n":1,"stream":true,"stop":["example"],"presence_penalty":1,"frequency_penalty":1,"logit_bias":{"additionalProperty":1},"logprobs":true,"top_logprobs":1,"user":"example","seed":1,"response_format":{},"tools":[{"type":"example","function":{"name":"example","description":"example","parameters":{}}}],"tool_choice":"example","functions":[{"name":"example","description":"example","parameters":{}}],"function_call":"example","parallel_tool_calls":"example","stream_options":{},"engine":"open_ai","provider":"example","backend":"example","gdpr_required":true,"metadata":{"call_sid":"example","campaign_sid":"example","scenario_sid":"example","node_id":"example","account_sid":"example","target":"example","source":"example","is_test":true},"fallback_model":"example","rag":{"document":{"ids":["example"],"number":1,"threshold":1},"is_limit_with_documents":true}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/adapters/llm/chat/completion \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "example", "messages": [ { "role": "example", "content": "example", "name": "example", "function_call": { "name": "example", "arguments": "example" }, "tool_calls": [ { "id": "example", "type": "example", "function": { "name": "example", "arguments": "example" } } ], "tool_call_id": "example" } ], "max_tokens": 1, "temperature": 1, "top_p": 1, "n": 1, "stream": true, "stop": [ "example" ], "presence_penalty": 1, "frequency_penalty": 1, "logit_bias": { "additionalProperty": 1 }, "logprobs": true, "top_logprobs": 1, "user": "example", "seed": 1, "response_format": {}, "tools": [ { "type": "example", "function": { "name": "example", "description": "example", "parameters": {} } } ], "tool_choice": "example", "functions": [ { "name": "example", "description": "example", "parameters": {} } ], "function_call": "example", "parallel_tool_calls": "example", "stream_options": {}, "engine": "open_ai", "provider": "example", "backend": "example", "gdpr_required": true, "metadata": { "call_sid": "example", "campaign_sid": "example", "scenario_sid": "example", "node_id": "example", "account_sid": "example", "target": "example", "source": "example", "is_test": true }, "fallback_model": "example", "rag": { "document": { "ids": [ "example" ], "number": 1, "threshold": 1 }, "is_limit_with_documents": true } }'Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
A chat message. Content is a string; multimodal content is not supported.
object
A model-emitted function call (deprecated single-function form).
object
JSON-encoded argument string.
object
The function name and JSON-encoded arguments carried by a tool call.
object
object
object
object
object
JSON-Schema parameter definition, kept deliberately loose.
object
Tool-selection control: “none”/“auto”/“required” or an object.
object
JSON-Schema parameter definition, kept deliberately loose.
object
Function-selection control (deprecated): “none”/“auto” or an object.
Whether tool calls may run in parallel.
object
object
Entity|intent|fallback|streaming
Hermes|bff|ss|ids
object
object
Responses
Section titled “Responses”OK
object
object
A chat message. Content is a string; multimodal content is not supported.
object
A model-emitted function call (deprecated single-function form).
object
JSON-encoded argument string.
object
The function name and JSON-encoded arguments carried by a tool call.
object
Per-token log-probability detail.
object
Examplegenerated
{ "id": "example", "object": "example", "created": 1, "model": "example", "choices": [ { "index": 1, "message": { "role": "example", "content": "example", "name": "example", "function_call": { "name": "example", "arguments": "example" }, "tool_calls": [ { "id": "example", "type": "example", "function": { "name": "example", "arguments": "example" } } ], "tool_call_id": "example" }, "finish_reason": "example", "logprobs": "example" } ], "usage": { "prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 1 }, "system_fingerprint": "example"}Invalid request body or parameters
Canonical structured error emitted by the chat completion, chat stream and
embeddings handlers (the shared errorResponse helper). code is an
application error code (0 when unset); status mirrors the HTTP status.
object
Examplegenerated
{ "name": "example", "message": "example", "code": 1, "status": 1}Unauthorized
Forbidden
Upstream provider timed out
Canonical structured error emitted by the chat completion, chat stream and
embeddings handlers (the shared errorResponse helper). code is an
application error code (0 when unset); status mirrors the HTTP status.
object
Examplegenerated
{ "name": "example", "message": "example", "code": 1, "status": 1}Internal server error
Canonical structured error emitted by the chat completion, chat stream and
embeddings handlers (the shared errorResponse helper). code is an
application error code (0 when unset); status mirrors the HTTP status.
object
Examplegenerated
{ "name": "example", "message": "example", "code": 1, "status": 1}Bad gateway (upstream adapter error)