LLM Gateway API: OpenAI and Anthropic Proxy Endpoints
Trident’s gateway endpoints are drop-in replacements for OpenAI and Anthropic, routing all LLM calls through the runtime firewall with full tracing.
The Trident LLM Gateway sits between your application code and the upstream model providers. Every request is pre-scanned by the runtime firewall, every response is post-scanned for canary leakage, and token spend is tracked against your project’s monthly budget — all without changing the shape of your existing OpenAI or Anthropic API calls.To adopt the gateway, change your SDK’s base URL to the corresponding Trident endpoint. No other code changes are required.
The gateway uses your Trident project credentials (the same HTTP Basic auth used by all other Trident endpoints). Your OpenAI or Anthropic API keys are stored encrypted on your Trident project and are never passed from your application — you configure them once in the dashboard under Project Settings → Gateway.Set the Authorization header to Basic <base64(publicKey:secretKey)> where publicKey and secretKey are your Trident credentials.
Do not put your OpenAI or Anthropic key in the Authorization header when
calling the Trident gateway. That header is for your Trident credentials.
Your provider API keys live in Project Settings → Gateway and are injected
server-side.
POST /api/public/gateway/openai/v1/chat/completions
A drop-in replacement for the OpenAI Chat Completions API. The request and response shapes are identical to https://api.openai.com/v1/chat/completions.
Trident extracts the last user message and scans it with the runtime
firewall. If the prompt is blocked, the gateway returns HTTP 451
immediately — no request is forwarded to OpenAI.
2
Upstream forwarding
Trident forwards your full request body to OpenAI using your stored,
encrypted API key.
3
Firewall post-scan
The assistant’s response is scanned for canary token leakage (best-effort,
non-blocking).
4
Spend tracking
Token usage is priced and accumulated against your project’s monthly
budget. When the budget is exhausted, subsequent requests return HTTP 402.
A drop-in replacement for the Anthropic Messages API. The request and response shapes are identical to https://api.anthropic.com/v1/messages. The same firewall scan, post-scan, and spend tracking apply.
import anthropicimport base64import ospub = os.environ["TRIDENT_PROJECT_PUBLIC_KEY"]sec = os.environ["TRIDENT_PROJECT_SECRET_KEY"]token = base64.b64encode(f"{pub}:{sec}".encode()).decode()client = anthropic.Anthropic( # The Anthropic SDK sends x-api-key; override the base URL so # requests go through Trident. Auth is handled via the # default_headers override below. base_url="https://app.usetrident.dev/api/public/gateway/anthropic", api_key="placeholder", # replaced by default_headers default_headers={"Authorization": f"Basic {token}"},)message = client.messages.create( model="claude-opus-4-5", max_tokens=1024, messages=[{"role": "user", "content": "What are the key risks in our deployment pipeline?"}],)print(message.content[0].text)