Endpoints
Authentication
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 theAuthorization header to Basic <base64(publicKey:secretKey)> where publicKey and secretKey are your Trident credentials.
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 tohttps://api.openai.com/v1/chat/completions.
What happens on each request
1
Firewall pre-scan
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.
Example: OpenAI SDK with base URL override
POST /api/public/gateway/anthropic/v1/messages
A drop-in replacement for the Anthropic Messages API. The request and response shapes are identical tohttps://api.anthropic.com/v1/messages. The same firewall scan, post-scan, and spend tracking apply.
Example: Anthropic SDK with base URL override
Error responses
When the firewall pre-scan blocks a prompt, the gateway returns HTTP 451 with the following body:Prerequisites
Before you can use the gateway, configure your provider API keys in the Trident dashboard:1
Open Project Settings
Navigate to app.usetrident.dev → your project → Project Settings.
2
Go to Gateway
Select the Gateway tab.
3
Enter your provider API key
Paste your OpenAI or Anthropic API key. Trident encrypts it immediately — the raw key is never stored in plaintext.
4
Optionally set a monthly budget
Set a
Monthly budget (USD) to cap spend. Requests that would exceed the budget are rejected before forwarding.