Model providers: OpenAI/xAI/Ollama + run several at once #237

Merged
justin merged 1 commits from multi-provider-openai-xai-ollama into main 2026-06-09 18:39:21 -04:00
Owner

Extends the #215 abstraction so you can use OpenAI, xAI, and Ollama and configure several at once.

  • OpenAICompatibleLLMProvider / OpenAICompatibleEmbeddingProvider — one impl (official openai SDK) covers OpenAI, xAI (api.x.ai/v1), Ollama (…:11434/v1), OpenRouter, etc. (differ only by base_url/key/model).
  • Registry: build_llm_providers() returns every provider whose creds are set → run several concurrently; get_llm_provider(name) selects by name, falling back to DEFAULT_LLM_PROVIDER, then Null.
  • Per-provider env (ANTHROPIC_*/OPENAI_*/XAI_*/OLLAMA_*) + DEFAULT_LLM_PROVIDER/DEFAULT_EMBEDDING_PROVIDER; documented in .env.example. Defaults keep AI off.
  • Embeddings now have real backends (OpenAI/Ollama), still separate from the LLM.

Tests: multi-provider selection, default resolution, disabled-without-creds, null fail-loud. 87 passed. Relates to #215.

🤖 Generated with Claude Code

Extends the #215 abstraction so you can use **OpenAI, xAI, and Ollama** and **configure several at once**. - `OpenAICompatibleLLMProvider` / `OpenAICompatibleEmbeddingProvider` — one impl (official `openai` SDK) covers OpenAI, xAI (`api.x.ai/v1`), Ollama (`…:11434/v1`), OpenRouter, etc. (differ only by base_url/key/model). - **Registry**: `build_llm_providers()` returns every provider whose creds are set → run several concurrently; `get_llm_provider(name)` selects by name, falling back to `DEFAULT_LLM_PROVIDER`, then Null. - Per-provider env (`ANTHROPIC_*`/`OPENAI_*`/`XAI_*`/`OLLAMA_*`) + `DEFAULT_LLM_PROVIDER`/`DEFAULT_EMBEDDING_PROVIDER`; documented in `.env.example`. Defaults keep AI off. - Embeddings now have real backends (OpenAI/Ollama), still separate from the LLM. Tests: multi-provider selection, default resolution, disabled-without-creds, null fail-loud. **87 passed.** Relates to #215. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
justin added 1 commit 2026-06-09 18:39:20 -04:00
Extends the #215 abstraction:
- OpenAICompatibleLLMProvider / OpenAICompatibleEmbeddingProvider — one impl (via
  the official openai SDK) covers OpenAI, xAI (api.x.ai/v1), Ollama
  (…:11434/v1), OpenRouter, etc.; they differ only by base_url, key, and model.
- Registry factory: build_llm_providers() / build_embedding_providers() return
  every provider whose credentials are configured, so you can run several
  concurrently. get_llm_provider(name)/get_embedding_provider(name) select by
  name, falling back to default_*_provider, then Null.
- Per-provider env config (ANTHROPIC_*, OPENAI_*, XAI_*, OLLAMA_*) +
  DEFAULT_LLM_PROVIDER / DEFAULT_EMBEDDING_PROVIDER; documented in .env.example.
  Defaults keep AI off (empty registry).

Embeddings now have real backends (OpenAI/Ollama), still separate from the LLM
since Anthropic offers no embeddings endpoint. Tests cover multi-provider
selection, default resolution, disabled-without-credentials, and null fail-loud.
Full suite 87 passed.

Relates to #215.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Justin Paul <justin@jpaul.me>
justin merged commit ceafb299d6 into main 2026-06-09 18:39:21 -04:00
justin deleted branch multi-provider-openai-xai-ollama 2026-06-09 18:39:21 -04:00
Sign in to join this conversation.