Tera Router

Gateway API

Base URL, authentication, and dialect compatibility for all inference endpoints.

Endpoints

The gateway serves three API dialects at once, all under /v1:

EndpointDialectUsed by
POST /v1/chat/completionsOpenAI ChatOpenAI SDK, most tools and frameworks
POST /v1/messagesAnthropic MessagesAnthropic SDK, Claude Code
POST /v1/messages/count_tokensAnthropicToken estimation (computed locally)
POST /v1/responsesOpenAI ResponsesResponses API clients
POST /responsesOpenAI ResponsesRoot-level alias, for clients like Codex

Request bodies are exactly the original formats — no required custom fields. The router only cares how you write model (see Models & routing).

Authentication

Use an API key prefixed with sk_tr_ created from the dashboard (or POST /v1/keys):

# option 1 — Authorization header
curl http://localhost:8080/v1/chat/completions \
  -H "Authorization: Bearer sk_tr_..."

# option 2 — x-api-key (Anthropic style)
curl http://localhost:8080/v1/messages \
  -H "x-api-key: sk_tr_..."

A wrong, disabled, or missing key gets a 401 in the OpenAI error envelope:

{
  "error": {
    "message": "invalid api key",
    "type": "authentication_error"
  }
}

Response headers

Every response (unary and streaming) carries headers that tell you who ultimately served the request:

X-TeraRouter-Provider: anthropic
X-TeraRouter-Model: claude-sonnet-4

Useful for verifying that chains/aliases/fallbacks landed on the target you expected.

Gateway vs dashboard API

Both live on the same port, but their auth differs:

Gateway (/v1/chat/...)Dashboard API (/v1/keys, /v1/usage, ...)
CredentialsAPI key sk_tr_JWT from POST /v1/auth/sign-in
Used byApps and coding agentsDashboard UI and admin scripts
ReferenceGateway APIAPI Reference

Don't mix them up

A dashboard JWT cannot be used on the gateway, and an sk_tr_ API key cannot be used on the dashboard API.

On this page