Goal
Abstract the provider layer so the system can route requests to multiple LLM providers through a unified interface. This turns the project from "OpenAI wrapper" into a lightweight AI Gateway.
Current State
provider.ts hardcodes OpenAI SDK. Only OpenAI-compatible APIs work.
Tasks
Smart Router (extends #6)
Why
This is the architecture behind services like OpenRouter, LiteLLM, and AI Gateway services. Building it yourself gives you deep understanding of how LLM gateways work, API differences between providers, and the adapter pattern in practice.
Learning Points
- Adapter pattern: wrapping incompatible interfaces behind a common contract
- Provider-specific streaming formats and how to normalize them
- Cost optimization strategies for multi-model systems
- Configuration-driven architecture (add new provider without code changes)
Goal
Abstract the provider layer so the system can route requests to multiple LLM providers through a unified interface. This turns the project from "OpenAI wrapper" into a lightweight AI Gateway.
Current State
provider.tshardcodes OpenAI SDK. Only OpenAI-compatible APIs work.Tasks
LLMProviderinterface:chatComplete(params)andchatStream(params)with unified input/output typesOpenAIProvider— wrap current logicClaudeProvider— Anthropic SDK adapter (messages API, different streaming format)DeepSeekProvider— OpenAI-compatible but with provider-specific quirksserver/.envdefines available providers with their API keys and base URLsChatResponse/StreamChunktypeSmart Router (extends #6)
Why
This is the architecture behind services like OpenRouter, LiteLLM, and AI Gateway services. Building it yourself gives you deep understanding of how LLM gateways work, API differences between providers, and the adapter pattern in practice.
Learning Points