Gateway API Reference
The data plane for your AI Agents. Use these endpoints to generate text, embeddings, and images via the TrustGate proxy.
https://api.trustgate.ai/v1
Headers
AuthorizationRequiredBearer token with your Agent Key (tg_sk_...).
X-Agent-Trace-IdOptionalA unique string (e.g., a session or workflow ID) used to group multiple multi-step autonomous agent requests into a single unified trace for observability.
X-Agent-PolicyOptionalThe ID of the policy to enforce on this request. Use this to apply specific rules like Agentic Retry Blocking or Cost Caps on a per-request basis.
POST
/chat/completionsCreate Chat Completion
The universal endpoint for text generation. Compatible with OpenAI, Anthropic, Gemini, Mistral, and Groq.
Parameters
model
string • Required
The ID of the model to use (e.g., 'gpt-4', 'claude-3-opus').
messages
array • Required
A list of messages comprising the conversation so far.
stream
boolean • Optional
If set, partial message deltas will be sent.
x-trustgate-trace-id
header • Optional
Custom UUID to link this request to a larger agent workflow.
cURL Request
curl https://api.trustgate.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer tg_sk_..." \
-H "x-trustgate-trace-id: trace_882a" \
-d '{
"model": "claude-3-opus",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'POST
/embeddingsGenerate Embeddings
Creates an embedding vector representing the input text.
Parameters
model
string • Required
ID of the model (e.g., 'text-embedding-3-small').
input
string • Required
Input text to embed.
cURL Request
curl https://api.trustgate.ai/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer tg_sk_..." \
-d '{
"model": "text-embedding-3-small",
"input": "TrustGate protects AI."
}'Error Codes
401
Unauthorized
Invalid Agent Key.
403
Policy Blocked
Model not allowed or PII blocked.
429
Budget Exceeded
Daily spending limit reached.