# SecondGate · API Routing

> SecondGate, the SecondStack LLM gateway — virtual API keys, model access control, SecondGuard guardrails, budgets, and spend observability.

Canonical: <https://docs.secondstack.ai/features/api-routing/>
Updated: 2026-07-07

---

**SecondGate** is the LLM API gateway of SecondStack — it centralizes every LLM request in your organization. Instead of scattered provider keys with no visibility or controls, chat users, internal apps, agents, and IDE plugins all call a single endpoint that handles authentication, routing, guardrails, budgets, and observability.

<p class="ss-mock-caption">Clients authenticate with virtual keys; the gateway routes to upstream providers with policy applied.</p>

## Virtual API keys

Users and applications authenticate with **virtual API keys** rather than raw provider keys. Each key carries its own budget and policy, and users can self-serve keys for their apps, agents, and IDE tools in the [User Dashboard](/features/user-dashboard/). Provider credentials stay held by the platform.

## OpenAI-compatible endpoints

Applications call standard, OpenAI- and Anthropic-compatible endpoints — for example `/v1/chat/completions`, `/v1/messages`, and `/responses` — with a virtual key. The gateway handles routing, failover, and load balancing across the models it fronts, so client code stays simple.

## Access control

Model access is governed centrally. Access is **default-deny** and additive, granted by **team, group, user, or team API key**, and applied separately to two channels — **SecondChat** and **direct API traffic** — so you can allow a model in chat while restricting it for programmatic use, or vice versa. See [ControlTower](/features/controltower/) for the management UI.

## Guardrails, budgets, and observability

Every request can pass through the platform's guardrails and controls:

- **Guardrails** — the SecondGuard service inspects inbound prompts and outbound responses for PII, secrets, and other policy-sensitive content, on the request path.
- **Budgets** — per-user, per-team, and per-key limits are enforced here at request time. See [Cost Management](/features/cost-management/).
- **Observability** — detailed usage is captured for analytics, and client request tags help attribute background traffic.

## Minimal exposed surface

Only the inference endpoints are exposed externally through the OpenResty gateway; the gateway's full management API is not reachable from outside. This keeps the public surface small.

## Supported providers

The gateway can route to Anthropic, OpenAI, Azure, Google (AI Studio and Vertex), Amazon Bedrock, Databricks, xAI, OpenRouter, and self-hosted open-weight models via vLLM.

:::note
Client request tags are for observability and attribution — they are not an authorization boundary. Use access control for permissions.
:::

## Related

- [ControlTower](/features/controltower/) — configure providers, models, and access.
- [Cost Management](/features/cost-management/) — budgets enforced at the gateway.
- [User Dashboard](/features/user-dashboard/) — self-service virtual keys.
