AI Gateway
Evigauge AI Gateway
On this page
Run your AI through Evigauge by changing one line — the base_url of your
existing OpenAI-compatible client. Every call is forwarded to your own model
provider (BYOK), and Evigauge captures it and runs its reconstruction engines
(decomposition, decision graph, provenance, reliability) on your behalf. No SDK,
no span code, any language.
Companion documents: SDK Reference · REST API Reference · MCP & Claude Code Plugin
The Gateway is an alternative to the SDK. The SDK instruments your app in code; the Gateway requires no code beyond pointing your client at it. Both land in the same place and produce the same analysis — pick whichever fits.
Quickstart
1. Connect your model provider (one time, per workspace). In the dashboard, open Settings → Gateway providers and add your provider key — or via the API:
curl -X PUT \
https://api.evigauge.ai/v1/observ/orgs/<org>/workspaces/<ws>/gateway/providers \
-H "Authorization: Bearer <dashboard-session>" \
-H "Content-Type: application/json" \
-d '{"provider":"openai","model_pattern":"","api_key":"sk-your-openai-key"}'
2. Point your client at the Gateway and authenticate with your Evigauge
workspace key (evg_live_…):
from openai import OpenAI
client = OpenAI(
base_url="https://gateway.evigauge.ai/v1",
api_key="evg_live_xxxxxxxxxxxx", # your Evigauge workspace key, NOT your OpenAI key
)
resp = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Summarize the Q3 report."}],
)
print(resp.choices[0].message.content)
That's the whole integration. The call runs on your provider key; Evigauge observes it in flight.
How it works
┌──────────┐ ┌──────────────────┐ ┌───────────────┐
│ your app │ ──▶ │ Evigauge Gateway │ ──▶ │ your provider │
└──────────┘ └────────┬─────────┘ └───────────────┘
│
│ after your response,
│ off your response path
▼
capture ──▶ engines
The lifecycle of one call
- Authenticate. The Gateway reads your
evg_key — fromAuthorization: Beareron the OpenAI paths, orx-api-key/x-goog-api-keyon the native Anthropic/Gemini paths — and resolves the org, workspace and project it belongs to. A missing or invalid key is a401and nothing is forwarded. - Resolve a provider credential for the
modelin the request body (see Which credential gets used below). No credential and nox-provider-keyis a412— the one case the Gateway fails closed, because there is no key to forward with. - Forward byte-for-byte. The request body is passed to the provider
unchanged:
tools,tool_choice,response_format,seed,logprobs,temperature,stop, streaming, and any field the Gateway has never heard of. The Gateway does not add, remove, reorder or rewrite fields. - Return unchanged. The provider's status, headers and body are returned to you as they came back. A provider error is returned as that provider's error, so you debug against the real API rather than against us.
- Capture, after the fact. Once your response is delivered, the Gateway records the call and queues it for your enabled engines. This happens off your response path. If any of it fails, you have already been served.
What "forwarded byte-for-byte" rules out
The Gateway is not a router, a cache or an optimiser. It does not:
- substitute a cheaper model, retry on a different provider, or fail over;
- inject, strip or rewrite a system prompt;
- cache responses or deduplicate identical requests;
- re-order or batch your calls;
- add tokens to the prompt it forwards.
Your bill from the provider is exactly what your request would have cost calling them directly, because it is that request.
Which credential gets used
Credentials are matched against the model string in the request body:
Stored model_pattern | Matches |
|---|---|
"" (empty, the default) | every model for that provider |
gpt-4o | that exact model id |
a prefix, e.g. gpt-4 | every model id beginning with it |
A more specific pattern wins over a less specific one, so a key pinned to
gpt-4o is used for gpt-4o even when a catch-all key for the same provider
also exists. An x-provider-key header beats everything stored: send one and no
lookup happens at all.
Authentication
You don't build a bearer header yourself. Just set your Evigauge workspace
key (evg_live_…) as the api_key on your OpenAI-compatible client — every
OpenAI SDK (Python, JS, LangChain, LiteLLM, Vercel AI SDK, …) sends it as
Authorization: Bearer <api_key> for you:
client = OpenAI(base_url="https://gateway.evigauge.ai/v1", api_key="evg_live_…")
That's the whole of it. You only ever write the header by hand when you call the
raw HTTP endpoint directly (e.g. curl), and even then it's the standard OpenAI
scheme — nothing Evigauge-specific:
Authorization: Bearer evg_live_xxxxxxxxxxxx
This is the same key you use elsewhere in Evigauge. It identifies your org,
workspace, and (optionally) project. It is not your model-provider key — that
is stored separately (see below) and never leaves Evigauge. It is also the same
whichever provider backs your model: you authenticate to the Gateway with your
evg_ key, and the Gateway handles each provider's own auth for you.
Providers & schema
The Gateway speaks one schema — OpenAI's (Chat Completions, Responses, Completions, Embeddings). You always talk to it with an OpenAI-compatible client, in OpenAI format — you never swap SDKs per provider.
Through that one schema it reaches five providers, each via its own
OpenAI-compatible endpoint, so the same code and the same evg_ key work no
matter which one backs your model:
| Provider | provider value | Reach a model by sending model |
|---|---|---|
| OpenAI | openai | gpt-4o, o3, … |
| Anthropic | anthropic | claude-… (via Anthropic's OpenAI-compatible endpoint) |
| Google Gemini | gemini | gemini-… (via Gemini's OpenAI-compatible endpoint) |
| DeepSeek | deepseek | deepseek-chat, deepseek-reasoner |
| OpenRouter | openrouter | vendor/model, e.g. meta-llama/llama-3.1-70b |
| anything else | your own string | set base_url to its OpenAI-compatible endpoint |
You pick the provider by storing its credential (next section) and sending the
matching model — only the base_url and your evg_ key ever change in your
client, never the request format.
Two ways to call it: OpenAI-compatible, or each provider's native SDK
You choose per call:
1. An OpenAI-compatible client — one code path, every provider. Point any
OpenAI-compatible client (OpenAI SDK, LangChain ChatOpenAI, LiteLLM openai/…,
Vercel AI SDK, …) at …/v1 and send the matching model. The Gateway reaches each
provider through its OpenAI-compatible endpoint — ideal when you want one path
across providers. (/v1/responses is OpenAI-only; /v1/chat/completions works
across every provider; /v1/completions / /v1/embeddings work wherever the
provider exposes them.)
2. The provider's OWN native SDK — production-grade, no shim. Point the
provider's native SDK at the Gateway with your evg_ key as its api_key. The
Gateway speaks that provider's native API directly and captures the native
request/response (tokens, cost, text, streaming). This matters for providers
whose OpenAI-compat layer is test-only (Anthropic's is explicitly not for
production):
| Provider | Native endpoint | Point your SDK at the gateway with… |
|---|---|---|
| Anthropic | POST /v1/messages | the Anthropic SDK — base_url → gateway, api_key = your evg_ key (sent as x-api-key) |
| Gemini | POST /v1beta/models/{model}:generateContent (+ :streamGenerateContent) | the Google GenAI SDK — base_url → gateway, api_key = your evg_ key (sent as x-goog-api-key) |
Your stored Anthropic/Gemini BYOK key is injected server-side; you never send the real provider key from your app. OpenAI / DeepSeek / OpenRouter are OpenAI-compatible in production, so their native schema is the OpenAI path in option 1 — no separate native endpoint needed.
Connecting a provider (BYOK)
The Gateway calls your model provider with your key — no markup, your account, your rate limits. Two custody modes:
Stored (recommended)
Store the key once, encrypted at rest. The Gateway looks it up per request.
PUT /v1/observ/orgs/{org}/workspaces/{ws}/gateway/providers
| field | required | notes |
|---|---|---|
provider | yes | openai, anthropic, openrouter, deepseek, gemini, or any OpenAI-compatible provider (default base URLs are built in for all five; set base_url for anything else) |
api_key | yes | your provider key; stored encrypted, never returned |
model_pattern | no | "" (default) = all models for this provider; or an exact model (gpt-4o) / prefix to pin a key to specific models |
base_url | no | override the provider's default endpoint (e.g. an OpenAI-compatible or on-prem endpoint) |
You can store several credentials per workspace (e.g. one OpenAI, one Anthropic);
the Gateway picks the best match for the model on each request.
GET …/gateway/providers lists them (keys shown only as •••• last4).
DELETE …/gateway/providers/{id} removes one.
Passthrough (no storage)
If you'd rather not store a key with Evigauge, send it per request:
x-provider-key: sk-your-provider-key
The Gateway forwards with that key and stores nothing.
Endpoints
The Gateway mirrors the OpenAI API surface. Base URL: https://gateway.evigauge.ai/v1.
| Endpoint | Method | Notes |
|---|---|---|
/v1/chat/completions | POST | OpenAI schema; streaming and non-streaming; reaches every provider |
/v1/responses | POST | OpenAI Responses API — reasoning and tool calls in one turn; OpenAI-only; streaming and non-streaming |
/v1/completions | POST | legacy text completions |
/v1/embeddings | POST | |
/v1/messages | POST | Anthropic native Messages API (use the Anthropic SDK); streaming and non-streaming |
/v1beta/models/{model}:generateContent | POST | Gemini native generateContent (use the Google GenAI SDK) |
/v1beta/models/{model}:streamGenerateContent | POST | Gemini native streaming |
The request/response bodies are the provider's own — the Gateway does not reshape
them. Use whatever model your provider supports; it is honored verbatim. Every
endpoint is captured the same way (tokens, cost, latency, and — with capture on —
text), so you keep full observability whichever protocol your client speaks.
Responses API
Use /v1/responses for agents that need reasoning together with tool calls.
A reasoning model (e.g. gpt-6-luna) can keep reasoning effort high and call
tools in the same turn — which Chat Completions cannot do, because it forces
reasoning_effort: "none" as soon as tools are present. Routing that traffic
through the Gateway no longer means giving that up: the Responses body is
forwarded byte-for-byte (input, instructions, tools, reasoning,
response_format, …) and captured natively — tokens and cost from the usage
block (input_tokens / output_tokens), text from output_text / output[]
when capture text is on, and streamed runs
assembled from the Responses SSE events (response.output_text.delta,
response.completed).
resp = client.responses.create(
model="gpt-6-luna",
input="Review this diff and open a ticket if it is a regression.",
tools=[{"type": "function", "name": "open_ticket", "parameters": {}}],
reasoning={"effort": "high"}, # kept — not forced to "none"
)
print(resp.output_text)
Streaming
Set "stream": true as usual. The Gateway tees the provider's SSE stream
straight through to you with no added buffering, so first-token latency is the
provider's own.
stream = client.chat.completions.create(
model="gpt-4o", stream=True,
messages=[{"role": "user", "content": "Write a haiku."}],
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
Two things are worth knowing about a streamed call:
- Capture happens when the stream ends, not per chunk. The Gateway assembles the completion from the deltas it has forwarded and records that. Token counts come from the provider's final usage frame.
- A stream that dies mid-flight is recorded as what arrived. If the provider drops the connection, or your client disconnects, the partial completion and the error are what land in the trace. The trace will show fewer output tokens than a complete call, which is accurate rather than missing.
Optional headers
| Header | Purpose |
|---|---|
x-evigauge-project-id | Scope the call to a project — the exact slug of a project that already exists in your workspace (defaults to the workspace's default project) |
x-evigauge-trace-id | Group several related calls into one multi-step trace. Reuse the same id across a chain of calls and Evigauge reconstructs the full decomposition / decision graph / provenance across them, exactly like an SDK-instrumented agent. |
x-provider-key | Passthrough provider key (see BYOK above) |
Send the project slug you actually created — not a random string.
x-evigauge-project-idmust match an existing project's slug in your workspace (lowercase, hyphenated — the value in the dashboard's project switcher / URL, not the display name). Decide it once and send it consistently.If you send a project id that doesn't exist, the call is not lost — it still succeeds and is recorded — but it lands in the workspace's Default project with the value you sent kept as
requested_project_id. The dashboard then shows a banner prompting you to create that project or fix the id. Knowing this up front (pass the real slug) avoids stray "unknown project" banners. Omit the header entirely and the call simply goes to the workspace's default project.
What Evigauge ingests
This is the section to read before pointing production traffic at the Gateway.
Always recorded
These come from the request and response envelope and do not depend on any setting. They are what the Gateway needs in order to be a cost and latency ledger at all.
| Recorded | Where it comes from |
|---|---|
| Model id | the model field you sent |
| Provider | the credential the call was routed through |
| Input / output token counts | the provider's own usage block |
| Cost | tokens priced by your workspace's cost provider |
| Latency | measured at the Gateway, around the provider call |
| Status and error type | the provider's response status |
| Org, workspace, project | resolved from your evg_ key and x-evigauge-project-id |
| Trace id | x-evigauge-trace-id if you sent one, otherwise one generated per call |
| Timestamps | when the call started and finished |
Recorded only when you turn it on
Prompt and completion text is not stored by default. The workspace setting Capture text is off until an admin enables it, and it fails closed — while it is off, the Gateway keeps the counts above and discards the bodies.
| Recorded with capture on | Notes |
|---|---|
| The prompt you sent | the full messages array, as forwarded |
| The completion returned | assembled from the stream when streaming |
| Tool calls and arguments | they are part of the message bodies |
With text captured, the engines have something to reconstruct and the trace gains decomposition (the reasoning broken into steps), the decision graph (the choices and tool use), provenance (what grounded the answer) and a reliability signal. Without it you still get a complete cost, latency and error record, and those four panels stay empty rather than wrong.
Never recorded
- Your provider key. A stored key is encrypted at rest and is never returned
by any API, including to you. An
x-provider-keysent per request is used for that forward and not persisted. - Anything your redaction rules match. Redaction rules are applied before storage, and the original is never written — so a rule added today does nothing for text captured yesterday.
- Response headers from the provider, beyond the status.
How long it is kept
Captured calls live under your workspace's retention period like any other trace. Shortening retention is destructive, so preview the change before confirming it.
What the engines cost you
The reconstruction engines run on your model credential, the one at LLM credentials, not on the provider key the Gateway forwards with. That spend appears in your LLM spend view attributed to the engine rather than to your application. Which engines run is a per-workspace choice under engine settings, where absence means enabled.
Grouping calls into one trace
A single bare chat completion has little structure to reconstruct: one prompt, one answer, no branches. The reconstruction is worth having when a trace covers a whole piece of work.
Send the same x-evigauge-trace-id across every call in one logical run and the
Gateway files them as one trace, in the order they arrived. A planner call, three
tool-follow-up calls and a synthesis call become one decomposition instead of five
unrelated rows. The id is yours to choose: any stable string per run, typically
the request id you already have.
If you do not send one, every call is its own trace. That is the right default, and it is also why Gateway traces look thinner than SDK traces until you group them. For reconstruction that does not depend on you threading an id at all, the SDK records the structure as the code runs.
Errors & reliability
The Gateway's failure modes are deliberately lopsided: anything it can do after your response is allowed to fail silently, and anything it must do before forwarding fails loudly.
| Status | Means | What to do |
|---|---|---|
401 | Missing or invalid evg_ bearer key | Check the key and that it belongs to this workspace |
412 | No provider credential matches the requested model, and no x-provider-key was sent | Connect a provider, or send a passthrough key |
| the provider's own | Your provider rejected the call | Debug against the provider: this is their status and their body, unmodified |
Fail-open after the forward. Capture and analysis run once your response has been delivered and can never affect it. If Evigauge cannot record a call, you still get your model's output, and the only consequence is a missing row.
Fail-closed before it. Authentication and credential resolution happen before
anything is forwarded, so a 401 or 412 means nothing was sent to your
provider and nothing was billed.
Provider errors are not retried. A 429 or a 503 from your provider is
returned to you as a 429 or a 503. Retry and backoff stay in your client,
where your own idempotency rules live.
Examples
TypeScript / JavaScript (OpenAI SDK):
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://gateway.evigauge.ai/v1",
apiKey: process.env.EVIGAUGE_KEY, // evg_live_...
});
const r = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello" }],
});
curl:
curl https://gateway.evigauge.ai/v1/chat/completions \
-H "Authorization: Bearer evg_live_xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'
LangChain (Python):
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://gateway.evigauge.ai/v1",
api_key="evg_live_xxxxxxxxxxxx",
model="gpt-4o",
)
LiteLLM (Python):
import litellm
resp = litellm.completion(
model="openai/gpt-4o",
api_base="https://gateway.evigauge.ai/v1",
api_key="evg_live_xxxxxxxxxxxx",
messages=[{"role": "user", "content": "Hello"}],
)
Vercel AI SDK (Next.js / TypeScript):
import { createOpenAI } from "@ai-sdk/openai";
const openai = createOpenAI({
baseURL: "https://gateway.evigauge.ai/v1",
apiKey: process.env.EVIGAUGE_KEY, // evg_live_...
});
// then: generateText({ model: openai("gpt-4o"), prompt: "Hello" })
// or a reasoning+tools agent via openai.responses("gpt-6-luna")
Langfuse — point its OpenAI integration (or the underlying client's
base_url) at https://gateway.evigauge.ai/v1 with your evg_ key. Langfuse's
own tracing and Evigauge's reconstruction then run side by side on the same
traffic.
Anthropic — native Messages API (the Anthropic SDK):
from anthropic import Anthropic
client = Anthropic(
base_url="https://gateway.evigauge.ai", # the gateway, NOT api.anthropic.com
api_key="evg_live_xxxxxxxxxxxx", # your Evigauge key (sent as x-api-key)
)
msg = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=512,
messages=[{"role": "user", "content": "Summarize the Q3 report."}],
)
print(msg.content[0].text)
Gemini — native generateContent (the Google GenAI SDK):
from google import genai
client = genai.Client(
api_key="evg_live_xxxxxxxxxxxx", # your Evigauge key (sent as x-goog-api-key)
http_options={"base_url": "https://gateway.evigauge.ai"},
)
resp = client.models.generate_content(
model="gemini-2.5-pro",
contents="Summarize the Q3 report.",
)
print(resp.text)
With the native SDKs your stored Anthropic/Gemini key is injected server-side —
you only ever hand the Gateway your evg_ key.
Any OpenAI-compatible client works too — only the base_url and key change.
Because the Gateway speaks Chat Completions, Responses, Completions and Embeddings
and the Anthropic/Gemini native APIs, you can keep whichever client you already
use and get full observability without any span code.
FAQ
Does this add latency? The Gateway is a thin forward and capture is asynchronous, off your response path. The one thing it adds before the provider call is a credential lookup.
Do you mark up tokens? No. The provider bills your own key directly, for exactly the request you made, because the Gateway forwards it unchanged.
Which models can I use? Any model your connected provider supports. The
model string is passed through verbatim, so a model released this morning works
without us shipping anything.
Can I use reasoning models with tools? Yes — send them to /v1/responses.
Chat Completions forces reasoning_effort: "none" as soon as a request carries
tools, so a reasoning-with-tools agent routed through /v1/chat/completions would
regress. The Responses endpoint forwards reasoning and tools together,
unchanged, and still captures the full trace — so you get the reasoning behavior
and the observability. See Responses API.
Do you store my prompts? Not unless an admin turns on capture text for the workspace. It is off by default and fails closed. See What Evigauge ingests.
Why do my Gateway traces look thinner than the SDK's? Because one chat call
has one prompt and one answer, and there is nothing to decompose. Group the calls
of a single run with a shared x-evigauge-trace-id and the reconstruction has
structure to work with.
Can I use the Gateway and the SDK together? Yes. They land in the same place and produce the same analysis. A common split is the Gateway for services you do not want to touch, the SDK for the agent you are actively building.
What happens if Evigauge goes down? Calls that have already authenticated
keep being forwarded and answered; capture is what degrades. The failure mode
that stops traffic is a 401 or a 412, both of which are about your key or your
provider credential rather than about our availability.
Is my provider key safe? A stored key is encrypted at rest and never returned by any API, including to you. Or use passthrough mode, where it is used for one forward and not persisted.
Can I pin different keys to different models? Yes, with model_pattern. See
Which credential gets used.