Skip to main content

LLM Gateway

Turn on governance for your LLM calls in 5 minutes. Works with OpenAI, Anthropic, Google Gemini, Groq, Mistral, Cohere, and 54 more providers out of the box.

Quickstart

1. Get an Igris API key

Sign up at app.igrisecurity.com/signup, then create a new API key under Settings → API Keys. Your key starts with ig_.

2. Create a connection for your LLM provider

Connections are encrypted credential vaults. They bind your upstream provider API key to an Igris slug you can reference from code without ever exposing the real key.
  1. Go to Govern → Connections in the dashboard
  2. Click New Connection
  3. Select type LLM
  4. Pick your provider — e.g. OpenAI
  5. Paste your provider API key
  6. Optionally restrict to specific models (e.g. gpt-4o, gpt-4o-mini, or a glob such as gpt-4*). A request for any other model is denied with 403 (Model X not allowed for this connection)
  7. Save and note the slug (e.g. openai-prod)

3. Make your first call

The model field uses @slug/model syntax. Igris resolves the slug, injects credentials, enforces policies, and logs everything — before forwarding to the upstream provider.

4. See it in the audit trail

Back in the dashboard, open Monitor → Audit Trail and filter by type LLM. You’ll see your call with:
  • Provider + model used
  • Input and output token counts
  • Cost in USD (calculated server-side)
  • End-to-end latency
  • User identity passed via user field
  • Policy action (allowed / denied / alerted / redacted)
Head to Dashboards → LLM Cost for spend breakdowns over time.

Streaming

Pass stream: true to get an AsyncIterable of SSE chunks. The gateway uses minimal SSE-parse buffering to extract usage data — no extra round-trips are added.
Token usage is extracted from the final SSE chunk (or the terminal usage field for providers that support it) and recorded in the audit trail even for streaming responses.

Passing metadata for policy conditions

The user field and arbitrary metadata can be passed via extra request headers. The SDK’s connectLlm() method is the cleanest way to attach per-request context:

Native SDKs (OpenAI, Anthropic)

You can also point the vendor SDKs at the gateway directly. Use your Igris key as the credential. The Anthropic SDK sends its key as x-api-key, but the gateway reads only Authorization: Bearer <igris key>, so configure the SDK with authToken instead of apiKey. The SDK adapters (@igris-security/sdk/adapters/openai and .../anthropic) do this for you. Native Anthropic calls to /v1/messages go through in passthrough mode, so the request body is not rewritten.

Endpoint and protocol

The gateway is OpenAI-compatible. All requests target:
Chat completions and embeddings are translated for providers that support them (others return 501). Any other path is forwarded as-is. For example, a chat completions call via raw HTTP:

Concepts

Connections

A connection is an encrypted credential vault that maps an Igris slug to an upstream provider API key. Your application code never holds the real provider key — it only knows the slug (e.g. openai-prod). The gateway resolves the slug at request time, injects the real credential, and forwards to the upstream provider. Connections can be scoped to a specific organization, restricted to a subset of models, enabled or disabled without a code change, and rotated by updating the vault entry in the dashboard. A single slug can be reused across as many callers as you like — policy rules target the slug. See Connections for CRUD operations via the API.

Providers

A provider is a registered upstream LLM service — OpenAI, Anthropic, Groq, Mistral, and 56 more — 60 in total. Each provider registration captures:
  • Slug — the identifier used in connection creation and model routing (e.g. openai, anthropic)
  • Base URL — where the gateway forwards requests
  • Auth style — bearer, x-api-key, or query-param
  • Supported endpoints — which of chat.completions, embeddings, images.generate, audio.transcriptions, audio.speech, or passthrough this provider supports
Providers with baseUrl: null (Ollama, HuggingFace, Triton, Modal, openai-compatible) require a customBaseUrl to be set on the connection for self-hosted deployments. The URL must be reachable from Igris: localhost and private-network addresses are blocked (see Upstream URL safety). See the full Provider Catalog.

Policies

A policy is an ordered list of PolicyRule objects attached to one or more connections (connectionSlugs) or, when connectionSlugs is null, to the whole organization. Rules are evaluated in order — first match wins. Each rule has four main parts:

Target

What the rule matches. Three discriminated union variants:

Action

What happens when the rule matches: "allow", "deny", "alert" or "redact". Deny returns HTTP 403. Alert records an alert event without blocking the request. Redact masks matching content in the request before it is forwarded.

Conditions

Optional metadata conditions that must also match for the rule to fire. The only supported keys are user (from X-Igris-User) and metadata.<key>. Operators: eq, neq, in, nin, or a bare string for equality. Metadata keys are lowercase, because the gateway lowercases X-Igris-Metadata-<Key> header names. Write the condition as metadata.role, not metadata.Role.

Limits, Guards, and Content Controls

Rules can also carry:
  • limit — rate limit: { requests?, tokens?, dollars?, per: "minute" | "hour" | "day" }. Going over returns 429. Rate limits apply to LLM rules only.
  • tokenGuard — { maxInputTokens?, maxRequestMaxTokens? }. Denies requests whose estimated input, or whose max_tokens, exceeds the value.
  • contentGuard — { detectors: string[], action: "deny" | "redact" | "alert", inspectResponse?: boolean }. Runs detectors (PII, secrets, prompt injection, custom detectors) over the prompt and optionally the response.
  • logContent — whether to persist the full prompt and completion for requests that match the rule
What a content guard does when a detector matches: The guard action applies to rules whose own action is allow or alert. A rule whose action is deny always denies. With inspectResponse on, a redact guard also masks the response. Response hits that can’t be masked are logged as a response-violation alert and fire the webhook. New guards default to deny in the policy editor. See Guards for details. The “Policy Denials” webhook fires for policy-rule hits and content-guard hits. It does not fire for rate-limit, budget, model-allowlist or no-match denials.

Audit Trail

Every request through the gateway produces an audit event with:
  • type: "llm_call"
  • provider and model (resolved after gateway routing)
  • tokensIn, tokensOut, cachedInputTokens
  • costCents (a float, see below)
  • latencyMs
  • userId, traceId, connectionSlug
  • llmEndpoint and requestMode (transformed or passthrough)
  • policyAction, policyId and deniedBy (when the request was denied)
  • requestMetadata (the metadata you sent)
Query audit events from the SDK with igris.auditEvents.list() or browse them in the dashboard under Monitor → Audit Trail (filter by type LLM).

Body logging

By default Igris stores no prompt or completion text. There are two ways to turn it on:
  • Per connection: set logFullContent: true on the connection. bodyRetentionDays sets how long bodies are kept. It defaults to your plan’s retention and cannot exceed it.
  • Per rule: set logContent: true on a policy rule.
Stored bodies are linked to the audit event by its ID.

Cost Tracking

Cost is computed server-side from a pricing snapshot. costCents is a floating-point number of US cents, not an integer. 1.5 means $0.015, and `0.0073` means $0.000073. The Dashboards → LLM Cost page aggregates spend by day, provider, model, connection, and user.

Anomaly Detection

The gateway tracks five signals per user (or per connection when requests carry no user): These are the global defaults for every connection. Self-hosted deployments can override them by setting the LLM_ANOMALY_DEFAULTS_OVERRIDE environment variable to a JSON object with the keys costSpike, tokenBurn, responseLength, modelShift and errorRate. Any field you leave out keeps its default. The anomalyConfig field on a connection is stored but not applied yet. When a signal fires, Igris emits a live event and writes an anomaly audit event. Anomalies never block requests. To stop runaway spend, use a rule limit or tokenGuard.

Limits and defaults

  • Default max_tokens: if a chat request sets neither max_tokens nor max_completion_tokens, the gateway adds max_tokens: 4096. Self-hosted deployments can change this with LLM_GATEWAY_DEFAULT_MAX_TOKENS.
  • Daily spend cap: a deployment can set LLM_GATEWAY_DEFAULT_DAILY_SPEND_LIMIT_CENTS (for example 1000 for $10 per day). It applies only to requests whose matched rules set no dollars limit. It is off unless set.
  • Rate limit: 1000 requests per minute per API key.
  • Body size: 2 MB.
  • Disabled gateway: a deployment with LLM_GATEWAY_ENABLED=false returns 404 on /llm/*.
See Limits and errors for the full list.

Errors

Gateway errors look like {"error": {"message": "...", "type": "igris_error", "code": "403"}}. Errors from the upstream provider (4xx and 5xx) are passed through. The SDK raises typed errors: IgrisAuthError (401), IgrisPolicyDeniedError (403 policy denial) and IgrisRateLimitError (429).

Three Usage Styles

Use igris.chat.completions.create() directly. The @slug/model model prefix tells the SDK which connection to route through. Zero external dependencies beyond the Igris SDK.

2. connectLlm escape hatch

Use igris.connectLlm(slug, options) to get a { baseUrl, apiKey, headers } object and wire it into any OpenAI-compatible SDK client. The withIgris adapters do this wiring for you. This is the zero-migration path when your app already uses the OpenAI Node SDK. There is a matching adapter for the Anthropic SDK at @igris-security/sdk/adapters/anthropic.

3. Raw HTTP

Any HTTP client that can set Authorization: Bearer <igris_key> and target https://api.igrisecurity.com/llm/<slug>/v1/chat/completions works directly. This is useful for language runtimes without an Igris SDK (Python, Go, Rust, etc.).

Request Modes: Passthrough vs Transformed

The gateway picks the mode from the request path, not from a flag you set.
  • Transformed mode applies to /v1/chat/completions and /v1/embeddings. The gateway rewrites the request and response to match the OpenAI schema, whatever the upstream expects. You can switch providers without changing your application code.
  • Passthrough mode applies to every other path. The gateway forwards the sub-path and body to the provider’s base URL as-is, with the connection’s credential injected. Use it for image generation, audio, native Anthropic /v1/messages calls, and other provider-specific APIs. If the provider’s base URL already ends in /v1, a leading /v1 in your path is dropped so it isn’t doubled. Passthrough always sends a POST with a JSON body and does not forward query strings. Providers whose base URL ends in /v1/openai, /v1/solar or /api/paas/v4 can still produce doubled paths.

Metadata Channels

Request context (user identity, trace IDs, metadata for policy conditions) is read from these sources: The JSON blob is ignored entirely if it is over 4096 characters, nested more than 3 levels, not a JSON object, or has any key containing a dot. connectLlm() sets X-Igris-Trace-Id, X-Igris-User and one X-Igris-Metadata-<key> header per metadata entry. It sends only string values. Non-string metadata is dropped. It doesn’t use the JSON blob or set body.user.

What’s next?

Providers

All 60 supported providers with slugs, base URLs, and auth styles.

Connections

Create and manage encrypted credential vaults for upstream providers.