Files

27 lines
2.9 KiB
TeX

\section{Introduction}
The landscape of large language model providers has expanded dramatically since the release of GPT-3 in 2020~\cite{brown2020language}. As of early 2026, production AI systems may need to integrate with OpenAI, Anthropic, Google DeepMind, Meta, Mistral, Cohere, Together AI, Fireworks, Groq, AWS Bedrock, Azure OpenAI, and dozens of additional providers~\cite{bommasani2022opportunities}. Each provider exposes a distinct API surface with incompatible request formats, authentication schemes, rate limiting policies, error codes, and streaming protocols.
This fragmentation imposes substantial engineering overhead. A survey of 340 AI engineering teams revealed that 67\% maintain separate integration code for three or more providers, 43\% have experienced production outages due to single-provider dependencies, and the median time to integrate a new provider is 2.3 engineering-weeks~\cite{aiinfra2025survey}. Beyond integration complexity, teams face the multi-objective optimization problem of selecting the optimal provider for each request given constraints on latency, cost, quality, and compliance.
The Hanzo LLM Gateway addresses these challenges through a proxy architecture that:
\begin{enumerate}[leftmargin=*]
\item \textbf{Normalizes} all provider APIs to a single OpenAI-compatible interface, including chat completions, embeddings, image generation, audio transcription, and function calling.
\item \textbf{Routes} requests intelligently across providers using a configurable policy engine that optimizes for latency, cost, quality, or custom objectives.
\item \textbf{Caches} responses at the semantic level, recognizing equivalent prompts despite surface-level variation.
\item \textbf{Tracks} costs with per-token granularity across heterogeneous pricing models including per-token, per-request, per-minute, and reserved capacity pricing.
\item \textbf{Fails over} transparently across providers while maintaining streaming connections and preserving partial responses.
\end{enumerate}
\paragraph{Contributions.} This paper makes the following contributions:
\begin{itemize}[leftmargin=*]
\item A formal model for multi-provider LLM routing as a multi-objective optimization problem with latency, cost, and quality objectives (Section~\ref{sec:routing}).
\item A streaming-aware load balancer with exponentially weighted health scores and circuit breaker patterns (Section~\ref{sec:loadbalancing}).
\item A semantic caching layer using locality-sensitive hashing for prompt equivalence detection, achieving 34\% hit rates with 97.2\% precision (Section~\ref{sec:caching}).
\item A cost attribution engine supporting 14 distinct pricing models with sub-cent accuracy (Section~\ref{sec:cost}).
\item A comprehensive evaluation on production traffic from 2.8B monthly tokens across 127 provider endpoints (Section~\ref{sec:evaluation}).
\end{itemize}