cd /news/ai-infrastructure/building-production-ai-systems-part-… · home topics ai-infrastructure article
[ARTICLE · art-71527] src=dev.to ↗ pub= topic=ai-infrastructure verified=true sentiment=· neutral

Building Production AI Systems (Part 3)

An engineer building production AI systems with OpenRouter shares lessons on handling provider failures, observability, and streaming resilience. The developer emphasizes that users blame the application, not the provider, when AI features break, and recommends standardized error handling, request IDs, and timeout limits.

read4 min views2 publishedJul 24, 2026

Running OpenRouter in Production: What Breaks, What Works, and What I’d Do Differently

Getting an LLM to respond to your first prompt is easy.

Keeping it reliable in production?

That’s where things become interesting.

One thing I’ve learned building software is that users don’t care whose fault it is when something breaks.

If your AI feature fails because OpenAI is down… Or Claude is rate-limited…

Or your network connection decides to disappear for five seconds…

Your users won’t blame the provider.

They’ll blame your application.

That’s why integrating an AI model isn’t enough.

You need to engineer for failure, lets talk about how.

One of the biggest advantages of OpenRouter is that it standardizes responses from different providers.

Without it, you often end up writing provider-specific error handling.

typescript if (provider === “openai”) { …

}

if (provider === “anthropic”) {

}

if (provider === “google”) {

… } That gets messy very quickly.

With OpenRouter, your application talks to one API contract.

Which means your error handling becomes predictable.

typescript

try {
const response = await client.chat.completions.create({…});
} catch (error) {
logger.error(error);
}

Simple.

Your code shouldn’t care which provider failed.

It should care how your application responds when one does.

One mistake I see quite often is developers only logging the error message.

That’s rarely enough.

When something fails in production, you want context.

Log things like:

A single log entry should tell you the complete story without having to reproduce the issue.

Future you will appreciate it.

Imagine a customer reports:

“The AI stopped working around 2 PM.”

Without observability, you’re guessing.

Was it your backend?

OpenRouter?

Claude?

Gemini?

A timeout?

A deployment?

Good observability removes the guesswork.

OpenRouter provides request tracking that allows you to match requests from your application with what happened inside their dashboard.

Instead of spending hours wondering where things went wrong, you can trace a single request from your backend logs all the way through the gateway.

That’s incredibly valuable once real users are involved.

Request IDs are underrated

Every request should have an identity.

Whether you’re using OpenRouter’s request identifiers or generating your own correlation IDs, always include them in your logs.

Imagine one user reports:

My response never arrived.

Without a request ID, you’re searching through thousands of log entries.

With one, you can immediately trace:

Production debugging becomes dramatically easier.

Streaming isn’t always as straightforward as it looks

Streaming responses make AI applications feel much faster.

Instead of waiting ten seconds for a complete answer, users start seeing words appear almost immediately.

Great user experience.

But there’s a catch.

Not every provider streams responses in exactly the same way.

Although OpenRouter normalizes much of this behavior, you’ll still want to build frontend parsers that are resilient.

Don’t assume every chunk arrives perfectly.

Don’t assume every event contains text.

Don’t assume the connection won’t terminate unexpectedly.

Your frontend should gracefully handle incomplete streams instead of crashing halfway through a response.

Timeouts are not optional

One of the easiest ways to create a poor user experience is to let requests hang forever.

Sometimes providers are slow.

Sometimes networks are unreliable.

Sometimes things simply break.

Your application should know when to stop waiting.

Set reasonable timeout limits.

If a request takes too long, cancel it. Your users would rather receive a helpful message after fifteen seconds than stare at an infinite spinner.

An application that knows when to give up usually feels faster than one that waits forever.

This is one of my favourite engineering principles.

Just because one provider fails doesn’t mean your feature should disappear completely.

Imagine your primary reasoning model becomes unavailable.

Instead of returning:

Something went wrong.

Why not automatically switch to a faster fallback model?

Maybe the answer isn’t quite as detailed.

Maybe it isn’t as creative.

But your user still gets a response.

That’s infinitely better than an error screen.

Graceful degradation isn’t about perfection.

It’s about maintaining functionality when perfection isn’t possible.

Build retries carefully

Retries sound simple.

Until they aren’t.

If a request fails because of a temporary network issue, retrying makes sense.

If it fails because the provider is overloaded, retrying after a short delay might work.

But if the request is invalid?

Retrying it five times won’t magically fix bad input.

A good retry strategy should:

Retries should improve reliability.

Not create more traffic.

Final thoughts One thing AI development has taught me is that choosing the right model is only a small part of building reliable applications.

The real challenge is designing systems that continue working when models slow down, providers become unavailable, or networks become unreliable.

Because eventually…

Something will fail.

The question isn’t whether it happens.

The question is whether your users notice.

If they don’t, you’ve probably built your system well. Enjoying the series? Let me know in the comments.

Ooh and do not forget to connect with me so you do not miss out on the next parts of the series.

── more in #ai-infrastructure 4 stories · sorted by recency
── more on @openrouter 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/building-production-…] indexed:0 read:4min 2026-07-24 ·