API reference

Endpoints & examples

Every endpoint goes through the same detection, policy, guardrails and audit.

MethodPathWhat it does
POST/v1/chat/completionsChat, tools and vision (OpenAI format). Streaming supported.
POST/v1/responsesOpenAI Responses API.
POST/v1/messagesAnthropic Messages API. Streaming supported.
POST/v1/messages/count_tokensAnthropic token counting.
POST/v1/completionsLegacy text completions.
POST/v1/embeddingsVectors for search and RAG.
POST/v1/rerankRe-order documents by relevance to a query.
POST/v1/images/generationsImage generation.
POST/v1/audio/speechText to speech.
POST/v1/videosStart a video job; poll GET /v1/videos/{id}, download /content.
POST/v1/moderationsContent moderation.
GET/v1/modelsOnly the models this key may use.
POST/v1/inspectCheck text before it goes to an AI website. No model is called.
Not served (HTTP 501, not_governed)
Their content can't be inspected before it leaves your network: /v1/audio/transcriptions, /v1/audio/translations, /v1/batches, /v1/files, /v1/images/edits, /v1/images/variations.

Examples

Replace <your API key> with your key and the model names with ones your key may use.

Chat

Terminal
curl https://gateway.agentkeyroute.com/v1/chat/completions \
  -H "Authorization: Bearer <your API key>" \
  -H "Content-Type: application/json" \
  -H "X-AIGov-User: alice@example.com" \
  -d '{"model":"gpt-4.1","messages":[{"role":"user","content":"Hello"}]}'

Streaming

Terminal
curl -N https://gateway.agentkeyroute.com/v1/chat/completions \
  -H "Authorization: Bearer <your API key>" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4.1","stream":true,"messages":[{"role":"user","content":"Write a haiku"}]}'

Tools

Terminal
curl https://gateway.agentkeyroute.com/v1/chat/completions \
  -H "Authorization: Bearer <your API key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4.1",
    "messages": [{"role": "user", "content": "Weather in Paris?"}],
    "tools": [{"type": "function", "function": {
      "name": "get_weather",
      "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}
    }}]
  }'

Responses

Terminal
curl https://gateway.agentkeyroute.com/v1/responses \
  -H "Authorization: Bearer <your API key>" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4.1","input":"Hello"}'

Messages

Terminal
curl https://gateway.agentkeyroute.com/v1/messages \
  -H "x-api-key: <your API key>" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-sonnet","max_tokens":512,"messages":[{"role":"user","content":"Hello"}]}'

Embeddings

Terminal
curl https://gateway.agentkeyroute.com/v1/embeddings \
  -H "Authorization: Bearer <your API key>" \
  -H "Content-Type: application/json" \
  -d '{"model":"text-embedding-3-small","input":["first passage","second passage"]}'

Rerank

Terminal
curl https://gateway.agentkeyroute.com/v1/rerank \
  -H "Authorization: Bearer <your API key>" \
  -H "Content-Type: application/json" \
  -d '{"model":"rerank-v3.5","query":"refund policy","documents":["Refunds within 30 days","Shipping takes 3 days"]}'

Images

Terminal
curl https://gateway.agentkeyroute.com/v1/images/generations \
  -H "Authorization: Bearer <your API key>" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-image-1","prompt":"A lighthouse at dusk","size":"1024x1024"}'

Models

Terminal
curl https://gateway.agentkeyroute.com/v1/models -H "Authorization: Bearer <your API key>"

Inspect

Terminal
curl https://gateway.agentkeyroute.com/v1/inspect \
  -H "Authorization: Bearer <your API key>" \
  -H "Content-Type: application/json" \
  -d '{"destination":"chatgpt.com","user":"alice@example.com","text":"Summarise this note for John Smith"}'

# → {"action":"allow|redact|block","classes":[...],"findings":[...],"redacted":"...","reason":"...","request_id":"..."}