curl --request POST \
--url https://{region}.context-router.slng.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "slng/auto",
"messages": [
{
"role": "system",
"content": "You are a helpful clinic assistant."
},
{
"role": "user",
"content": "What are your opening hours?"
}
]
}
'{
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>",
"name": "<string>",
"tool_calls": [
{}
],
"tool_call_id": "<string>"
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"error": {
"message": "Missing required agent id",
"type": "invalid_request_error",
"code": "missing_client_id"
}
}{
"error": {
"message": "Missing required template variables: appointment_time, city",
"type": "invalid_request_error",
"param": "template_variables",
"code": "missing_template_variables"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "missing_client_id"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "missing_client_id"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "missing_client_id"
}
}Create a chat completion
Route an OpenAI Chat Completions request. An agent ID and session ID are required, as
headers (X-Slng-Agent-Id, X-Slng-Session-Id) or body fields (slng_agent_id,
slng_session_id); the body field wins if both are sent.
curl --request POST \
--url https://{region}.context-router.slng.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "slng/auto",
"messages": [
{
"role": "system",
"content": "You are a helpful clinic assistant."
},
{
"role": "user",
"content": "What are your opening hours?"
}
]
}
'{
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>",
"name": "<string>",
"tool_calls": [
{}
],
"tool_call_id": "<string>"
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"error": {
"message": "Missing required agent id",
"type": "invalid_request_error",
"code": "missing_client_id"
}
}{
"error": {
"message": "Missing required template variables: appointment_time, city",
"type": "invalid_request_error",
"param": "template_variables",
"code": "missing_template_variables"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "missing_client_id"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "missing_client_id"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "missing_client_id"
}
}Authorizations
Send your SLNG API key as a Bearer token (an OpenAI SDK's api_key option). Provider
credentials in slng_config authenticate to those providers.
Headers
Stable agent ID. Scopes the cache — change it when the system prompt changes. Required
unless sent as slng_agent_id (body wins). Max 256 chars; no whitespace, commas, pipes
or braces.
Opaque ID. Max 256 characters; no whitespace, commas, pipes or braces.
256^[^\s,|{}]+$ID for a single call, constant across its turns. Required unless sent as
slng_session_id (body wins). Same character rules as the agent ID.
Opaque ID. Max 256 characters; no whitespace, commas, pipes or braces.
256^[^\s,|{}]+$Optional correlation ID, echoed back in x-slng-request-id. X-Request-Id is also
accepted.
Body
OpenAI Chat Completions body plus SLNG extensions. Unlisted OpenAI fields pass through.
OpenAI messages array. template_variables substitution touches the system message only.
1Show child attributes
Show child attributes
slng/auto (or omit) routes across your configured models with failover. Pass an
entry's model label to pin one — disabling failover and giving it a separate
cache. Any other value returns a 400.
"slng/auto"
"gpt-4o-mini"
OpenAI parameter, passed through.
OpenAI parameter, passed through.
OpenAI parameter, passed through.
OpenAI parameter, passed through.
true for SSE streaming, false for a single JSON response. Supported for every model.
Streaming options.
Show child attributes
Show child attributes
OpenAI tool definitions. Answers with tool calls, and the turn after a tool result, are not cached.
OpenAI tool choice, passed through.
SLNG extension. {name: value} map substituted into {{name}} placeholders in the
system message only. Names are letters, digits and underscore.
Limits (over any returns 422): 64 variables, 64-char names, 4000-char values. A
{{name}} with no value returns 422 (missing_template_variables); unused variables
are ignored.
Use for personalization that is spoken or echoed. Values that steer the answer (language, plan, region) belong in the prompt — steering here can make the cache serve another caller's answer.
Show child attributes
Show child attributes
{ "caller_name": "Rajesh", "city": "Mumbai" }
SLNG extension. Model endpoints and provider keys sent inline, replacing your saved
configuration for that request. Treat as a credential (HTTPS, keep out of logs); under
256 KB serialized. Invalid config returns 400 (invalid slng_config:); a non-object
returns 422 (invalid_slng_config).
Show child attributes
Show child attributes
Body form of X-Slng-Agent-Id. Required unless the header is sent; wins if both.
256^[^\s,|{}]+$Body form of X-Slng-Session-Id. Required unless the header is sent; wins if both.
256^[^\s,|{}]+$Set true to record the request and response (in-region) for analytics. Requires
both IDs.
Set true to return the provider response with no caching or edits. Routing and
failover still apply.
Response
Chat completion in OpenAI format, live or cached. See x-slng-response-source.