POST
/api/v1/gatewaySend chat request through the gateway
Routes a chat completion through the LLM gateway with automatic provider selection, caching, rate limiting, and circuit breaking. Supports fallback models.
Authentication
Send Authorization: Bearer YOUR_API_KEY on every request. Generate API keys at /dashboard/api-keys.
Request body required
Example
{
"messages": [
{
"role": "system",
"content": "string"
}
],
"model": "gpt-4o",
"tenantId": "00000000-0000-0000-0000-000000000000",
"options": {
"temperature": 0.7,
"maxTokens": 1024,
"fallbackModels": [
"string"
]
}
}Schema
{
"application/json": {
"schema": {
"type": "object",
"required": [
"messages",
"model"
],
"properties": {
"messages": {
"type": "array",
"items": {
"type": "object",
"required": [
"role",
"content"
],
"properties": {
"role": {
"type": "string",
"enum": [
"system",
"user",
"assistant"
]
},
"content": {
"type": "string"
}
}
}
},
"model": {
"type": "string",
"example": "gpt-4o"
},
"tenantId": {
"type": "string",
"format": "uuid"
},
"options": {
"type": "object",
"properties": {
"temperature": {
"type": "number",
"default": 0.7
},
"maxTokens": {
"type": "integer",
"default": 1024
},
"fallbackModels": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}Response
All status codes
200Chat completion response with usage, latency, and cost
502All models failed
Code samples
cURL
curl -X POST \
https://evalguard.ai/api/v1/gateway \
-H "Authorization: Bearer $EVALGUARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "messages": [ { "role": "system", "content": "string" } ], "model": "gpt-4o", "tenantId": "00000000-0000-0000-0000-000000000000", "options": { "temperature": 0.7, "maxTokens": 1024, "fallbackModels": [ "string" ] } }'TypeScript
import { EvalGuard } from "@evalguard/sdk";
const client = new EvalGuard({ apiKey: process.env.EVALGUARD_API_KEY });
const response = await client.request({
method: "POST",
path: "/api/v1/gateway",
body: {
"messages": [
{
"role": "system",
"content": "string"
}
],
"model": "gpt-4o",
"tenantId": "00000000-0000-0000-0000-000000000000",
"options": {
"temperature": 0.7,
"maxTokens": 1024,
"fallbackModels": [
"string"
]
}
},
});
console.log(response);Python
from evalguard import EvalGuard
import os
client = EvalGuard(api_key=os.environ["EVALGUARD_API_KEY"])
response = client.request(
method="POST",
path="/api/v1/gateway",
body={
"messages": [
{
"role": "system",
"content": "string"
}
],
"model": "gpt-4o",
"tenantId": "00000000-0000-0000-0000-000000000000",
"options": {
"temperature": 0.7,
"maxTokens": 1024,
"fallbackModels": [
"string"
]
}
},
)
print(response)Go
package main
import (
"context"
"fmt"
"os"
"github.com/evalguard/evalguard-go"
)
func main() {
client := evalguard.NewClient(os.Getenv("EVALGUARD_API_KEY"))
resp, err := client.Request(context.Background(), "POST", "/api/v1/gateway", map[string]any{"messages": []any{map[string]any{"role": "system", "content": "string"}}, "model": "gpt-4o", "tenantId": "00000000-0000-0000-0000-000000000000", "options": map[string]any{"temperature": 0.7, "maxTokens": 1024, "fallbackModels": []any{"string"}}})
if err != nil { panic(err) }
fmt.Println(resp)
}Errors
502