Self-Hosted AI Gateway: Route OpenAI, Anthropic & Gemini Through One API
Proxy OpenAI, Anthropic, Gemini, and Grok through a single OpenAI-compatible endpoint. Unified cost tracking, request logging, and no Helicone or LiteLLM fees.
A self-hosted AI gateway is a proxy that sits between your application and multiple AI provider APIs (OpenAI, Anthropic, Gemini, xAI), letting you route all LLM requests through a single endpoint with unified authentication, cost tracking, and observability — running on your own infrastructure instead of a third-party SaaS.
Temps ships an AI Gateway as a built-in feature — no separate service to deploy, no additional bill. It runs inside the same Rust binary that handles your deployments, analytics, and error tracking.
TL;DR: The Temps AI Gateway is an OpenAI-compatible proxy built into the Temps self-hosted PaaS. It routes requests to Anthropic (Claude), OpenAI (GPT/o-series), Google Gemini, and xAI (Grok) through one endpoint, with per-request cost tracking stored at 1/10,000th-cent precision. Provider API keys are encrypted with AES-256-GCM. Temps is Apache 2.0 and free to self-host; Temps Cloud costs ~$6/mo (Hetzner cost + 30% margin, no per-seat fees).
According to Kong, 72% of enterprises plan to increase GenAI spending in 2025. The average monthly AI spend already hits $85,521 according to CloudZero. And most teams can't answer "which model is burning through our budget?"
Here's what happens without a gateway:
4+ API keys scattered across env vars, Vault secrets, and team Slack DMs
4+ billing portals with different invoicing cycles
No cross-provider cost view — you can't answer "how much did our AI features cost last month?"
No per-user or per-feature attribution — was it the chatbot or the code reviewer that burned $3,000?
Key rotation nightmares — changing one key means updating 12 services
The core difference: Temps embeds the gateway in the same process as deployments, analytics, error tracking, and uptime monitoring. You don't run a separate service, don't pay a separate bill, and don't log in to a separate dashboard.
If your code already calls OpenAI, switching to the Temps gateway takes one line:
import openaiclient = openai.OpenAI( api_key="tk_your_temps_api_key", base_url="https://your-temps.example.com/api/ai/v1",)# Routes to Anthropic automatically based on model prefixresponse = client.chat.completions.create( model="claude-sonnet-4-6", messages=[{"role": "user", "content": "Explain TCP vs UDP"}],)
Same code, same SDK, same types. Works with any OpenAI-compatible SDK — Python, TypeScript, Go, Rust, curl.
import OpenAI from "openai";const client = new OpenAI({ apiKey: "tk_abc123", baseURL: "https://your-temps.example.com/api/ai/v1",});// Four providers, one endpoint, one API keyconst anthropic = await client.chat.completions.create({ model: "claude-sonnet-4-6", messages: [{ role: "user", content: "Hello" }],});const openaiModel = await client.chat.completions.create({ model: "gpt-4o", messages: [{ role: "user", content: "Hello" }],});const gemini = await client.chat.completions.create({ model: "gemini-2.5-flash", messages: [{ role: "user", content: "Hello" }],});
BYOK keys are ephemeral — used for the request and never stored. System-configured keys are encrypted at rest with AES-256-GCM (via the aes-gcm Rust crate, same encryption layer used for deployment environment variables).
Temps includes a built-in OpenTelemetry collector. Combine the AI Gateway with OTel GenAI semantic conventions for end-to-end traces of every AI interaction:
Which user triggered the request
What the input and output messages were
How long the model took to respond
Token usage and estimated cost
Thinking blocks and tool calls (for Anthropic Claude)
The AI Activity tab in your project dashboard shows these traces as a conversation view — system prompt, user messages, assistant responses, tool calls, and reasoning/thinking blocks rendered inline.
In the Temps dashboard, go to AI Gateway and add your provider API keys. Each key is encrypted with AES-256-GCM before being written to the database. The dashboard validates the key format and tests connectivity before saving.
The Temps AI Gateway adds under 10ms overhead — including authentication, request translation, and response normalization. The bottleneck is always the upstream provider (typically 200–2000ms), never the proxy.
Yes. Use the X-Provider-Api-Key header to pass your key per-request (BYOK mode). It's used for that request only and never stored. System-configured keys are encrypted with AES-256-GCM.
Yes. All four providers support streaming via "stream": true. The gateway translates SSE chunks between provider formats — Anthropic's message_delta events are normalized to OpenAI's delta format.
The AI Gateway is included in Temps at no extra charge. You pay your provider API costs directly (OpenAI, Anthropic, etc.) — Temps adds zero markup. On Temps Cloud, it's included in the ~$6/mo plan. Self-hosting is free under the Apache 2.0 license.
Yes. Instrument your app with OpenTelemetry GenAI semantic conventions and the AI Activity tab shows full conversation threads — system prompts, user messages, assistant responses, tool calls, and thinking blocks.
Temps routes by model name prefix: claude-* → Anthropic, gpt-*/o1/o3/o4/text-embedding-* → OpenAI, gemini-* → Google, grok-* → xAI. Custom OpenAI-compatible endpoints are also supported.
The AI Gateway ships with the latest Temps release. If you're already running Temps, update to the latest version and configure your provider keys in the dashboard.
If you're new to Temps, get started in under 5 minutes:
curl -fsSL https://get.temps.sh | sh
One binary. Deployments, analytics, error tracking, monitoring, and a built-in AI gateway. No SaaS sprawl required. Apache 2.0, free to self-host.