Skip to content

Blog

Building a multi-model architecture: route requests to the right LLM

Using one model for everything is the simplest architecture. It’s also the most wasteful. A 685B-parameter reasoning model answering “what’s the weather?” is like hiring a PhD to sort mail.

This guide covers how to use a small, fast model to classify incoming requests and route them to the right specialist. The result: lower latency, lower cost, and often better quality — because each model handles what it’s actually good at.


The problem with single-model architectures

Section titled “The problem with single-model architectures”

Most applications start with one model:

User request --> Large Model --> Response

This works, but every request — simple or complex — pays the same latency and cost penalty. When 60% of your traffic is simple classification, FAQ, or extraction, you’re burning expensive compute on tasks a small model handles equally well.

Llama 3.1 8B
~200 t/s
DeepSeek V3.2
~60 t/s
DeepSeek R1
~30 t/s

The gap between Llama 8B and R1 is nearly 7x in throughput. Routing simple requests to the small model saves that difference on every request.


User request --> Router (Llama 8B) --> classify intent
|
+-----------+-----------+-----------+
| | | |
simple general reasoning code
| | | |
Llama 3.1 8B DeepSeek DeepSeek R1 Qwen3
V3.2 Coder
| | | |
+-----+-----+-----+-----+
|
Response

Two stages:

  1. Classify — The router model reads the user’s message and outputs a category. This takes ~0.2 seconds with Llama 8B.
  2. Route — Based on the category, forward the request to the appropriate specialist model.

The router adds minimal overhead (~200ms) but saves significant compute by keeping simple requests away from expensive models.


Llama 3.1 8B is the router. At ~200 t/s output speed, ~0.2s TTFT, and $0.02/M input tokens, the classification step costs almost nothing and completes before the user notices.

The classification prompt is simple — you want a single-word category, not a conversation:

from openai import OpenAI
client = OpenAI(
base_url="https://api.cheapestinference.com/v1",
api_key="your-api-key"
)
def classify_request(user_message: str) -> str:
"""Classify a user message into a routing category."""
response = client.chat.completions.create(
model="meta-llama/llama-3.1-8b-instruct",
messages=[
{
"role": "system",
"content": (
"Classify the user's message into exactly one category. "
"Respond with only the category name, nothing else.\n\n"
"Categories:\n"
"- simple: greetings, FAQ, simple factual questions\n"
"- general: complex questions, analysis, writing, summarization\n"
"- reasoning: math, logic, multi-step problems, science\n"
"- code: code generation, debugging, refactoring, technical implementation\n"
"- agent: tasks requiring tool use, web search, or multi-step execution"
)
},
{"role": "user", "content": user_message}
],
max_tokens=10,
temperature=0
)
category = response.choices[0].message.content.strip().lower()
# Default to general if classification is unclear
valid = {"simple", "general", "reasoning", "code", "agent"}
return category if category in valid else "general"

The key details: max_tokens=10 because we only need one word. temperature=0 for deterministic routing. The system prompt is explicit about format — no preamble, just the category.


Each category maps to a model optimized for that task:

# Model routing table
ROUTE_TABLE = {
"simple": "meta-llama/llama-3.1-8b-instruct",
"general": "deepseek/deepseek-chat-v3-0324",
"reasoning": "deepseek/deepseek-reasoner",
"code": "qwen/qwen3-coder",
"agent": "moonshotai/kimi-k2-5",
}
def route_request(user_message: str, conversation_history: list) -> str:
"""Classify and route a request to the appropriate model."""
category = classify_request(user_message)
model = ROUTE_TABLE[category]
response = client.chat.completions.create(
model=model,
messages=conversation_history + [
{"role": "user", "content": user_message}
],
stream=True
)
# Stream the response back
full_response = ""
for chunk in response:
if chunk.choices[0].delta.content:
content = chunk.choices[0].delta.content
full_response += content
print(content, end="", flush=True)
return full_response

Notice that simple requests route back to Llama 8B — the same model that did the classification. For simple queries, the router overhead is effectively zero because the specialist is the same model and can reuse the warm connection.


The basic router works for most traffic, but production systems need a few refinements:

def route_request_production(
user_message: str,
conversation_history: list,
force_model: str = None
) -> tuple[str, str]:
"""Production router with overrides and fallback."""
# Allow explicit model override (for power users or testing)
if force_model:
model = force_model
category = "override"
else:
category = classify_request(user_message)
model = ROUTE_TABLE[category]
try:
response = client.chat.completions.create(
model=model,
messages=conversation_history + [
{"role": "user", "content": user_message}
]
)
return response.choices[0].message.content, category
except Exception:
# Fallback to V3.2 if the specialist is unavailable
fallback = "deepseek/deepseek-chat-v3-0324"
response = client.chat.completions.create(
model=fallback,
messages=conversation_history + [
{"role": "user", "content": user_message}
]
)
return response.choices[0].message.content, f"{category}->fallback"

Three patterns worth noting:

  1. Force model — Let callers bypass routing when they know what they need.
  2. Fallback — If a specialist model is down, fall back to V3.2. It handles everything reasonably well.
  3. Return the category — Log which route each request takes. You’ll need this data to tune the system.

Consider a workload of 1,000 requests with this distribution: 600 simple, 300 general, 70 reasoning, 30 code. Average 500 input tokens, 200 output tokens per request.

Single-model approach (everything on V3.2)

Section titled “Single-model approach (everything on V3.2)”
Avg latency
~4.5s
All 1000 reqs
V3.2 only

Every request waits for V3.2’s ~1.2s TTFT plus generation time at ~60 t/s. Simple questions get the same treatment as complex analysis.

Simple (600)
~1.2s (8B)
General (300)
~4.7s (V3.2)
Reasoning (70)
~9.0s (R1)
Code (30)
~3.5s (Coder)

The weighted average latency drops to approximately 2.7s — a 40% reduction. The 600 simple requests finish in ~1.2s instead of ~4.5s. That’s a 3.7x improvement for the majority of your traffic.

The 70 reasoning requests are slower individually (~9s vs ~4.5s) because R1 generates chain-of-thought tokens. But the quality on those specific requests is significantly better — R1 scores 50.2% on HLE versus V3.2’s 39.3%.

You get faster averages and better quality on the hard tail.


A customer support chatbot receives three types of requests:

  1. FAQ (60%) — “What are your business hours?” / “How do I reset my password?”
  2. Complex support (30%) — “I was charged twice for order #12345, can you investigate?”
  3. Technical issues (10%) — “Your API returns 500 when I send multipart form data with UTF-8 filenames”

All requests go to DeepSeek V3.2. FAQs get correct answers but with unnecessary latency. Technical issues get decent answers but miss edge cases that a code-specialized model would catch.

SUPPORT_ROUTES = {
"simple": "meta-llama/llama-3.1-8b-instruct", # FAQ, greetings
"general": "deepseek/deepseek-chat-v3-0324", # Complex support
"reasoning": "deepseek/deepseek-chat-v3-0324", # Investigations
"code": "qwen/qwen3-coder", # Technical issues
"agent": "moonshotai/kimi-k2-5", # Multi-step resolution
}

FAQs resolve in ~1 second via Llama 8B. Complex support issues get V3.2’s full analytical capability. Technical problems route to Qwen3 Coder, which understands the code context better. If a support issue requires looking up order data via API, it routes to Kimi K2.5 for tool-assisted resolution.

The classification step adds ~200ms. For the 60% of requests that drop from ~4.5s to ~1.2s, that’s an invisible cost.


Routing adds complexity. Skip it when:

  • All your requests are the same type. If you’re building a code editor, just use Qwen3 Coder. No routing needed.
  • You have fewer than 100 requests/day. The cost savings don’t justify the engineering overhead at low volume.
  • Latency doesn’t matter. For batch processing or async workloads, a single capable model is simpler.
  • Your classification accuracy is low. If the router misclassifies frequently, you get worse results than a single good model. Test the classifier on real traffic before deploying.

The sweet spot is high-volume applications with diverse request types — chatbots, API gateways, developer tools, and customer-facing products where response time directly affects user experience.


  1. Log your traffic. Before building a router, understand your request distribution. What percentage is simple? Complex? Code?
  2. Start with two tiers. Llama 8B for simple, V3.2 for everything else. Add specialists only when you have data showing they help.
  3. Measure classification accuracy. Sample 100 requests, manually label them, compare against the router’s output. Target >90% accuracy.
  4. Add fallback. Every specialist route should fall back to V3.2 if the specialist is unavailable.
  5. Monitor per-route metrics. Track latency, cost, and quality per category. This tells you where to optimize next.

All models in this guide are available through a single OpenAI-compatible API with no configuration changes between models. If you’re building a platform that needs LLM access for your users, see how per-key plans work.

Sources: Artificial Analysis Leaderboard · DeepSeek V3.2 · HLE Leaderboard · Kimi K2.5 Benchmarks

How to choose the right open-source model for your task

Most teams default to the biggest model available and call it a day. That works — until latency spikes, costs climb, and you realize a 8B-parameter model would have handled 60% of your requests just fine.

This guide maps common use cases to specific models, with real throughput numbers from our infrastructure. No theory — just which model to pick and why.


Use caseModelWhy
General chat / assistantsDeepSeek V3.2Best all-rounder. 85% MMLU-Pro, 73% SWE-bench, 60 t/s.
Complex reasoningDeepSeek R150.2% on Humanity’s Last Exam. Chain-of-thought built in.
Code generationQwen3 CoderPurpose-built for code. Strong on completions, refactoring, and debugging.
Agentic workflowsKimi K2.5334 t/s output, native tool use, 50.2% HLE with tools. Built for agents.
Vision / multimodalLlama 4 Scout17 active experts, 109B params, native image understanding.
Fast classificationLlama 3.1 8B~200 t/s, 0.2s TTFT. Small enough for routing, tagging, extraction.
General (budget)GLM 4.7 FlashFast inference, competitive quality. Good when V3.2 is overkill.
Long context chatMiniMax M2.5Native long-context support. Handles large documents well.
Large general + reasoningQwen3 235B235B MoE. Strong across benchmarks when you need maximum capability.
EmbeddingsBGE LargeMTEB-tested. Solid retrieval quality for RAG pipelines.

Pick: DeepSeek V3.2

DeepSeek V3.2 is the default choice for most workloads. It scores 85% on MMLU-Pro (beating Claude Opus 4.6’s 82%), 73% on SWE-bench Verified, and runs at ~60 tokens/second on our infrastructure.

Kimi K2.5
334 t/s
Llama 3.1 8B
~200 t/s
DeepSeek V3.2
~60 t/s
DeepSeek R1
~30 t/s

Good at: Broad knowledge, instruction following, multilingual, structured output. Not ideal for: Tasks that need step-by-step reasoning chains (use R1) or sub-100ms latency (use Llama 8B). Pick over alternatives when: You need a reliable general-purpose model that handles most tasks without specialization.


Pick: DeepSeek R1

R1 is a reasoning-first model. It produces explicit chain-of-thought tokens before its final answer. On Humanity’s Last Exam — a benchmark designed to be unsolvable by current models — R1 scores 50.2%, beating GPT-5.4 (41.6%) and Claude Opus 4.6 (40%).

The tradeoff is speed. At ~30 t/s, R1 is the slowest model in our lineup. That’s expected — it’s generating reasoning tokens that never appear in the final output.

Good at: Math, science, logic puzzles, multi-step problems, anything where “thinking” helps. Not ideal for: Simple Q&A, classification, or latency-sensitive applications. Pick over alternatives when: The task requires multi-step deduction. If a human would need to “think through it,” R1 will outperform faster models.


Pick: Qwen3 Coder

Qwen3 Coder is purpose-built for software engineering tasks — code completion, refactoring, debugging, and generation across languages. It’s trained specifically on code-heavy data and optimized for developer workflows.

Good at: Code completion, bug fixing, refactoring, test generation, multi-file edits. Not ideal for: General conversation or non-code tasks (use V3.2). Pick over alternatives when: Code quality matters more than general knowledge. For mixed code-and-chat workflows, V3.2 or Kimi K2.5 may be more versatile.


Pick: Kimi K2.5

Kimi K2.5 was designed for agentic use. It has native tool-calling support, runs at 334 t/s (the fastest model we serve), and scores 50.2% on HLE when using tools — matching R1’s reasoning-only score.

The speed matters for agents. Each tool call is a round trip: the model generates a function call, the tool executes, the result goes back to the model. At 334 t/s and 0.31s TTFT, Kimi completes multi-step agent loops in seconds where slower models take minutes.

Good at: Tool use, function calling, multi-step task execution, fast iteration loops. Not ideal for: Pure reasoning without tools (R1 is better). Code-only tasks (Qwen3 Coder is more specialized). Pick over alternatives when: Your application involves tool calling, API interactions, or multi-step agent orchestration where speed compounds.


Pick: Llama 4 Scout

Llama 4 Scout is Meta’s mixture-of-experts multimodal model — 109B total parameters with 17 active experts. It handles text and images natively, making it the pick for tasks that require visual understanding alongside language.

Good at: Image description, visual Q&A, document understanding, chart interpretation. Not ideal for: Text-only tasks where you’re paying for vision capability you don’t use (use V3.2). Pick over alternatives when: Your input includes images. For text-only workloads, other models are more efficient.


Pick: Llama 3.1 8B

At 8 billion parameters, Llama 3.1 8B runs at ~200 t/s with approximately 0.2s time to first token. It’s the right choice for tasks where speed matters more than depth: intent classification, sentiment analysis, entity extraction, content filtering, and request routing.

Good at: Classification, tagging, extraction, routing decisions, simple Q&A, content moderation. Not ideal for: Complex reasoning, long-form generation, or tasks requiring deep world knowledge. Pick over alternatives when: You need results in under a second and the task is well-defined. Also ideal as the router model in a multi-model architecture.


Pick: GLM 4.7 Flash

GLM 4.7 Flash delivers competitive quality at fast inference speeds. When DeepSeek V3.2 is more capability than you need — simple conversations, basic summarization, FAQ bots — GLM 4.7 Flash gets the job done efficiently.

Good at: Simple chat, summarization, translation, basic Q&A. Not ideal for: Complex reasoning or tasks where benchmark-leading quality matters. Pick over alternatives when: You want good-enough quality with better speed and lower cost than the largest models.


Pick: MiniMax M2.5

MiniMax M2.5 handles long context windows natively. For workloads that involve ingesting large documents, long conversation histories, or extensive codebases, M2.5 maintains coherence across the full context.

Good at: Document analysis, long conversations, large-context summarization. Not ideal for: Short, simple tasks where context length is irrelevant (use Llama 8B or GLM Flash). Pick over alternatives when: Your input regularly exceeds what smaller-context models handle well.


Pick: Qwen3 235B

Qwen3 235B is a large mixture-of-experts model that competes across the full benchmark spectrum. When you need the highest possible quality and latency is not the primary constraint, Qwen3 235B delivers.

Good at: Broad capability across reasoning, knowledge, and generation. Strong multilingual support. Not ideal for: Latency-sensitive applications (large model, slower inference). Pick over alternatives when: You need top-tier quality and can tolerate higher latency. Good for batch processing and offline tasks.


Pick: BGE Large

BGE Large (BAAI General Embedding) is a well-tested embedding model for retrieval-augmented generation. It performs well on MTEB benchmarks and produces dense vectors suitable for semantic search, document retrieval, and clustering.

Good at: Semantic search, RAG pipelines, document similarity, clustering. Not ideal for: Generative tasks (it’s an embedding model, not a chat model). Pick over alternatives when: You need vector embeddings for search or retrieval. Pair it with a generative model for the full RAG pipeline.


What's your task?
|
+-- Need to understand images?
| YES --> Llama 4 Scout
|
+-- Need step-by-step reasoning? (math, logic, science)
| YES --> DeepSeek R1 (~30 t/s, but highest reasoning quality)
|
+-- Need tool calling / agent loops?
| YES --> Kimi K2.5 (334 t/s, native tool use)
|
+-- Need code generation / editing?
| YES --> Qwen3 Coder (purpose-built for code)
|
+-- Need embeddings for search/RAG?
| YES --> BGE Large
|
+-- Need sub-200ms response?
| YES --> Llama 3.1 8B (~200 t/s, 0.2s TTFT)
|
+-- Need long context (large documents)?
| YES --> MiniMax M2.5
|
+-- Need maximum quality, latency flexible?
| YES --> Qwen3 235B
|
+-- General purpose, good balance?
YES --> DeepSeek V3.2 (default choice)

You don’t need ten models to cover most workloads.

Llama 3.1 8B handles 60% of requests. Classification, routing, simple Q&A, extraction, content filtering. Fast and cheap.

DeepSeek V3.2 handles 30%. General chat, complex instructions, knowledge-intensive tasks. The reliable all-rounder.

Specialized models handle the last 10%. R1 for hard reasoning. Kimi K2.5 for agent loops. Qwen3 Coder for code. BGE Large for embeddings.

Start with Llama 8B + V3.2. Add specialists only when you have evidence that general models aren’t performing on specific task categories. Measure first, specialize second.


All models are available through a single OpenAI-compatible API. If you’re building a platform that needs LLM access for your users, see how per-key plans work.

Sources: Artificial Analysis Leaderboard · SWE-bench Leaderboard · Kimi K2.5 Benchmarks · DeepSeek V3.2 · HLE Leaderboard · MMLU-Pro Leaderboard · MTEB Leaderboard

Open-source models are production-ready. Here's the proof.

There’s a persistent assumption in the industry: open-source models are fine for experimentation, but production workloads need GPT-5 or Claude Opus. We run open-source models in production every day. Here’s what the benchmarks actually say.

We’re comparing 5 models across 5 metrics — the same models in every chart, no cherry-picking:

Open-source (available via our API): DeepSeek V3.2, DeepSeek R1, Kimi K2.5 Proprietary (reference): Claude Opus 4.6, GPT-5.4


Code quality: SWE-bench Verified (% resolved)

Section titled “Code quality: SWE-bench Verified (% resolved)”
Claude Opus 4.6
80.8%
GPT-5.4
~80.0%
Kimi K2.5
76.8%
DeepSeek V3.2
73.0%
DeepSeek R1
57.6%

Proprietary models lead here. Opus 4.6 and GPT-5.4 are within a point of each other at ~80%. Kimi K2.5 is 4 points behind at 76.8% — competitive but not leading. R1 is a reasoning model, not optimized for code.


Kimi K2.5 *
50.2%
DeepSeek R1
50.2%
GPT-5.4
41.6%
Claude Opus 4.6
40.0%
DeepSeek V3.2
39.3%

Open-source wins decisively. R1 hits 50.2% and Kimi K2.5 matches it with tool-use enabled (*without tools: 31.5%). Both beat Opus 4.6 (40%) and GPT-5.4 (41.6%). V3.2 is roughly at Opus level — it’s a general model, not a reasoning specialist.

*Kimi K2.5’s HLE score uses its agentic mode with tool access. This is how the model is designed to be used in production.


GPT-5.4
88.5%
Kimi K2.5
87.1%
DeepSeek V3.2
85.0%
DeepSeek R1
84.0%
Claude Opus 4.6
82.0%

GPT-5.4 leads narrowly at 88.5%, but Kimi K2.5 is 1.4 points behind and all three open-source models beat Opus 4.6. The gap across all 5 models is only 6.5 points — this benchmark is nearly saturated.


Kimi K2.5
334 t/s
GPT-5.4
~78 t/s
DeepSeek V3.2
~60 t/s
Claude Opus 4.6
46 t/s
DeepSeek R1
~30 t/s

Kimi K2.5 at 334 tok/s is in a different league — 4x faster than GPT-5.4, 7x faster than Opus 4.6. R1 is the slowest (expected — it’s a reasoning model producing chain-of-thought tokens).


Kimi K2.5
0.31s
GPT-5.4
~0.95s
DeepSeek V3.2
1.18s
DeepSeek R1
~2.0s
Claude Opus 4.6
2.48s

Lower is better. Kimi K2.5 responds 8x faster than Opus 4.6 and 3x faster than GPT-5.4. Even V3.2 beats both proprietary models. Opus 4.6 is the slowest model in this comparison.

Speed and TTFT measured on our production infrastructure. Claude and GPT-5.4 data from Artificial Analysis.


Code Reasoning Knowledge Speed Latency Kimi K2.5 DeepSeek V3.2 DeepSeek R1 Claude Opus 4.6 GPT-5.4
MetricWinnerOpen-sourceProprietaryGap
Code (SWE-bench)Opus 4.6Kimi 76.8%Opus 80.8%-4 pts
Reasoning (HLE)R1R1 50.2%GPT-5.4 41.6%+8.6 pts
Knowledge (MMLU-Pro)GPT-5.4Kimi 87.1%GPT-5.4 88.5%-1.4 pts
Speed (tok/s)Kimi K2.5334 t/sGPT-5.4 78 t/s4.3x faster
Latency (TTFT)Kimi K2.50.31sGPT-5.4 0.95s3x faster

Open-source wins 3 out of 5. Proprietary models lead on Code (by 4 points) and Knowledge (by 1.4 points). Open-source leads on Reasoning (by 8.6 points), Speed (by 4.3x), and Latency (by 3x).

Note: Kimi K2.5’s HLE score (50.2%) uses tool-augmented mode. Without tools it scores 31.5%. DeepSeek R1’s 50.2% is pure chain-of-thought reasoning without tools.


What “production-ready” actually means

Section titled “What “production-ready” actually means”
  1. Reliable enough. Consistent quality across thousands of requests.
  2. Fast enough. Kimi K2.5 at 334 tok/s and 0.31s TTFT. That’s real-time.
  3. Capable enough. Within 4 points of the best proprietary model on code, ahead on reasoning.
  4. Predictable. Versioned models that don’t change without warning.

Proprietary models change under you. Fine one day, different behavior the next. No changelog, no warning. Open-source models are versioned — DeepSeek V3.2 behaves the same tomorrow as today. You choose when to upgrade.

For production workloads, that predictability is worth more than a marginal quality edge on any single benchmark.


We serve open-source models through a single API. If you’re building a platform that needs LLM access for your users, see how per-key plans work.

Sources: Artificial Analysis Leaderboard · SWE-bench Leaderboard · Kimi K2.5 Benchmarks · DeepSeek V3.2 · OpenAI Pricing · Anthropic Pricing · HLE Leaderboard · MMLU-Pro Leaderboard

What it takes to build your own LLM inference platform

If you’re building a SaaS that needs to give users access to LLMs, you have two options: build the infrastructure yourself, or use a platform that does it for you. Here’s what “build it yourself” actually looks like.

This isn’t theoretical. We built this. Here’s every component, what it does, and what alternatives exist.

Before you write a single line of code, you need access to models.

Self-host on your own hardware: Buy GPUs, rent datacenter space, run the models yourself. Full control, best unit economics at scale — but massive upfront cost and you’re limited to the models you can afford to deploy. Running DeepSeek V3.2 requires multiple high-end GPUs. Running dozens of models? You’d need a data center.

Rent infrastructure: Use GPU clouds like Vast.ai, AWS, Hetzner, CoreWeave, or Lambda. No hardware to buy, but you still manage deployments, scaling, and failover. Costs add up fast — a single H100 runs $2-4/hr.

Use an inference provider: Sign agreements with DeepInfra, Together.ai, Fireworks, etc. who already have the models deployed. Pay per token, no GPU management. But you depend on their availability, pricing, and terms. If they change prices or drop a model, you need a plan B.

Mix: Most serious platforms end up here. Own hardware for high-volume models where the unit economics justify it, rented GPUs for burst capacity, and provider agreements for the long tail of models nobody runs enough to self-host.

Self-hosting dozens of models on your own is economically unrealistic. The real question is where to draw the line between own infra, rented compute, and providers.

If you self-host or rent GPUs, you need software to serve the models:

  • vLLM — most popular, good throughput, active community
  • TGI (Text Generation Inference) — Hugging Face’s solution, solid for single-model deployments
  • TensorRT-LLM — NVIDIA’s optimized engine, best raw performance but harder to set up
  • SGLang — newer, fast, good for structured generation

You’ll also need to handle model weights, quantization, scaling across GPUs, and failover when a node goes down. This is a full-time ops job.

Your users shouldn’t hit the inference backend directly. You need a proxy that:

  • Translates between API formats (OpenAI, Anthropic)
  • Routes requests to the right model/provider
  • Injects authentication
  • Handles retries and failover
  • Strips provider headers so users don’t know your backend

Options:

  • Build from scratch with Express/Fastify + http-proxy-middleware
  • Use an open-source gateway: LiteLLM, Portkey, Kong AI Gateway, MLflow Gateway
  • Use a managed gateway: Helicone, Braintrust, Promptlayer

Each has trade-offs. Open-source gateways give you control but you manage the deployment. Managed gateways are easier but add latency and cost.

Two layers:

User auth (dashboard login)

  • Firebase Auth, Auth0, Clerk, Supabase Auth, or roll your own
  • Supports email, Google, GitHub, wallet signatures

API key auth (inference requests)

  • Generate API keys per user
  • Validate on every request before proxying
  • Store key metadata (plan, rate limits, owner)

This is where it gets interesting for platforms. You need per-key plans — each key with its own rate limits and usage tracking. Most auth solutions don’t do this out of the box. You’ll need a custom key management layer.

Per-key rate limiting with at least:

  • RPM (requests per minute)
  • TPM (tokens per minute)
  • Budget caps (dollar amount per time window)

This needs to be enforced at the proxy layer, before the request hits the inference backend. Otherwise a single user can exhaust your GPU allocation.

Options:

  • Redis-based counters (most common)
  • Token bucket algorithms
  • Proxy-level enforcement (some gateways include this)

If you’re using per-key plans, each key needs its own set of limits. Not one global limit — individual limits per key.

You need to know:

  • How many tokens each key consumed (input + output)
  • What model was used
  • Cost per request
  • Aggregate usage per user, per day, per billing period

For subscription billing:

  • Stripe for card payments
  • Budget windows (e.g., $X per 8-hour period)
  • Automatic key revocation when subscription expires

For pay-as-you-go:

  • Credit balance per user
  • Deduct per request based on token count × model price
  • Top-up flow (Stripe, crypto, etc.)

For crypto payments:

  • USDC on a supported chain
  • On-chain transaction verification
  • Wallet connector in the dashboard (wagmi, viem, etc.)

This is a significant amount of code. Usage tracking alone requires intercepting every response to count tokens, calculating cost based on the model’s pricing, and storing it per key.

Your users need a web UI to:

  • Create and manage API keys
  • View usage per key (tokens, requests, cost)
  • Subscribe to plans or top up credits
  • See available models and pricing

Tech stack typically:

  • React/Next.js/Vue frontend
  • REST API backend
  • Real-time usage updates

For platforms (your users creating keys for their users), you also need a management API — programmatic key creation, plan assignment, usage queries.

Models change. New ones come out weekly. You need:

  • A catalog of which models you serve
  • Pricing per model (input/output cost per token)
  • Sync mechanism to update prices when providers change them
  • Display names, categories, tags for the dashboard
  • Cache pricing metadata (some models support prompt caching discounts)

This is an ongoing operational burden, not a one-time setup.

Your users need:

  • API reference (endpoints, request/response formats)
  • SDK examples (Python, Node.js, at minimum)
  • Authentication guide
  • Billing/usage documentation
  • Quick start guide

This is easily 20-30 pages of documentation that needs to stay current.

  • Health checks on the inference backend
  • Status page for users
  • Alerting when latency spikes or errors increase
  • Logging (but not logging prompt content — privacy)
  • Graceful degradation when a model or provider is down
  • Privacy policy
  • Data handling documentation
  • GDPR compliance if you serve EU users
  • Decision: do you store prompts? (You shouldn’t)
  • SOC 2 / ISO 27001 if targeting enterprise

ComponentOngoing maintenance
Inference backendHigh — scaling, failover, model updates
API proxyMedium — format changes, new providers
Auth + key managementLow
Per-key rate limitingLow
Usage tracking + billingMedium — edge cases, reconciliation
DashboardMedium — new features, UX
Model catalogHigh — weekly model updates
DocumentationMedium — keep current
MonitoringLow
Privacy/complianceLow

Building is the easy part. The hard part is what breaks with real users:

  • A provider changes their API format without warning. Your proxy returns 500s for 2 hours until you notice.
  • A model gets deprecated. Your users’ hardcoded model IDs stop working overnight.
  • Token counting has an off-by-one bug. You’ve been undercharging for 3 weeks. Your margin is gone.
  • A user finds a way to exceed rate limits through concurrent requests. Your inference bill spikes 10x in one afternoon.
  • Stripe webhook fails silently. A user’s subscription expired but their API key still works. Free inference for a month.
  • You push a billing update and break the usage tracking. Three days of missing data. Users open tickets.

Each of these has happened to us. We fixed them. The question is whether you want to fix them yourself, with your users waiting, or use a platform that already has.

You use an inference platform that already has all of this, create API keys for your users, and ship your product this week.


We built all of the above so you don’t have to. See how per-key plans work.