NewsCrawler.org

Why More Developers Are Using AI Gateways

The article explains what an AI Gateway[1] is and why more teams use one. The author describes a team that wrote three adapters for OpenAI, Anthropic and Qwen in its business code, each with its own retry logic, error codes and token counting.

An AI Gateway moves model calls out of business code. The application sends requests in one format (usually OpenAI Chat Completions) to one address, and the gateway handles translation, routing, fallback and cost tracking. Routing strategies range from a fixed model to rules by scenario, tenant or risk level, and to cost routing, which tries a small model first. A fallback[2] is not suitable for every error: network interruptions and 5xx errors suit switching, 429 requires reading Retry-After, and authentication errors do not improve by switching.

The gateway can give each app or user a virtual key[3] that maps to the real provider key, so a key can be revoked without affecting others. Limits are set by tokens and cost budgets rather than QPS, because one request may use 100 tokens and another 100,000. The article shows a LiteLLM configuration that exposes gpt-4o, deepseek-chat and qwen-max through one address, so client code changes only base_url and model. Drawbacks include an extra point of failure, possible flattening of provider-specific features, and maintenance costs for self-hosting. Thoughtworks noted more than 25 CVE[4] reports for LiteLLM in 2026. A gateway is not needed for a system with one model and one caller.

Read the original juejin.cn

Discussion

Readers mostly agree that glue code and scattered error handling cause real problems. One commenter asks how a gateway avoids repeated output or repeated tool execution when a fallback happens after a streaming response has already partly returned, and suggests including idempotency, tool execution state and cancellation signals in the routing policy.

Sources

  • CNJuejin ZH

    为什么越来越多人用 AI Gateway?

    17 likes1,817 views5 comments25 saves

Published: First seen: Читать по-русски

Open as a page