# LLM Gateway

> LLM Gateway is an open-source AI gateway. Route requests through one OpenAI-compatible API and key, with usage analytics, cost tracking, caching, and automatic failover. The live models and providers directories list current availability. Open source (AGPLv3) and self-hostable.

## Quick answers

- [What is LLM Gateway?](https://llmgateway.io/products/ai-gateway): An open-source (AGPLv3) LLM API gateway: one OpenAI-compatible endpoint, `https://api.llmgateway.io/v1`, and one API key for models from every major provider.
- [How do I switch to it?](https://docs.llmgateway.io/quick-start): Change your OpenAI SDK base URL and API key, then use a model ID such as `gpt-4o`. On pay-as-you-go keys, the `provider/model` form (`openai/gpt-4o`) pins a provider; DevPass coding plans do not support pinning.
- [What does it cost?](https://llmgateway.io/pricing): Provider token rates. Pay-as-you-go credits carry a flat 5% platform fee; Bring-Your-Own-Keys is free. Self-hosting is free.
- [What happens when a provider fails?](https://llmgateway.io/reliability): Requests that name only a model are retried on other providers that serve it. Provider-pinned requests can also be rerouted, for example when the pinned provider is rate-limited or its uptime is degraded and an eligible alternative exists. The `X-No-Fallback: true` header blocks these reroutes; a rate-limited request then receives HTTP 429. Full rules: https://docs.llmgateway.io/features/routing.
- [How does it compare to OpenRouter or LiteLLM?](https://llmgateway.io/compare): See the comparison pages and the [OpenRouter alternatives](https://llmgateway.io/blog/openrouter-alternatives) and [LiteLLM alternatives](https://llmgateway.io/blog/litellm-alternatives) posts.

## Key pages

- [Models](https://llmgateway.io/models): Full catalog of supported LLMs with pricing, context windows, and capabilities.
- [LLM Rankings](https://llmgateway.io/rankings): Which models developers actually run in production — live token volume, trends, and provider market share over 24h/7d/30d windows.
- [Model release timeline](https://llmgateway.io/timeline): When each LLM was released by its provider and when it was added to LLM Gateway — a reference for AI model release dates.
- [Pricing](https://llmgateway.io/pricing): Per-token at provider rates. Pay-as-you-go credits carry a flat 5% platform fee; Bring-Your-Own-Keys is free; enterprise plans available.
- [Pricing (machine-readable)](https://llmgateway.io/pricing.md): Plain-markdown pricing summary for AI agents.
- [Image generation API](https://llmgateway.io/products/image-generation): One OpenAI-compatible endpoint (`/v1/images/generations`, `/v1/images/edits`) for every image model, with a live table of the lowest price of one image per model (models billed by image tokens alone are marked as priced per token).
- [Providers](https://llmgateway.io/providers): Every supported provider and the models each offers.
- [Docs](https://docs.llmgateway.io): API reference and integration guides.
- [About](https://llmgateway.io/about): Who builds LLM Gateway and why.
- [Contact](https://llmgateway.io/contact): Email, Discord, GitHub, and enterprise sales channels.
- [Compare](https://llmgateway.io/compare/open-router): How LLM Gateway compares to OpenRouter, LiteLLM, Portkey, the Vercel AI Gateway, and GitHub Copilot.
- [GitHub Copilot cost calculator](https://llmgateway.io/copilot-cost-calculator): Estimate a team's monthly Copilot AI Credits bill under the June 2026 usage-based billing and compare the same workload at pass-through token prices with prompt caching.
- [Migrate from GitHub Copilot](https://llmgateway.io/migration/github-copilot): Map Copilot chat, agent mode, and code review to gateway-backed tools with hard budget caps.
- [Migrate from OpenRouter](https://llmgateway.io/migration/openrouter): Same OpenAI-compatible API and model strings — swap the base URL and key, keep BYOK free, and self-host if you need prompts inside your own network.
- [Model comparisons](https://llmgateway.io/models/compare): Side-by-side pricing, context window, and capabilities for any two models, with a page per popular pair.
- [Glossary](https://llmgateway.io/glossary): Short definitions of LLM API terms — tokens, context windows, prompt caching, routing, fallback, TTFT.
- [Token counter](https://llmgateway.io/token-counter): Count tokens, words, and characters in the browser.
- [Context window checker](https://llmgateway.io/context-window-checker): See which models a prompt fits in, with room reserved for the response.
- [Troubleshooting](https://docs.llmgateway.io/troubleshooting/provider-api-down): What to do when a provider is down, and fixes for OpenAI 429, Anthropic 529, and Gemini 429 errors.
- [Blog feed](https://llmgateway.io/blog/rss.xml) and [changelog feed](https://llmgateway.io/changelog/rss.xml): RSS.

## Best models by use case

- [Best models for roleplay](https://llmgateway.io/models/roleplay): Roleplay and character-chat LLMs compared by prose quality, context window, and price.
- [Best models for coding](https://llmgateway.io/models/coding): Code generation and agentic coding models, frontier and open-weight.
- [Best models for creative writing](https://llmgateway.io/models/creative-writing): LLMs with strong long-form prose and narrative consistency.
- [Best models for translation](https://llmgateway.io/models/translation): Multilingual models for document and string translation.
- [Best models for math](https://llmgateway.io/models/math): Reasoning models for competition math and quantitative work.
- [Best models for cyber security](https://llmgateway.io/models/cyber-security): LLMs for code audits, log triage, CTFs, and sandboxed malware analysis, including Chinese-lab models with no cyber refusal layer.
- [Best models for reverse engineering](https://llmgateway.io/models/reverse-engineering): Tool-calling models that read decompiler output and drive Ghidra, Hopper, and IDA through REA (Reverse Engineer Anything) without stopping mid-task.
- [Long context models](https://llmgateway.io/models/long-context): Models with 200K to 2M token context windows.
- [Cheapest models](https://llmgateway.io/models/cheapest): Models at or under $0.20 per million input tokens.
- [Open source models](https://llmgateway.io/models/open-source): Open-weight LLMs served via API, with current pricing and capabilities.

## Use cases

- [Coding agents](https://llmgateway.io/use-cases/coding-agents): One key behind Claude Code, Cursor, Cline and custom agents, with fallback and per-agent cost tracking.
- [AI customer support](https://llmgateway.io/use-cases/ai-customer-support): Support assistants on one API with model fallback and cost analytics.
- [RAG and document Q&A](https://llmgateway.io/use-cases/rag-document-qa): Long-context and embedding models for retrieval pipelines.
- [Cost optimization](https://llmgateway.io/use-cases/cost-optimization): Route by task, cache prompts, and see spend per key.
- [Cyber security](https://llmgateway.io/use-cases/cyber-security): Code audits, log triage, CTFs and sandboxed malware analysis; frontier models for defensive work, Chinese-lab models for tasks Claude and GPT refuse.
- [Reverse engineering](https://llmgateway.io/use-cases/reverse-engineering): Run REA, Ghidra and Hopper agents (Claude Code, Codex, OpenCode) on models that do not stop mid-analysis.
- [Startups](https://llmgateway.io/use-cases/startups): One API and key for every model, pay-as-you-go, with failover and per-request cost analytics.
- [Agencies](https://llmgateway.io/use-cases/agencies): Per-client projects, API keys, usage limits, and cost logs for bill-back.
- [Healthcare](https://llmgateway.io/use-cases/healthcare): Restrict which providers receive requests, redact sensitive data, control retention, or self-host.
- [Fintech](https://llmgateway.io/use-cases/fintech): Audit logs, provider compliance policies, SSO, spend limits, and cross-provider failover.

## Developer resources

- [LLM Gateway developer resources](https://llmgateway.io/developers): API documentation, authentication, developer dashboard, and MCP entry points.
- [LLM Gateway authentication](https://docs.llmgateway.io/features/api-keys): Create, rotate, and scope API keys; authenticate with the Authorization: Bearer header.
- [LLM Gateway developer dashboard](https://llmgateway.io/dashboard): Sign in to manage projects, keys, usage, and spending limits.
- [LLM Gateway API versioning and deprecation policy](https://docs.llmgateway.io/resources/api-versioning): Compatibility, deprecation notices, and sunset conventions.
- [LLM Gateway rate limits](https://docs.llmgateway.io/resources/rate-limits): Quota headers and retry guidance.

- [OpenAPI specification](https://llmgateway.io/openapi.json): Machine-readable spec for the LLM Gateway API (also at https://api.llmgateway.io/openapi.json). Every operation has an operationId, typed schemas, and typed 4xx/5xx error responses.
- [API base URL](https://api.llmgateway.io/v1): OpenAI-compatible; authenticate with `Authorization: Bearer <api-key>`.
- [API docs](https://docs.llmgateway.io): Reference and integration guides; full docs as markdown at https://llmgateway.io/llms-full.txt.
- [Quick start](https://docs.llmgateway.io/quick-start): First request in minutes with any OpenAI SDK.
- [MCP server](https://api.llmgateway.io/mcp): Model Context Protocol server (Streamable HTTP). Connect at https://llmgateway.io/mcp or the API-domain URL. Public discovery uses GET; tool calls require an API key. OAuth metadata: https://api.llmgateway.io/.well-known/oauth-protected-resource/mcp.
- [API versioning](https://docs.llmgateway.io/resources/api-versioning): The API is path-versioned (`/v1`); breaking changes only ship under a new version. Deprecations are announced in the [changelog](https://llmgateway.io/changelog).
- [Rate limits](https://docs.llmgateway.io/resources/rate-limits): 429 responses include `Retry-After` and `RateLimit`, `RateLimit-Policy`, and legacy `RateLimit-*` headers; back off until `Retry-After` elapses.
