{"slug": "i-built-an-openai-compatible-gateway-to-control-llm-costs", "title": "I Built an OpenAI-Compatible Gateway to Control LLM Costs", "summary": "An indie developer built CostLLM, an OpenAI-compatible API gateway that sits between code and LLM providers to control costs. The gateway offers per-project spending visibility, cost caps per feature, and rate limit management without vendor lock-in. It supports models like deepseek-v4-flash, deepseek-v4-pro, deepseek-chat, and deepseek-reasoner.", "body_md": "As an indie developer building AI products, I kept hitting the same wall: **how do I control LLM costs without vendor lock-in?**\n\nDirect API keys meant zero visibility into per-project spending. Month-end surprise bills. No way to cap costs per feature. Rate limit headaches.\n\nSo I built **CostLLM** — an OpenAI-compatible API gateway that sits between your code and the LLM provider.\n\n```\n# Before\nclient = OpenAI(api_key=\"sk-proj-...\")\n\n# After\nclient = OpenAI(\n    base_url=\"https://api.costllm.ai/v1\",\n    api_key=\"YOUR_COSTLLM_API_KEY\"\n)\n```\n\n| Model | Type |\n|---|---|\n| deepseek-v4-flash | Fast chat |\n| deepseek-v4-pro | Complex reasoning |\n| deepseek-chat | General purpose |\n| deepseek-reasoner | Deep analysis |\n\nBuilding a production API gateway taught me a lot about concurrency, streaming, error handling, and payment webhooks. The hardest part wasn't the code — it was designing a pricing model that works for both free users and growing teams.\n\nI'd love feedback from other developers working with LLM APIs — especially around cost visibility, key management, and what you'd want from a gateway.", "url": "https://wpnews.pro/news/i-built-an-openai-compatible-gateway-to-control-llm-costs", "canonical_source": "https://dev.to/qaz1214430044/i-built-an-openai-compatible-gateway-to-control-llm-costs-2ppm", "published_at": "2026-07-15 15:24:59+00:00", "updated_at": "2026-07-15 15:42:06.130259+00:00", "lang": "en", "topics": ["developer-tools", "ai-infrastructure", "ai-tools", "large-language-models"], "entities": ["CostLLM", "OpenAI", "deepseek"], "alternates": {"html": "https://wpnews.pro/news/i-built-an-openai-compatible-gateway-to-control-llm-costs", "markdown": "https://wpnews.pro/news/i-built-an-openai-compatible-gateway-to-control-llm-costs.md", "text": "https://wpnews.pro/news/i-built-an-openai-compatible-gateway-to-control-llm-costs.txt", "jsonld": "https://wpnews.pro/news/i-built-an-openai-compatible-gateway-to-control-llm-costs.jsonld"}}