Switch between OpenAI, Gemini and AWS Bedrock with one environment variable and zero code changes.
Role
Software Developer, Full-Stack & AI
Domain
LLM infrastructure
Stack
Python
OpenAI
Google Gemini
AWS Bedrock Converse API
# Multi-provider LLM platform
Jay Gadhiya. Vibgyor Technologies, Oct 2024 to now. Software Developer, Full-Stack & AI.
Switch between OpenAI, Gemini and AWS Bedrock with one environment variable and zero code changes.
## Problem
Code that calls one LLM vendor directly ties its cost and reliability to that vendor, and vendor pricing and capabilities keep changing.
## Approach
- Designed one interface over OpenAI, Google Gemini and AWS Bedrock (through the Converse API).
- Routed every call site through that interface, so none of them names a provider.
- Normalised each provider's response into the same shape before the product uses it.
Architecture diagram: Application call sites send every request to one LLM interface and never name a provider. One environment variable picks OpenAI, Google Gemini or AWS Bedrock (through the Converse API), with non-critical tasks sent to cheaper models. Each response is normalised into the same shape before the product uses it.
## Key decisions
- **Choose the provider with one environment variable.** Changing vendors is a configuration change with zero code changes.
- **Send non-critical tasks to cheaper models.** Cost follows how much a task matters, and call sites stay the same.
- **Keep vendor details out of call sites.** Pricing and capabilities change often, so provider code lives in one place.
## Result
Switching providers is a config change, application code stays the same, and cheaper models handle the non-critical work.
## Stack
Python, OpenAI, Google Gemini, AWS Bedrock Converse API
Write-up: [I Asked 3 LLMs for JSON. I Got 3 Kinds of “JSON”.](https://medium.com/@gadhiyajay7676/i-asked-3-llms-for-json-i-got-3-kinds-of-json-794fd969289f)
Page: https://jaygadhiya.com/work/multi-provider-llm-platform/
Contact: hello@jaygadhiya.com
Read the write-up
One grading request, three providers. The responses are illustrative.