AnyAPI is a self-hosted API server backed by 9 free AI providers. Start it once, call it from Python — build chatbots, automation, CLI tools, or anything that needs language AI.
what you can build
Run it as a local service, call it from any Python process. The built-in CLI is just one example client.
Wire your bot handler to DaemonClient.send_request("ask", …). Free AI replies with no per-message cost.
Build a code-review tool, a doc generator, a commit-message writer — your own prompt logic on top of the API.
Pipe git diff, file contents, or any text. Get structured AI output back in plain Python — no SDK boilerplate.
Route requests across providers, compare outputs, chain reasoning steps — all over a stable local JSON-RPC interface.
integration
Import DaemonClient, point it at the socket, iterate events. That's the whole API surface.
import asyncio from anyapi.cli.client import DaemonClient from pathlib import Path async def ask(prompt: str, provider: str = "duckduckgo") -> str: sock = Path.home() / f".local/share/anyapi/{provider}_daemon.sock" client = DaemonClient(sock) reply = [] async for event in client.send_request("ask", {"prompt": prompt}): if event.event == "token": reply.append(event.data) elif event.event in ("done", "error"): break return "".join(reply) # Summarise a file, review a diff, answer a question… answer = asyncio.run(ask("Explain this diff: " + open("changes.diff").read())) print(answer)
# Or pipe it from the shell — the built-in CLI is just another client $ git diff HEAD~1 | anyapi "Review this diff for bugs" $ cat main.py | anyapi "Summarise what this does" $ anyapi "Generate a commit message for: feature/auth-refactor"
api reference
The daemon listens on ~/.local/share/anyapi/<provider>_daemon.sock. Send a newline-delimited JSON request; receive a stream of events.
// Request {"id": "uuid", "method": "ask", "params": {"prompt": "Hello!"}} // Response stream {"id": "uuid", "event": "status", "data": {"stage": "typing"}} {"id": "uuid", "event": "token", "data": "Hello"} {"id": "uuid", "event": "token", "data": " there"} {"id": "uuid", "event": "done", "data": {"text": "Hello there", "chars": 11}}
| Method | Params | Description |
|---|---|---|
| ask | prompt: str | Send a prompt — streams token events, then done |
| new_chat | — | Start a fresh conversation in the browser |
| save_conversation | name?: str | Save the current conversation to disk |
| load_conversation | id: str | Load a saved conversation (prefix match) |
| list_conversations | — | List all saved conversations |
| current_conversation | — | Return full turn history for the active conversation |
| stats | — | Rate-limit counters and session info |
| health | — | Browser and provider health check |
| reload_auth | — | Re-inject cookies without restarting the daemon |
| shutdown | — | Gracefully shut down the daemon |
providers
No accounts, no API keys, no setup — for the five instant providers. DeepSeek, ChatGPT, Gemini, and Qwen need a one-time cookie export (~5 min).
Zero setup, zero login
Microsoft Copilot
Open-source models
Web-search grounded
You.com chat
Best free reasoning
OpenAI GPT-4o
Google Gemini
Alibaba Qwen
architecture
Start one daemon per provider. Connect as many clients as you like — your Python script, a bot, a REPL — all sharing the same browser session.
get started
No accounts. No keys. No .env file. Requires Python 3.10+ and ~150 MB for the Chromium download.