POST
/api/v1/chat/completionsOpenAI-compatible chat completions ingress (T0-B round-6)
OpenAI-exact wire-format chat-completions endpoint. Drop-in compatible with the openai-node SDK + clients targeting `https://api.openai.com/v1/chat/completions` — point your base URL at EvalGuard and `model` decides which of our 90+ supported providers receives the call. Streaming (SSE) supported. Tools / function calls pass through. Vendor extension `evalguard.dicl.examples` enables prepending pre-retrieved few-shot pairs (1-E). For Anthropic targets, `metadata.cache_control: "ephemeral"` on any message activates prompt caching (1-C).
Authentication
Send Authorization: Bearer YOUR_API_KEY on every request. Generate API keys at /dashboard/api-keys.
Request body required
Example
{
"model": "<Model name; supports vendor-prefix (\"ant>",
"messages": [
{
"role": "system",
"name": "string",
"tool_call_id": "string",
"tool_calls": [
{
"id": "string",
"type": "function",
"function": {
"name": "string",
"arguments": "string"
}
}
],
"metadata": {}
}
],
"evalguard": {
"dicl": {
"examples": [
{
"input": "string",
"output": "string"
}
]
}
},
"temperature": 0,
"top_p": 0,
"n": 1,
"stream": false,
"max_tokens": 1,
"max_completion_tokens": 1,
"presence_penalty": -2,
"frequency_penalty": -2,
"seed": -9007199254740991,
"service_tier": "auto",
"user": "string",
"tools": [
{
"type": "function",
"function": {
"name": "string",
"description": "string",
"parameters": {}
}
}
],
"stream_options": {
"include_usage": false
},
"parallel_tool_calls": false
}Schema
{
"application/json": {
"schema": {
"type": "object",
"properties": {
"model": {
"type": "string",
"minLength": 1,
"maxLength": 200,
"description": "Model name; supports vendor-prefix (\"anthropic/claude-3-5-sonnet\") + bare aliases (\"gpt-4o\")."
},
"messages": {
"minItems": 1,
"maxItems": 500,
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string",
"enum": [
"system",
"user",
"assistant",
"tool",
"developer"
]
},
"content": {
"nullable": true,
"anyOf": [
{
"type": "string",
"maxLength": 1000000
},
{
"maxItems": 50,
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"text"
]
},
"text": {
"type": "string",
"maxLength": 1000000
}
},
"required": [
"type",
"text"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"image_url"
]
},
"image_url": {
"type": "object",
"properties": {
"url": {
"type": "string",
"maxLength": 50000
},
"detail": {
"type": "string",
"enum": [
"auto",
"low",
"high"
]
}
},
"required": [
"url"
],
"additionalProperties": false
}
},
"required": [
"type",
"image_url"
],
"additionalProperties": false
}
]
}
}
]
},
"name": {
"type": "string",
"maxLength": 120
},
"tool_call_id": {
"type": "string",
"maxLength": 200
},
"tool_calls": {
"maxItems": 50,
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"maxLength": 200
},
"type": {
"type": "string",
"enum": [
"function"
]
},
"function": {
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 120
},
"arguments": {
"type": "string",
"maxLength": 100000
}
},
"required": [
"name",
"arguments"
],
"additionalProperties": false
}
},
"required": [
"id",
"type",
"function"
],
"additionalProperties": false
}
},
"metadata": {
"type": "object",
"properties": {
"cache_control": {
"anyOf": [
{
"type": "string",
"enum": [
"ephemeral"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"ephemeral"
]
}
},
"required": [
"type"
],
"additionalProperties": false
}
]
}
},
"additionalProperties": {}
}
},
"required": [
"role",
"content"
],
"additionalProperties": false
}
},
"evalguard": {
"type": "object",
"properties": {
"dicl": {
"type": "object",
"properties": {
"examples": {
"maxItems": 20,
"type": "array",
"items": {
"type": "object",
"properties": {
"input": {
"type": "string",
"maxLength": 50000
},
"output": {
"type": "string",
"maxLength": 50000
}
},
"required": [
"input",
"output"
],
"additionalProperties": false
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false,
"description": "EvalGuard vendor extensions."
},
"temperature": {
"type": "number",
"minimum": 0,
"maximum": 2
},
"top_p": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"n": {
"type": "integer",
"minimum": 1,
"maximum": 8
},
"stream": {
"type": "boolean"
},
"stop": {
"anyOf": [
{
"type": "string",
"maxLength": 200
},
{
"maxItems": 8,
"type": "array",
"items": {
"type": "string",
"maxLength": 200
}
}
]
},
"max_tokens": {
"type": "integer",
"minimum": 1,
"maximum": 1000000
},
"max_completion_tokens": {
"type": "integer",
"minimum": 1,
"maximum": 1000000
},
"presence_penalty": {
"type": "number",
"minimum": -2,
"maximum": 2
},
"frequency_penalty": {
"type": "number",
"minimum": -2,
"maximum": 2
},
"seed": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"service_tier": {
"type": "string",
"enum": [
"auto",
"default",
"flex",
"priority",
"scale",
"standard_only"
]
},
"user": {
"type": "string",
"maxLength": 200
},
"tools": {
"maxItems": 128,
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"function"
]
},
"function": {
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 120
},
"description": {
"type": "string",
"maxLength": 2000
},
"parameters": {
"type": "object",
"additionalProperties": {}
}
},
"required": [
"name"
],
"additionalProperties": false
}
},
"required": [
"type",
"function"
],
"additionalProperties": false
}
},
"tool_choice": {
"anyOf": [
{
"type": "string",
"enum": [
"auto",
"none",
"required"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"function"
]
},
"function": {
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 120
}
},
"required": [
"name"
],
"additionalProperties": false
}
},
"required": [
"type",
"function"
],
"additionalProperties": false
}
]
},
"response_format": {
"anyOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"text",
"json_object"
]
}
},
"required": [
"type"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"json_schema"
]
},
"json_schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 120
},
"schema": {
"type": "object",
"additionalProperties": {}
},
"strict": {
"type": "boolean"
}
},
"required": [
"name",
"schema"
],
"additionalProperties": false
}
},
"required": [
"type",
"json_schema"
],
"additionalProperties": false
}
]
},
"stream_options": {
"type": "object",
"properties": {
"include_usage": {
"type": "boolean"
}
},
"additionalProperties": false
},
"parallel_tool_calls": {
"type": "boolean"
}
},
"required": [
"model",
"messages"
],
"additionalProperties": false
}
}
}Response
All status codes
200OpenAI-shape chat completion response (or text/event-stream when stream=true).
400(no description)
401(no description)
422Unknown model or no provider API key configured.
429(no description)
502Upstream provider error.
Code samples
cURL
curl -X POST \
https://evalguard.ai/api/v1/chat/completions \
-H "Authorization: Bearer $EVALGUARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "<Model name; supports vendor-prefix (\"ant>", "messages": [ { "role": "system", "name": "string", "tool_call_id": "string", "tool_calls": [ { "id": "string", "type": "function", "function": { "name": "string", "arguments": "string" } } ], "metadata": {} } ], "evalguard": { "dicl": { "examples": [ { "input": "string", "output": "string" } ] } }, "temperature": 0, "top_p": 0, "n": 1, "stream": false, "max_tokens": 1, "max_completion_tokens": 1, "presence_penalty": -2, "frequency_penalty": -2, "seed": -9007199254740991, "service_tier": "auto", "user": "string", "tools": [ { "type": "function", "function": { "name": "string", "description": "string", "parameters": {} } } ], "stream_options": { "include_usage": false }, "parallel_tool_calls": false }'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/chat/completions",
body: {
"model": "<Model name; supports vendor-prefix (\"ant>",
"messages": [
{
"role": "system",
"name": "string",
"tool_call_id": "string",
"tool_calls": [
{
"id": "string",
"type": "function",
"function": {
"name": "string",
"arguments": "string"
}
}
],
"metadata": {}
}
],
"evalguard": {
"dicl": {
"examples": [
{
"input": "string",
"output": "string"
}
]
}
},
"temperature": 0,
"top_p": 0,
"n": 1,
"stream": false,
"max_tokens": 1,
"max_completion_tokens": 1,
"presence_penalty": -2,
"frequency_penalty": -2,
"seed": -9007199254740991,
"service_tier": "auto",
"user": "string",
"tools": [
{
"type": "function",
"function": {
"name": "string",
"description": "string",
"parameters": {}
}
}
],
"stream_options": {
"include_usage": false
},
"parallel_tool_calls": false
},
});
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/chat/completions",
body={
"model": "<Model name; supports vendor-prefix (\"ant>",
"messages": [
{
"role": "system",
"name": "string",
"tool_call_id": "string",
"tool_calls": [
{
"id": "string",
"type": "function",
"function": {
"name": "string",
"arguments": "string"
}
}
],
"metadata": {}
}
],
"evalguard": {
"dicl": {
"examples": [
{
"input": "string",
"output": "string"
}
]
}
},
"temperature": 0,
"top_p": 0,
"n": 1,
"stream": False,
"max_tokens": 1,
"max_completion_tokens": 1,
"presence_penalty": -2,
"frequency_penalty": -2,
"seed": -9007199254740991,
"service_tier": "auto",
"user": "string",
"tools": [
{
"type": "function",
"function": {
"name": "string",
"description": "string",
"parameters": {}
}
}
],
"stream_options": {
"include_usage": False
},
"parallel_tool_calls": False
},
)
print(response)Go
package main
import (
"context"
"fmt"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{"model":"<Model name; supports vendor-prefix (\"ant>","messages":[{"role":"system","name":"string","tool_call_id":"string","tool_calls":[{"id":"string","type":"function","function":{"name":"string","arguments":"string"}}],"metadata":{}}],"evalguard":{"dicl":{"examples":[{"input":"string","output":"string"}]}},"temperature":0,"top_p":0,"n":1,"stream":false,"max_tokens":1,"max_completion_tokens":1,"presence_penalty":-2,"frequency_penalty":-2,"seed":-9007199254740991,"service_tier":"auto","user":"string","tools":[{"type":"function","function":{"name":"string","description":"string","parameters":{}}}],"stream_options":{"include_usage":false},"parallel_tool_calls":false}`)
req, _ := http.NewRequestWithContext(context.Background(), "POST", "https://evalguard.ai/api/v1/chat/completions", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("EVALGUARD_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
fmt.Println(resp.Status)
}Errors
400401422429502