{"slug": "i-got-tired-of-rewriting-ai-api-wrappers-so-i-built-a-gateway", "title": "I Got Tired of Rewriting AI API Wrappers, So I Built a Gateway", "summary": "A developer built Apiarium, a unified API gateway that abstracts multiple AI providers (OpenAI, Anthropic, and more) behind a single endpoint with normalized error handling and credit-based pricing. The project targets developers building side projects who want one API key and a predictable bill instead of managing multiple accounts and wrappers.", "body_md": "Every side project starts the same way.\n\n-Generate an OpenAI key.\n\n-Add it to `.env`\n\n.\n\n-Write a wrapper.\n\n-Realize I also need Claude.\n\n-Create another account.\n\n-Another API key.\n\n-Another billing dashboard.\n\nBefore the project even starts, I've already configured three different services.\n\nAt some point I thought why not just make this a proper API and host it publicly?\n\nThat's how Apiarium started.\n\nThey're great projects. But I wanted something more opinionated:\n\nMy target isn't teams running production AI infrastructure. It's developers building side projects who want one API key and a predictable bill.\n\n```\nClient\n   │\n   ▼\nApiarium\n   ├── /llm         → OpenAI, Anthropic (more coming)\n   ├── /image       → gpt-image-1 (more coming)\n   ├── /tts         → OpenAI TTS, ElevenLabs (soon)\n   └── /transcribe  → Whisper (more coming)\n```\n\n*More providers coming.\n\nAdding a new provider doesn't change the API contract.\n\nSame endpoints, same auth, more options.\n\nFrom the client's perspective, every provider looks exactly the same:\n\n```\n# GPT-4o-mini\ncurl -X POST https://api.apiarium.dev/llm \\\n  -H \"Authorization: Bearer YOUR_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"gpt-4o-mini\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello\"}]}'\n\n# Switch to Claude — same endpoint, same auth\ncurl -X POST https://api.apiarium.dev/llm \\\n  -H \"Authorization: Bearer YOUR_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"claude-haiku\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello\"}]}'\n```\n\n**Credits instead of per-model pricing.** Pricing by token across four providers is confusing. I landed on credits text generation costs 1–20 credits depending on the model, images cost 100, TTS costs 10 per 1,000 characters. One number, always visible.\n\n**Normalized error format.** OpenAI and Anthropic return completely different error structures. Every error from Apiarium looks the same regardless of which provider caused it:\n\n```\n{\n  \"error\": \"Rate limit exceeded. Try again in 30 seconds.\",\n  \"code\": \"rate_limit_exceeded\",\n  \"retry_after\": 30\n}\n```\n\n**Provider abstraction.** Every provider adapter returns the same internal response format before it's sent back to the client. That means adding a new provider is mostly implementing one adapter instead of changing the whole API.\n\nIf I started again, I'd build the provider abstraction first instead of adding providers one by one. Every new model taught me another edge case around streaming, token accounting, or error handling. Designing for those differences upfront would've saved me time.\n\nLaunched a few days ago. Still early, but the infrastructure is solid and every endpoint works.\n\nI'm mostly interested in whether this solves a real problem for other developers. If you've hit the same setup tax or think I'm solving the wrong problem entirely, I'd genuinely like to hear it.\n\nIf even one developer stops copy-pasting another `ai-utils.js`\n\nfile because of this, I'll call it a success.", "url": "https://wpnews.pro/news/i-got-tired-of-rewriting-ai-api-wrappers-so-i-built-a-gateway", "canonical_source": "https://dev.to/manolito99/i-got-tired-of-rewriting-ai-api-wrappers-so-i-built-a-gateway-58n5", "published_at": "2026-06-27 19:35:50+00:00", "updated_at": "2026-06-27 20:03:42.347475+00:00", "lang": "en", "topics": ["developer-tools", "ai-infrastructure", "large-language-models", "generative-ai"], "entities": ["Apiarium", "OpenAI", "Anthropic", "Claude", "GPT-4o-mini", "ElevenLabs", "Whisper"], "alternates": {"html": "https://wpnews.pro/news/i-got-tired-of-rewriting-ai-api-wrappers-so-i-built-a-gateway", "markdown": "https://wpnews.pro/news/i-got-tired-of-rewriting-ai-api-wrappers-so-i-built-a-gateway.md", "text": "https://wpnews.pro/news/i-got-tired-of-rewriting-ai-api-wrappers-so-i-built-a-gateway.txt", "jsonld": "https://wpnews.pro/news/i-got-tired-of-rewriting-ai-api-wrappers-so-i-built-a-gateway.jsonld"}}