AI Gateway

One gateway for all your AI Applications

Route requests to AI Inference and third-party providers, fall back when a model fails, and keep keys, limits, and usage logs in one place, with no proxy servers to run.

Your Stack, Your Way
  • OpenAI
  • Anthropic
  • Groq
  • Next.js
  • Astro
  • React
  • Vue
  • Angular
  • Nuxt
  • Gatsby
  • Hugo
  • Preact
  • Remix
  • Qwik
  • Vite
  • VitePress
  • Docusaurus
  • Eleventy
  • Hexo
  • Jekyll
  • Hono
  • Node.js
  • AWS
  • Google Cloud
  • Azure
  • Cloudflare Workers
  • Terraform
  • GitHub
  • SQLite
  • Drizzle

One endpoint for every model

Apps send OpenAI-format requests with a model alias. Change the model behind an alias once, and every app follows.

Fallback when a provider fails

Each alias lists its models in order. When a call errors or times out, the gateway moves to the next one.

Provider keys stay server-side

Provider keys live in secret environment variables. Each team gets its own gateway key, stored only as a SHA-256 hash.

Abuse blocked before it costs tokens

Firewall applies WAF, rate limits, and DDoS Protection before requests reach the gateway, so blocked traffic never reaches a model.

Repeated prompts served from cache

Callers opt in per request. A matching prompt gets a stored response, with no model call and no tokens spent.

Every call on the record

Each call logs the team, model, fallback, cache result, and tokens used. Stream the logs to your SIEM or data warehouse.

Every AI request through one control point

Chatbots, AI agents, and coding agents call one endpoint. Firewall stops abuse, then a function checks the key, routes the call, and logs it.

Chatbots, AI agents, and coding agents connect through the AI gateway on Azion to models, MCP servers, and APIs

Use cases

Platform teams

Central model access for every team

Give each team its own gateway key and list of allowed models, and block a team that reaches its budget.

Reliability

Failover across providers

Try a model on AI Inference first, then a third-party provider, so one provider's outage doesn't take your AI features down.

Cost control

Spend tracked per team

Sum token usage per team from the gateway logs, and answer repeated prompts from cache with no model call.

AI agents

Governed model access for agents

Point agents and MCP servers at the gateway, so every model call they make follows the same keys, limits, and logs.

Model choice

Route by task, not by vendor

Map aliases such as general and long-context to the model that fits each job, and swap models without touching app code.

Audit

A record of every model call

Know which team called which model, when, and with how many tokens. Keep the trail in Splunk, Datadog, or BigQuery.

The shortest path to a production AI gateway

Keep the OpenAI SDK you already use. Point it at your gateway and send a model alias. The gateway handles keys, routing, fallback, and logs.

client.ts
01import OpenAI from 'openai';
02
03const client = new OpenAI({
04 baseURL: process.env.AI_GATEWAY_URL,
05 apiKey: process.env.AI_GATEWAY_KEY
06});
07
08const reply = await client.chat.completions.create({
09 model: 'general',
10 messages: [{ role: 'user', content: 'Summarize this ticket.' }]
11});
12
13console.log(reply.choices[0].message.content);
HeroSpark
Azion transformed our operations, reducing costs and improving performance while freeing 200+ monthly hours for strategic development.
Mateus LeonardiCTO at HeroSpark

All the development primitives you need

Frequently Asked Questions

What is AI Gateway?

AI Gateway is one endpoint between your applications and the AI models they call, built on the Azion Web Platform. It authenticates each team, picks a model by policy, falls back when a call fails, caches responses the caller allows, and writes a usage and audit log line for every call. It runs as a function on Azion's distributed infrastructure, behind Firewall.

What is AI Gateway built with?

Functions runs the gateway logic on an application, and AI Inference runs the models hosted on Azion. Firewall applies WAF, rate limits, and DDoS Protection before a request reaches the function. KV Store holds team keys and policies, the Cache API stores allowed responses, and Connectors reach your own model servers. Real-Time Events, Real-Time Metrics, and Data Stream record and export every call.

Which models and providers can I use?

Any model on AI Inference, including Qwen3 30B A3B, GPT-OSS 20B, and Mistral 3 Small, plus embedding, reranking, and vision models. The gateway also calls third-party providers whose APIs accept the OpenAI chat completions format, and your own model servers through Connectors. For a provider with its own request format, adapt the request in the function.

Do I need to change my application code?

Usually only the base URL and the key. The gateway accepts OpenAI chat completions requests at /v1/chat/completions, so OpenAI SDKs and compatible clients keep working. Teams send a model alias, such as general, and the platform team decides which model answers it.

How does fallback work?

Each alias has an ordered list of models. When a call throws an error, returns no choices, answers with an error status, or runs past its timeout, the gateway tries the next model. Every failed attempt is logged, and if all of them fail, the gateway answers 502.

How do I control spend per team?

Every call logs the team and the tokens the model used, so your analytics platform can sum spend per team. When a team reaches its budget, set its status to blocked, and the gateway answers 429 to its key. Third-party calls use your own provider keys, so providers bill your accounts at their own prices, with no markup from Azion.

How are provider keys and team keys protected?

Provider keys are stored as secret environment variables and read inside the function, so they never appear in code or reach a team. Each team gets its own gateway key, and KV Store keeps only its SHA-256 hash. To validate JSON Web Tokens instead, run the JWT function from Marketplace on Firewall.

How do I monitor requests, latency, and errors?

Real-Time Metrics charts requests, status codes, upstream status, and function invocations. Real-Time Events keeps each request's log lines for 7 days, grouped by request ID. Data Stream sends the same lines to Splunk, Datadog, Elasticsearch, Google BigQuery, Amazon S3, Apache Kafka, or any HTTPS endpoint.

How does AI Gateway on Azion compare to other AI gateways?

Managed AI gateways give you a fixed set of features to configure. On Azion, the gateway is code you own: routing, fallback, caching, and authentication live in one function, so you can apply any policy your teams need. The same platform runs models on AI Inference and protects the endpoint with Firewall, so there's no separate proxy to secure.

What do I need to get started?

An application with Application Accelerator, which lets a rule run the gateway function, and KV Store, which is in Preview and enabled through Technical Support. The documentation covers the full setup, from the function code to the usage stream. Talk to a specialist to plan the models, routes, and budgets for your teams.

//Build

Build once.Run everywhere.

Get a faster path to launch, lower latency, and less infrastructure overhead.