Free AI API Code: Build Your Own LLM Gateway with FastAPI (Open Source)
Want one single API that can talk to many AI models? This free open-source project does exactly that. It is called LLM Gateway — a small Python (FastAPI) server that sits in front of AI providers like OpenAI, OpenRouter, Groq or a local Ollama, and gives you one OpenAI-style address for all of them. It also has API-key login, rate limiting, automatic retries, and a live dashboard that shows requests, tokens, cost and speed. Best part: it runs fully offline with a built-in demo (mock) provider, so you can test everything without any paid API key. What you need: Python installed on your computer. That is all. STEP 1 — Download and run the code git clone https://github.com/nisarahmad78/llm-gateway.git cd llm-gateway python -m venv .venv source .venv/bin/activate pip install -r requirements.txt cp .env.example .env uvicorn app.main:app --port 8000 Now open these in your browser: Dashboard: http://localhost:8000/ API docs: http://localhost:8000/docs Health check: http://localhost:8000/healt...