๐ฆ๐๐ผ๐ฝ ๐๐ถ๐ด๐ต๐๐ถ๐ป๐ด ๐ช๐ถ๐๐ต ๐๐ ๐๐ฃ๐๐
I used OpenAI, Claude, and local models. My code became a mess. I struggled with API keys and error handlers.
I tried big libraries. They were too complex. I tried one big function. It grew too long.
I needed a better way.
I built a thin adapter layer. I focused on four goals:
- Send messages.
- Get responses.
- Handle errors.
- Log costs.
I created one base interface. Each AI provider gets its own adapter. Your app only talks to the interface. It does not know which provider is behind it.
This pattern works for most cases. It has limits:
- Tool calling uses different schemas.
- Vision formats vary.
- Streaming differs by provider.
My advice:
- Start with adapters on day one.
- Write integration tests for each provider.
- Version your interface.
Keep your code clean.
How do you handle your AI calls?