Skip to content

feat(opencode): add LiteLLM provider integration#29937

Open
RheagalFire wants to merge 2 commits into
anomalyco:devfrom
RheagalFire:feat/litellm-provider
Open

feat(opencode): add LiteLLM provider integration#29937
RheagalFire wants to merge 2 commits into
anomalyco:devfrom
RheagalFire:feat/litellm-provider

Conversation

@RheagalFire
Copy link
Copy Markdown

Issue for this PR

Closes #29935

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds LiteLLM as a built-in provider. Sets LITELLM_BASE_URL (and optionally LITELLM_API_KEY) to connect. Models are auto-discovered from the proxy's /v1/models endpoint at
startup, no manual config needed.

Since LiteLLM is a gateway (not a fixed provider), it's not in models.dev. The provider auto-seeds into the database when env vars are detected.

Files changed:

  • provider.ts: Custom loader with env var resolution, database seeding, and /v1/models discovery
  • schema.ts: Well-known litellm provider ID
  • sprite.svg / types.ts: Provider icon
  • en.ts / settings-providers.tsx / dialog-select-provider.tsx: UI strings and notes
Env var Description
LITELLM_BASE_URL Base URL of the LiteLLM proxy (e.g. http://localhost:4000)
LITELLM_API_KEY API key / master key for the proxy (optional if proxy has no auth)

Related: #29308, #6231, #14468

How did you verify your code works?

  1. Started LiteLLM proxy backed by Azure AI Foundry with claude-sonnet-4-6 and claude-opus-4-7
  2. Set LITELLM_BASE_URL + LITELLM_API_KEY env vars
  3. Ran TUI (bun dev), LiteLLM models auto-discovered and appear in model picker
  4. Sent messages, streaming works
  5. Tested tool calling (file listing), works through the proxy
  6. Switched between models (sonnet/opus), works
  7. Ran web UI (bun dev serve + bun run --cwd packages/app dev), provider visible in settings, chat works
  8. Tested disconnect/reconnect flow

Screenshots / recordings

ceb2-3aa7-47fd-b86f-e27af97bfe24-2.mp4

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@RheagalFire RheagalFire requested a review from adamdotdevin as a code owner May 29, 2026 22:48
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate/Related PRs Found:

  1. PR feat(opencode): add LiteLLM provider with auto model discovery #14468 - feat(opencode): add LiteLLM provider with auto model discovery

  2. PR fix: inject cache_control on content blocks for openai-compatible proxies to Anthropic backends (Bifrost, LiteLLM, Databricks) #25985 - fix: inject cache_control on content blocks for openai-compatible proxies to Anthropic backends (Bifrost, LiteLLM, Databricks)

  3. PR feat(opencode): add LLM provider fallback chain #26292 - feat(opencode): add LLM provider fallback chain

The most significant is PR #14468 - verify if it's the predecessor/duplicate of the current work or if it's a separate issue being addressed by PR #29937.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add LiteLLM proxy as a built-in provider

1 participant