Docs / API / Gateway

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

  • AuthorizationRequired

    Bearer token with your Agent Key (tg_sk_...).

  • X-Agent-Trace-IdOptional

    A 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-PolicyOptional

    The 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/completions

Create Chat Completion

The universal endpoint for text generation. Compatible with OpenAI, Anthropic, Gemini, Mistral, and Groq.

Parameters

model
stringRequired
The ID of the model to use (e.g., 'gpt-4', 'claude-3-opus').
messages
arrayRequired
A list of messages comprising the conversation so far.
stream
booleanOptional
If set, partial message deltas will be sent.
x-trustgate-trace-id
headerOptional
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/embeddings

Generate Embeddings

Creates an embedding vector representing the input text.

Parameters

model
stringRequired
ID of the model (e.g., 'text-embedding-3-small').
input
stringRequired
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.