Prompt
I'm building an app with multiple model providers — what infra should I use?
Latest observation
If you’re building an app that may use multiple model providers (OpenAI, Anthropic, Google, etc.), the best infra is usually a provider-agnostic LLM gateway / orchestration layer in front of the model APIs, plus standard app infrastructure around it.
Recommended infra pattern
1) Put a thin AI gateway in your backend
Use a service that:
- abstracts provider-specific APIs behind one internal interface
- handles retries, fallbacks, routing, and timeouts
- normalizes responses, streaming, and errors
- logs usage and cost by provider/model
This can be:
- self-built in your backend
- or an existing gateway/orchestration platform
Common responsibilities:
- model selection
- prompt/template management
- rate limit handling
- request/response tracing
- safety moderation
- cost tracking
- fallback when one provider fails
2) Keep app state separate from model calls
Use your normal cloud infra for the rest:
- API/backend: Node.js / Python / Go service
- DB: Postgres for users, sessions, conversations, config
- Cache: Redis for rate limits, session state, prompt caching
- Queue: SQS / RabbitMQ / Pub/Sub for async jobs
- Object storage: S3/GCS for files, uploads, transcripts
- Vector DB: only if you need retrieval/RAG
- Postgres + pgvector is a good default
- Pinecone/Weaviate/Qdrant if you need managed scale
3) Add observability from day one
You’ll want:
- per-provider latency
- token usage
- cost by endpoint/user/org
- error rates
- fallback counts
- prompt/response traces
Tools:
- OpenTelemetry
- Datadog / Grafana / Prometheus
- LLM-specific tracing tools if useful
Best infra options by stage
MVP
If you’re early:
- Backend: a single app server
- DB: Postgres
- Cache: Redis
- AI layer: simple internal wrapper around providers
- Deploy: one cloud (AWS/GCP/Azure) or serverless
This is usually enough unless you already need complex routing.
Growing product
When you need reliability and provider switching:
- add an AI gateway service
- use feature flags/config to choose models by user/org/use case
- centralize prompt management
- add queues for long-running jobs
- add observability + cost controls
Enterprise / multi-team
If you have many teams or workloads:
- separate control plane (policies, routing, auth, cost rules)
- separate data plane (actual inference requests)
- enforce:
- provider allowlists
- model approval
- PII filtering
- audit logs
- regional routing / data residency
Build vs buy
Build it yourself if:
- you have only a few model integrations
- you want maximum control
- your team can maintain provider adapters
Use an existing layer if:
- you want faster time-to-market
- you need fallback/load balancing across models
- you expect many model providers
Examples of categories:
- LLM gateways
- model routers
- prompt management/orchestration tools
- observability platforms
Practical default stack
A solid default stack looks like:
- Frontend: web/mobile app
- Backend: API service
- Auth: Auth0 / Cognito / Clerk
- DB: Postgres
- Cache: Redis
- Async: queue
- AI gateway: internal wrapper or dedicated gateway service
- Vector store: pgvector if needed
- Logging/metrics/tracing: OpenTelemetry + Datadog/Grafana
- Secrets: cloud secret manager
- Deploy: containerized on ECS/Kubernetes/Cloud Run
A simple rule of thumb
If your app will use more than one provider, don’t let provider SDKs leak into your product code everywhere.
Create one internal AI interface and make all provider-specific logic live below it.
That gives you:
- portability
- easier testing
- lower vendor lock-in
- simpler failover
- better cost control
If you want, I can give you a recommended stack for your specific situation (MVP vs production, team size, cloud, RAG or no RAG, latency-sensitive or not).