[PR #13896] feat(opencode): add auto loading models for litellm providers #14859

Open
opened 2026-02-16 18:19:36 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13896

State: open
Merged: No


What does this PR do?

Fixes #13891

This PR adds auto loading models feature for LiteLLM proxy providers in OpenCode. When a provider is configured with both litellmProxy: true and autoload: true options, OpenCode will automatically fetch available models from the LiteLLM proxy's /model/info endpoint (with fallback to /models endpoint). This eliminates the need to manually define every model in opencode.json when using LiteLLM proxies that may have many models.

How did you verify your code works?

  • Unit tests
  • Manual testing e.g. for opencode.json
  "$schema": "https://opencode.ai/config.json",
  "model": "InternalLiteLLMGateway/anthropic/claude-opus-4-5",
  "provider": {
    "InternalLiteLLMGateway": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "InternalLiteLLMGateway",
      "options": {
        "baseURL": "https://litellm.internal",
        "litellmProxy": true,
        "autoload": true,
        "apiKey": "sk-xxx",
        "headers": {
          "Authorization": "Bearer sk-xxx"
        }
      }
    }
  }
}

https://github.com/user-attachments/assets/ff46c217-4ed4-4249-91f4-1fed7dd86e31

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13896 **State:** open **Merged:** No --- ### What does this PR do? Fixes #13891 This PR adds auto loading models feature for LiteLLM proxy providers in OpenCode. When a provider is configured with both `litellmProxy: true` and `autoload: true` options, OpenCode will automatically fetch available models from the LiteLLM proxy's `/model/info` endpoint (with fallback to `/models` endpoint). This eliminates the need to manually define every model in `opencode.json` when using LiteLLM proxies that may have many models. ### How did you verify your code works? - [x] Unit tests - [x] Manual testing e.g. for `opencode.json` ```{ "$schema": "https://opencode.ai/config.json", "model": "InternalLiteLLMGateway/anthropic/claude-opus-4-5", "provider": { "InternalLiteLLMGateway": { "npm": "@ai-sdk/openai-compatible", "name": "InternalLiteLLMGateway", "options": { "baseURL": "https://litellm.internal", "litellmProxy": true, "autoload": true, "apiKey": "sk-xxx", "headers": { "Authorization": "Bearer sk-xxx" } } } } } ``` https://github.com/user-attachments/assets/ff46c217-4ed4-4249-91f4-1fed7dd86e31
yindo added the pull-request label 2026-02-16 18:19:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14859