# Chat completion (RAG-capable) POST /v1/a/adapters/llm/chat/completion Select code sample ``` const url = 'https://example.com/v1/a/adapters/llm/chat/completion'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', '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,"reasoning_effort":"none","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","agent_sid":"example","automation_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/a/adapters/llm/chat/completion \ --header 'Authorization: Bearer ' \ --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, "reasoning_effort": "none", "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", "agent_sid": "example", "automation_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 } }' ``` - /v1/a/adapters/llm/chat/completion ## Permission This operation needs the permission [`llm:chat:manage`](https://docs.aiva.apifonica.com/concepts/roles-and-permissions/#llm-chat-manage). ## Authorizations - **[bearerAuth](https://docs.aiva.apifonica.com/api/account/#bearerauth)** ## Request Bodyrequired Media typeapplication/json object **model** required string **messages** required Array\ A chat message. Content is a string; multimodal content is not supported. object **role** required string **content** required string **name** string **function\_call** A model-emitted function call (deprecated single-function form). object **name** string **arguments** JSON-encoded argument string. string **tool\_calls** Array\ object **id** required string **type** required string **function** required The function name and JSON-encoded arguments carried by a tool call. object **name** string **arguments** string **tool\_call\_id** string **max\_tokens** integer **temperature** number format: float **top\_p** number format: float **reasoning\_effort** Reasoning budget for reasoning-capable models (GPT-5 and newer). Omit to keep the model default (medium). Lower values cut latency; ‘none’ disables reasoning entirely. Forwarded to OpenAI and Azure OpenAI backends only; ignored by the other providers. string Allowed values: none minimal low medium high **n** integer **stream** boolean **stop** Array\ **presence\_penalty** number format: float **frequency\_penalty** number format: float **logit\_bias** object ***key*** additional properties integer **logprobs** boolean **top\_logprobs** integer **user** string **seed** integer **response\_format** object ***key*** additional properties any **tools** Array\ object **type** required string **function** object **name** required string **description** string **parameters** required JSON-Schema parameter definition, kept deliberately loose. object ***key*** additional properties any **tool\_choice** Tool-selection control: “none”/“auto”/“required” or an object. **functions** Array\ object **name** required string **description** string **parameters** required JSON-Schema parameter definition, kept deliberately loose. object ***key*** additional properties any **function\_call** Function-selection control (deprecated): “none”/“auto” or an object. **parallel\_tool\_calls** Whether tool calls may run in parallel. **stream\_options** object ***key*** additional properties any **engine** string Allowed values: open\_ai azure **provider** string **backend** string **gdpr\_required** boolean **metadata** object **call\_sid** string **agent\_sid** The agent the call runs under. string **automation\_sid** The automation that placed the call. Empty when no automation placed it. string **scenario\_sid** string **node\_id** string **account\_sid** string **target** Entity|intent|fallback|streaming string **source** Hermes|bff|ss|ids string **is\_test** boolean **fallback\_model** string **rag** object **document** object **ids** Array\ **number** integer **threshold** number format: float **is\_limit\_with\_documents** boolean ## Responses ### 200 OK Media typeapplication/json object **id** required string **object** required string **created** required integer format: int64 **model** required string **choices** required Array\ object **index** required integer **message** required A chat message. Content is a string; multimodal content is not supported. object **role** required string **content** required string **name** string **function\_call** A model-emitted function call (deprecated single-function form). object **name** string **arguments** JSON-encoded argument string. string **tool\_calls** Array\ object **id** required string **type** required string **function** required The function name and JSON-encoded arguments carried by a tool call. object **name** string **arguments** string **tool\_call\_id** string **finish\_reason** required string **logprobs** Per-token log-probability detail. **usage** required object **prompt\_tokens** required integer **completion\_tokens** required integer **total\_tokens** required integer **system\_fingerprint** required string ##### 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" } ``` ### 400 Invalid request body or parameters Media typeapplication/json 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 **name** required string **message** required string **code** required integer **status** required integer ##### Examplegenerated ``` { "name": "example", "message": "example", "code": 1, "status": 1 } ``` ### 401 Unauthorized ### 403 Forbidden ### 408 Upstream provider timed out Media typeapplication/json 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 **name** required string **message** required string **code** required integer **status** required integer ##### Examplegenerated ``` { "name": "example", "message": "example", "code": 1, "status": 1 } ``` ### 500 Internal server error Media typeapplication/json 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 **name** required string **message** required string **code** required integer **status** required integer ##### Examplegenerated ``` { "name": "example", "message": "example", "code": 1, "status": 1 } ``` ### 502 Bad gateway (upstream adapter error)