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

Closed
opened 2026-02-16 18:12:34 -05:00 by yindo · 2 comments
Owner

Originally created by @farukcankaya on GitHub (Feb 16, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

When using OpenCode with a LiteLLM proxy, users must manually define every model in opencode.json. LiteLLM proxies already expose all available models via their /models endpoint (OpenAI-compatible). If the proxy has 20+ models, the config becomes tedious to maintain and goes stale as models are added/removed on the proxy side.

Proposed solution

Add an autoload: true option that works alongside litellmProxy: true. When both are set, OpenCode fetches the list of available models from the proxy's /models endpoint at startup. When only litellmProxy: true is set (without autoload), models must be defined manually as before.

Manual models only (litellmProxy: true):

{
  "provider": {
    "MyLiteLLMProxy": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "My LiteLLM Proxy",
      "options": {
        "baseURL": "https://litellm.example.com/v1",
        "litellmProxy": true
      },
      "models": {
        "gpt-4": { "name": "GPT-4" },
        "anthropic/claude-opus-4-6": { "name": "anthropic/claude-opus-4-6" },
        "deepseek-chat": { "name": "DeepSeek Chat" }
      }
    }
  }
}

Auto-load all models (litellmProxy: true + autoload: true):

{
  "provider": {
    "my-proxy": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "My LiteLLM Proxy",
      "options": {
        "baseURL": "https://litellm.example.com/v1",
        "litellmProxy": true,
        "autoload": true,
        "apiKey": "sk-key"
      }
    }
  }
}

Key behaviors:

  • litellmProxy: true marks the provider as a LiteLLM proxy
  • autoload: true opts into fetching models from the /models endpoint at startup
  • Both must be set for auto-loading (or provider ID contains "litellm" + autoload: true)
  • Manually configured models are never overridden (user config takes precedence)

Why this belongs in OpenCode

  • "Support for new providers" is listed as an accepted contribution type in CONTRIBUTING.md
  • LiteLLM is the most common proxy for teams running multiple LLM providers behind a single gateway
  • This removes friction for self-hosted and enterprise setups where model lists change frequently
  • Zero impact on existing users - autoload is opt-in alongside litellmProxy
Originally created by @farukcankaya on GitHub (Feb 16, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request ### Problem When using OpenCode with a LiteLLM proxy, users must manually define every model in `opencode.json`. LiteLLM proxies already expose all available models via their `/models` endpoint (OpenAI-compatible). If the proxy has 20+ models, the config becomes tedious to maintain and goes stale as models are added/removed on the proxy side. ### Proposed solution Add an `autoload: true` option that works alongside `litellmProxy: true`. When both are set, OpenCode fetches the list of available models from the proxy's `/models` endpoint at startup. When only `litellmProxy: true` is set (without `autoload`), models must be defined manually as before. **Manual models only** (`litellmProxy: true`): ```json { "provider": { "MyLiteLLMProxy": { "npm": "@ai-sdk/openai-compatible", "name": "My LiteLLM Proxy", "options": { "baseURL": "https://litellm.example.com/v1", "litellmProxy": true }, "models": { "gpt-4": { "name": "GPT-4" }, "anthropic/claude-opus-4-6": { "name": "anthropic/claude-opus-4-6" }, "deepseek-chat": { "name": "DeepSeek Chat" } } } } } ``` **Auto-load all models** (`litellmProxy: true` + `autoload: true`): ```json { "provider": { "my-proxy": { "npm": "@ai-sdk/openai-compatible", "name": "My LiteLLM Proxy", "options": { "baseURL": "https://litellm.example.com/v1", "litellmProxy": true, "autoload": true, "apiKey": "sk-key" } } } } ``` Key behaviors: - `litellmProxy: true` marks the provider as a LiteLLM proxy - `autoload: true` opts into fetching models from the `/models` endpoint at startup - Both must be set for auto-loading (or provider ID contains "litellm" + `autoload: true`) - Manually configured models are never overridden (user config takes precedence) ### Why this belongs in OpenCode - "Support for new providers" is listed as an accepted contribution type in CONTRIBUTING.md - LiteLLM is the most common proxy for teams running multiple LLM providers behind a single gateway - This removes friction for self-hosted and enterprise setups where model lists change frequently - Zero impact on existing users - `autoload` is opt-in alongside `litellmProxy`
yindo added the discussion label 2026-02-16 18:12:34 -05:00
yindo closed this issue 2026-02-16 18:12:34 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 16, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #6231: Auto-discover models from OpenAI-compatible provider endpoints - This is very similar in scope, requesting automatic model discovery from the /v1/models endpoint for OpenAI-compatible providers including LiteLLM proxies.

Both issues request the same core functionality: auto-loading model lists from an OpenAI-compatible endpoint instead of requiring manual configuration. The main difference is that #13891 is specifically scoped to LiteLLM with an opt-in autoload flag, while #6231 discusses broader auto-discovery for all OpenAI-compatible providers.

These may be candidates for consolidation or alignment in implementation.

@github-actions[bot] commented on GitHub (Feb 16, 2026): This issue might be a duplicate of existing issues. Please check: - #6231: Auto-discover models from OpenAI-compatible provider endpoints - This is very similar in scope, requesting automatic model discovery from the `/v1/models` endpoint for OpenAI-compatible providers including LiteLLM proxies. Both issues request the same core functionality: auto-loading model lists from an OpenAI-compatible endpoint instead of requiring manual configuration. The main difference is that #13891 is specifically scoped to LiteLLM with an opt-in `autoload` flag, while #6231 discusses broader auto-discovery for all OpenAI-compatible providers. These may be candidates for consolidation or alignment in implementation.
Author
Owner

@R44VC0RP commented on GitHub (Feb 16, 2026):

Good idea, going to close this for now, once we get more requests for this we can reopen.

@R44VC0RP commented on GitHub (Feb 16, 2026): Good idea, going to close this for now, once we get more requests for this we can reopen.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9492