curl --request POST \
--url https://{host}/v2/workspaces/slug:llm-gateway/webhooks/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
]
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [
{
content: '<string>',
name: '<string>',
tool_call_id: '<string>',
tool_calls: [
{
id: '<string>',
type: 'function',
function: {name: '<string>', arguments: '<string>'}
}
]
}
]
})
};
fetch('https://{host}/v2/workspaces/slug:llm-gateway/webhooks/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{host}/v2/workspaces/slug:llm-gateway/webhooks/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"cost": 123,
"duration_ms": 123,
"carbon": {}
}
}{
"error": "<string>",
"message": "<string>",
"code": "<string>",
"details": {},
"status": 123,
"retryAfter": 123,
"provider": "<string>",
"model": "<string>",
"provider_error_type": "<string>"
}{
"error": "<string>",
"message": "<string>",
"code": "<string>",
"details": {},
"status": 123,
"retryAfter": 123,
"provider": "<string>",
"model": "<string>",
"provider_error_type": "<string>"
}{
"error": "<string>",
"message": "<string>",
"code": "<string>",
"details": {},
"status": 123,
"retryAfter": 123,
"provider": "<string>",
"model": "<string>",
"provider_error_type": "<string>"
}{
"error": "<string>",
"message": "<string>",
"code": "<string>",
"details": {},
"status": 123,
"retryAfter": 123,
"provider": "<string>",
"model": "<string>",
"provider_error_type": "<string>"
}Create a chat completion
OpenAI-compatible chat completions. Routes the request through the gateway’s provider layer (OpenAI, Azure OpenAI, Anthropic, Vertex, Bedrock, OpenAI-compatible) based on the resolved model spec.
Streaming. When stream: true, the response is a text/event-stream
of OpenAI-compatible delta chunks (ChatCompletionChunk) terminated by
a literal data: [DONE] payload. Provider-native stream shapes
(Anthropic, Bedrock, Vertex) are normalised to OpenAI deltas before
being forwarded. Provider errors mid-stream are emitted as a synthetic
chunk with a content message followed by [DONE].
When stream: false (default), the response is a single JSON
ChatCompletionResponse. The non-streaming response is enriched with
usage.cost, usage.duration_ms, and usage.carbon (Prisme.ai
extensions over the standard OpenAI shape).
Prisme.ai extensions in the request body:
task_id- opaque correlation identifier for A2A flows.analytics_context- caller-supplied context (orgSlug,agent_id,user_id,context_id,agent_allowed_models,call_type,message_turn) used to enrichanalytics.llm.completionevents.
Rate limiting. 100 requests per 60 seconds per consumer
(auth.user_id or session.id).
Governance. Calls may be rejected with 403 MODEL_NOT_ALLOWED or
429 quota errors based on the caller’s organization governance
(resolved via ai-governance-v2), or with 403 HEADER_POLICY_VIOLATION
when a required upstream identity header would reach the model provider
empty (see header_policy).
curl --request POST \
--url https://{host}/v2/workspaces/slug:llm-gateway/webhooks/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
]
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [
{
content: '<string>',
name: '<string>',
tool_call_id: '<string>',
tool_calls: [
{
id: '<string>',
type: 'function',
function: {name: '<string>', arguments: '<string>'}
}
]
}
]
})
};
fetch('https://{host}/v2/workspaces/slug:llm-gateway/webhooks/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{host}/v2/workspaces/slug:llm-gateway/webhooks/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"cost": 123,
"duration_ms": 123,
"carbon": {}
}
}{
"error": "<string>",
"message": "<string>",
"code": "<string>",
"details": {},
"status": 123,
"retryAfter": 123,
"provider": "<string>",
"model": "<string>",
"provider_error_type": "<string>"
}{
"error": "<string>",
"message": "<string>",
"code": "<string>",
"details": {},
"status": 123,
"retryAfter": 123,
"provider": "<string>",
"model": "<string>",
"provider_error_type": "<string>"
}{
"error": "<string>",
"message": "<string>",
"code": "<string>",
"details": {},
"status": 123,
"retryAfter": 123,
"provider": "<string>",
"model": "<string>",
"provider_error_type": "<string>"
}{
"error": "<string>",
"message": "<string>",
"code": "<string>",
"details": {},
"status": 123,
"retryAfter": 123,
"provider": "<string>",
"model": "<string>",
"provider_error_type": "<string>"
}Authorizations
User-bound credential carrying an identity: either a session JWT
or a user access token (at:*) generated from the user settings UI.
Send as Authorization: Bearer <token>.
Org API keys (iak_*) are not accepted here - they carry
no user identity. Use the x-prismeai-api-key header instead
(see OrgApiKeyAuth).
Body
OpenAI-compatible chat completion request. Only the fields actually accepted by the gateway are documented here.
Model id from the catalogue (e.g. gpt-4o,
eu.anthropic.claude-sonnet-4-20250514-v1:0,
vertex-gemini-2.5-flash).
256Conversation history (system + user/assistant/tool turns).
Hide child attributes
Hide child attributes
Author role.
system, user, assistant, tool Message content. Either a plain string, or an array of typed parts (e.g. text + image) for multimodal inputs.
Optional author name (e.g. function name for tool messages).
For role: tool, the id of the tool call this message responds to.
Tool calls emitted by an assistant message.
Hide child attributes
Hide child attributes
Provider-issued tool call identifier.
Tool kind. Currently always function.
function Sampling temperature (provider-dependent range, typically 0–2).
Max tokens to generate.
Nucleus sampling parameter.
OpenAI-style frequency penalty.
OpenAI-style presence penalty.
One or more stop sequences (string or array of strings).
When true, the response is a text/event-stream of
ChatCompletionChunk deltas terminating with data: [DONE].
Tool/function definitions made available to the model. Forwarded to providers that support tool calling.
Tool selection hint: "auto", "none", "required", or
{ type: "function", function: { name } }.
OpenAI-style structured output hint
(e.g. { "type": "json_object" }).
Provider seed for reproducible sampling (where supported).
Prisme.ai extension. Opaque correlation id propagated to A2A (agent-to-agent) flows.
128Prisme.ai extension. Caller-supplied analytics context merged
into the analytics.llm.completion event.
Response
Successful completion. Content type depends on request.stream:
application/json: non-streamingChatCompletionResponse.text/event-stream: SSE stream ofChatCompletionChunkpayloads terminated bydata: [DONE].
Non-streaming chat completion response. Mirrors OpenAI's shape with
Prisme.ai extensions on usage (cost, duration_ms, carbon).
Generated id (chatcmpl-<correlationId>).
chat.completion Unix timestamp (seconds).
Resolved model id used to serve the request.
Hide child attributes
Hide child attributes
A single message in a chat completion request or response.
Hide child attributes
Hide child attributes
Author role.
system, user, assistant, tool Message content. Either a plain string, or an array of typed parts (e.g. text + image) for multimodal inputs.
Optional author name (e.g. function name for tool messages).
For role: tool, the id of the tool call this message responds to.
Tool calls emitted by an assistant message.
Hide child attributes
Hide child attributes
Provider-issued tool call identifier.
Tool kind. Currently always function.
function stop, length, tool_calls, content_filter, or another
provider-specific value.
Token, cost, and carbon accounting.
Hide child attributes
Hide child attributes
Prisme.ai extension. Estimated USD cost computed from
pricing.input_per_1m_tokens / pricing.output_per_1m_tokens
on the model document.
Prisme.ai extension. Wall-clock duration of the call.
Prisme.ai extension. Carbon-footprint estimate produced by
_compute-carbon-footprint.
Was this page helpful?