# pyllmrouter

> Python library + CLI giving one thread-safe, async-capable chat interface (`create_chat()`, `chat()`, `chat_stream()`, `achat()`) (plus text embeddings through Gemini, Ollama and llama.cpp) over eight LLM backends: Claude Agent SDK (OAuth token / CLI login), Anthropic API, Gemini API, Antigravity CLI (`agy`), OpenAI Codex (official Python SDK or CLI), Ollama and llama.cpp. When no provider is set it auto-detects the first usable one in a fixed priority order; when a provider is set it never probes.

Install: `pip install "pyllmrouter[all] @ git+https://github.com/fortalbrz/pyllmrouter.git"` (Python >= 3.10; extras: claude-agent, anthropic, gemini, codex, ollama, all).

Embeddings: `create_embedder()` / `embed()`; capable providers (auto-detection order): gemini > ollama > llamacpp.

Provider priority (auto-detection only): claude-agent-token > claude-agent-login > anthropic > gemini > antigravity > codex > ollama > llamacpp.

## Docs

- [README](README.md): install, provider guides (incl. Antigravity `agy` and Codex sign-in tutorials), API, concurrency/async, CLI, environment variables, recipes, troubleshooting
- [Full machine-oriented reference](llms-full.txt): every public symbol, selection rules, concurrency contract, env vars, error types in one file
- [Provider catalogue (JSON)](docs/providers.json): ids, aliases, auth, env vars, install commands (same as `pyllmrouter describe`)
- [Agent / contributor rules](AGENTS.md): layout, how to add a provider, quality gates

## Code

- [src/pyllmrouter/registry.py](src/pyllmrouter/registry.py): provider names, priority order, probing, auto-detection, `create_chat`, async helpers
- [src/pyllmrouter/base.py](src/pyllmrouter/base.py): `BaseChat` contract (history, per-chat turn lock, retries, streaming, async API)
- [src/pyllmrouter/bridge.py](src/pyllmrouter/bridge.py): sync<->async iteration bridges (cancellation-safe)
- [src/pyllmrouter/providers/](src/pyllmrouter/providers/): one module per backend
- [src/pyllmrouter/cli.py](src/pyllmrouter/cli.py): `pyllmrouter providers|detect|describe|ask`

## Optional

- [Tests](tests/): fakes for every backend plus real child processes; no network or credentials needed
