GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(opencode): add LiteLLM provider with auto model discovery by balcsida · Pull Request #14468 · anomalyco/opencode

Conversation

@balcsida

@balcsida balcsida commented Feb 20, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #13891

Type of change

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

What does this PR do?

Adds a native litellm provider that auto-discovers models from a LiteLLM proxy at startup. Previously users had to manually define every model in opencode.json — now setting LITELLM_API_KEY and LITELLM_HOST is enough.

Discovery: Fetches /model/info for rich metadata (pricing, limits, capabilities). Falls back to the standard /models endpoint for older LiteLLM versions or non-LiteLLM OpenAI-compatible proxies.

What gets mapped from /model/info:

  • Per-token pricing → per-million-token (including over-200k tier)
  • Context/output limits
  • Capabilities: reasoning, vision, PDF, audio, video, tool calling
  • Temperature support via supported_openai_params
  • Interleaved thinking inference for Claude/Anthropic models

Reasoning transforms: Claude models behind LiteLLM get thinking budget variants, other models get reasoningEffort. This prevents false-positive reasoning param injection for aliased models (e.g. o3-custom → Mistral).

Files changed:

  • litellm.ts (new): Discovery module — fetches, parses, maps model metadata
  • provider.ts: Seeds litellm provider from env vars; custom loader calls discovery and injects models (user config takes precedence)
  • transform.ts: LiteLLM-specific reasoning variant logic
  • llm.ts: Adds explicit providerID === "litellm" to proxy detection
Env var Description Default
LITELLM_API_KEY API key for the proxy —
LITELLM_HOST Base URL of the proxy http://localhost:4000
LITELLM_BASE_URL Alias for LITELLM_HOST —
LITELLM_CUSTOM_HEADERS JSON string of extra headers {}
LITELLM_TIMEOUT Discovery timeout in ms 5000

Builds on ideas from #13896 (fallback endpoint, over-200k pricing, temperature detection) and #14277 (clean fallback chain). Supersedes my earlier #14202 which was auto-closed for not following the PR template.

How did you verify your code works?

  1. Set LITELLM_API_KEY + LITELLM_HOST pointing to a running LiteLLM proxy
  2. Run opencode — LiteLLM models appear in model picker
  3. Select a model and send a message — streaming works
  4. Test aliased reasoning model (e.g. o3-custom → Mistral) — reasoning params NOT injected
  5. Test actual Claude reasoning model — thinking variants work
  6. Test without proxy running — graceful fallback, provider hidden
  7. Test with older proxy (no /model/info) — falls back to /models with sensible defaults

Screenshots / recordings

N/A — no UI changes

Checklist

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

alvarosanchez, espetro, d0b3rm4n, juan-abia, pguilmette, jcushman, johnie, j3k0, mikew, ChananM, and 37 more reacted with thumbs up emoji sjakobs, PowerToThePeople111, saberebrn, carlosz1986, bartlettroscoe, and conorsch reacted with heart emoji kkugot, juan-abia, johnie, carlosz1986, saberebrn, redis-adjoe, AyaAkl25, shubh-adjoe, RossBogel, BthaBro, and bartlettroscoe reacted with rocket emoji thoroc, johnie, carlosz1986, saberebrn, redis-adjoe, AyaAkl25, RossBogel, PowerToThePeople111, and NikBeastDeve reacted with eyes emoji
All reactions
  • 👍 47 reactions
  • ❤️ 6 reactions
  • 🚀 11 reactions
  • 👀 9 reactions
@github-actions

github-actions Bot commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

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

Based on my search, I found two related PRs that are NOT duplicates but are closely related:

  1. PR feat(opencode): add dynamic model fetching for OpenAI-compatible provider #14277: feat(opencode): add dynamic model fetching for OpenAI-compatible provider

    • Related because the current PR builds on ideas from this PR (clean fallback chain mentioned in description)
  2. PR feat(opencode): add auto loading models for litellm providers #13896: feat(opencode): add auto loading models for litellm providers

    • Related because the current PR explicitly builds on ideas from this PR (fallback endpoint, over-200k pricing, temperature detection mentioned in description)

These PRs appear to be related work in the same area but are separate features. PR #14468 (the current PR) is a distinct, more comprehensive implementation of the LiteLLM provider with auto-discovery, and it references these earlier related PRs rather than duplicating them.

No duplicate PRs found.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@balcsida
balcsida force-pushed the feat/litellm-support branch from d4a5701 to 1e2b913 Compare February 20, 2026 16:52
alexyaroshuk
alexyaroshuk reviewed Feb 20, 2026
View reviewed changes
Comment thread packages/opencode/src/provider/litellm.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/provider/provider.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@balcsida
balcsida requested a review from adamdotdevin as a code owner February 20, 2026 20:16
@balcsida
balcsida force-pushed the feat/litellm-support branch 2 times, most recently from 54cedd2 to d3e6960 Compare February 21, 2026 21:42
@balcsida
balcsida requested a review from alexyaroshuk February 21, 2026 21:43
@alexyaroshuk

alexyaroshuk commented Feb 22, 2026

Copy link
Copy Markdown
Contributor

lgtm, but test fails. check e2e. this test fails:
e2e/projects/projects-switch.spec.ts:49:1 › switching back to a project opens the latest workspace session

Did you try testing locally? bun test:e2e:local

balcsida, neronlux, and juan-abia reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@balcsida

balcsida commented Feb 22, 2026

Copy link
Copy Markdown
Author

@alexyaroshuk, yes, sorry, fixed all the tests

alexyaroshuk, kkugot, neronlux, and juan-abia reacted with thumbs up emoji kkugot reacted with rocket emoji
All reactions
  • 👍 4 reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@balcsida
balcsida force-pushed the feat/litellm-support branch 5 times, most recently from bf8b1e8 to 7dc5277 Compare February 25, 2026 20:41
@kkugot

kkugot commented Feb 26, 2026

Copy link
Copy Markdown

👍

balcsida and juan-abia reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@balcsida

balcsida commented Feb 26, 2026

Copy link
Copy Markdown
Author

@alexyaroshuk, may I have your blessing on this? 🥺

juan-abia reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexyaroshuk

alexyaroshuk commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

@adamdotdevin can this one get a look?

balcsida, d0b3rm4n, kkugot, and juan-abia reacted with heart emoji
All reactions
  • ❤️ 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Feb 27, 2026
📊 AI CLI 工具社区动态日报 2026-02-27 duanyytop/agents-radar#20
Closed
feat(opencode): send x-opencode-session header for all providers #15520
Closed
@kkugot

kkugot commented Mar 4, 2026

Copy link
Copy Markdown

:shipit: maybe?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ELBouslama

ELBouslama commented Mar 6, 2026

Copy link
Copy Markdown

@alexyaroshuk @adamdotdevin any luck to get it merged soon ?

FarhadF, maazamalik, parid0kht, balcsida, kkugot, espetro, standuprey, juan-abia, slumbi, RossBogel, and PowerToThePeople111 reacted with rocket emoji
All reactions
  • 🚀 11 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Mar 9, 2026
feat: auto-detect local Ollama models #16653
Closed
2 tasks
@kkugot

kkugot commented Mar 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

@balcsida please rebase, there are some conflicts now. @alexyaroshuk @adamdotdevin could you review please? This will make so many opencode users in enterprise world very happy. Thanks!

juan-abia, jamie-dit, and PowerToThePeople111 reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@balcsida
balcsida force-pushed the feat/litellm-support branch from b232351 to 1ef13b8 Compare March 13, 2026 11:38
@balcsida

balcsida commented Mar 13, 2026

Copy link
Copy Markdown
Author

Hey @kkugot

Thanks for the ping, I rebased the branch and fixed the conflicts, but dev currently fails, so tests for this PR will fail as well.

While I understand how this feature is a very nice to have in an enterprise environment (it is exactly the same reason why I sent this PR - we would like to use this as well), please kindly don't spam alexyaroshuk and adamdotdevin - I would rather not like put additional pressure on them.

Kind regards,
@balcsida

kkugot reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@balcsida
balcsida force-pushed the feat/litellm-support branch 4 times, most recently from 3d73899 to 0988ce8 Compare March 13, 2026 19:58
@github-actions github-actions Bot mentioned this pull request Mar 15, 2026
feat(opencode): dynamic model discovery for local providers (LM Studio, llama.cpp, etc.) #17670
Closed
3 of 6 tasks
balcsida and others added 23 commits July 15, 2026 13:01
@balcsida
feat(opencode): add litellm provider seeding and custom loader
2e07f9b
@balcsida
feat(opencode): add litellm-specific reasoning transform variants
8ac5e01
@balcsida
fix(opencode): add explicit litellm providerID check for proxy detection
ec20470
@balcsida
feat(opencode): allow interactive litellm provider configuration
042d7d0
@balcsida
feat(opencode): add litellm multi-step connect flow in TUI
aa632b3
@balcsida
feat(app): add litellm connect dialog with base URL and API key fields
fb94070
@balcsida
refactor: clean up litellm code to follow style guide
4a164e8
@balcsida
fix(opencode): use global config update for litellm base URL persistence
60b0c30
@balcsida
feat(opencode): store underlying model in litellm model options
3366ce7
@balcsida
fix(opencode): detect litellm Claude models via underlying model info
c7bdc6e
@balcsida
fix(opencode): use snake_case budget_tokens for litellm thinking vari…
d2b01fa
…ants
@balcsida
fix(opencode): select correct system prompt for litellm Claude models
d2b2ed8
@balcsida
fix(opencode): filter underlyingModel from litellm provider options
33177c6
# Conflicts:
#	packages/opencode/src/session/llm.ts
@balcsida
feat(opencode): enable prompt caching litellm Claude models
ebc012e
@balcsida
refactor(opencode): replace try/catch with .catch() in litellm code
8730bd2
@balcsida
fix(opencode): use branded types for litellm ModelID and ProviderID
1be9955
# Conflicts:
#	packages/opencode/src/provider/provider.ts
@balcsida @claude
fix(opencode): adapt litellm loader to Effect-based Env API
b3fc573
Upstream refactored the Env module into an Effect Service; use
dep.get() inside the Effect generator and let the caller pass the
discovery timeout instead of reading env in the async helper.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@balcsida @claude
fix(opencode): update litellm Log import to namespace path
63d8348
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@balcsida
fix(opencode): guard defaultModelIDs against providers with no models
8c347bb
@balcsida @claude
fix(opencode): conform defaultModelIDs to Schema.Record(String, String)
c9b7ef7
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@balcsida @claude
fix(opencode): rename provider.id to providerID in litellm check
a7f2805
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@balcsida @claude
fix(opencode): force HTTP/2 for litellm to avoid proxy SSE buffering
edf85c3
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@balcsida
refactor: trim litellm provider cleanup
159fead
@balcsida
balcsida force-pushed the feat/litellm-support branch from d2fab08 to 159fead Compare July 15, 2026 12:47
@github-actions github-actions Bot mentioned this pull request Jul 15, 2026
📊 AI CLI 工具社区动态日报 2026-07-15 litang9/big_model_radar#210
Open
@balcsida

balcsida commented Jul 16, 2026

Copy link
Copy Markdown
Author

I'm tired

juan-abia, stefanlasiewski, and js0ny reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@balcsida balcsida closed this Jul 16, 2026
@jamie-dit

jamie-dit commented Jul 17, 2026

Copy link
Copy Markdown

Sorry @balcsida

If it makes you feel better, I've been tracking your PR since the start. Real shame OpenCode ignored this PR.

stefanlasiewski and slumbi reacted with thumbs up emoji balcsida reacted with heart emoji
All reactions
  • 👍 2 reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@stefanlasiewski

stefanlasiewski commented Jul 18, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Bummer that OpenCode didn't add this. Model discovery is an important feature for enterprise use and helps with cost management. Claude Code does this, and I expect all major vendors will support it if they don't already.

Thanks for the hard work balcsida.

balcsida reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@el-AI-wei el-AI-wei mentioned this pull request Sep 14, 2026
[FEATURE]: Add LiteLLM as a provider #48938
Closed
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adamdotdevin adamdotdevin Awaiting requested review from adamdotdevin
@alexyaroshuk alexyaroshuk Awaiting requested review from alexyaroshuk
@Hona Hona Awaiting requested review from Hona
@Brendonovich Brendonovich Awaiting requested review from Brendonovich
1 more reviewer
@scratchmex scratchmex scratchmex left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Auto-load available models from LiteLLM proxy with autoload option

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@balcsida @alexyaroshuk @kkugot @ELBouslama @janus-reith @zacharymichaelmoore @jamie-dit @krrish-berri-2 @stefanlasiewski @scratchmex
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.