API / V1

Four fixed request formats. One usage record.

Tollgate accepts JSON POST requests on the paths below. Streaming and every unlisted endpoint are rejected.

01 / Endpoints

Supported provider routes.

ProviderPathRequest format
OpenAI/p/{projectId}/providers/openai/v1/chat/completionsChat Completions, non-streaming only
OpenRouter/p/{projectId}/providers/openrouter/api/v1/chat/completionsChat Completions, non-streaming only
Anthropic/p/{projectId}/providers/anthropic/v1/messagesMessages, non-streaming only
Gemini/p/{projectId}/providers/gemini/v1beta/models/{model}:generateContentGenerateContent, non-streaming only

02 / Headers

Required request identity.

HeaderRequiredMeaning
X-Tollgate-KeyYesMatching test or live write key.
X-Tollgate-Idempotency-KeyYesStable safe ID for retries of one exact request. Reusing it with changed content or settings returns a conflict.
X-Tollgate-CustomerRecommendedExternal customer ID using 1–80 letters, numbers, dots, underscores, colons, or dashes. A missing header becomes unattributed.
Authorization / provider keyYesOpenAI/OpenRouter use Authorization, Anthropic uses x-api-key, and Gemini uses x-goog-api-key.
X-Tollgate-Task-IdNoSafe trace ID using letters, numbers, dot, underscore, colon, or dash.

03 / Response

Provider body, Tollgate evidence.

Pass-through

Provider responses up to 4 MiB return to the caller. Larger responses are rejected safely. Tollgate adds response headers such as x-tollgate-provider, x-tollgate-cost-status, and x-tollgate-call-id.

Cost states

reported comes from the provider, estimated comes from a verified built-in price or exact rate card, and unavailable is never changed to zero.

04 / Errors

Rejected before spend where possible.

StatusCondition
400Invalid JSON, unsafe IDs, missing retry ID, streaming, or invalid model ID.
401Missing, invalid, or rotated Tollgate write key; missing provider credential.
404Unknown project, provider, or unsupported provider endpoint.
409Duplicate retry ID or the same retry ID used for a different request.
502The selected provider could not be reached.