Skip to content

[FEATURE]:Auto-sync LiteLLM Models into OpenCode Configuration #29308

@diegomarinho

Description

@diegomarinho

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

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

When OpenCode starts, or when a valid LiteLLM API Key is configured, OpenCode should automatically detect and synchronize newly available models exposed by the LiteLLM /v1/models endpoint.

Currently, users need to manually update their opencode.json configuration whenever new models are added to the LiteLLM gateway. This becomes operationally expensive in enterprise environments where models are frequently added, removed, versioned, or re-routed internally.

The proposed enhancement is for OpenCode to periodically fetch the model catalog from the configured LiteLLM endpoint and automatically update the local provider model registry.

The LiteLLM gateway should become the source of truth for available models.


Expected behavior

If the configured provider is LiteLLM-compatible:

{
  "provider": {
    "litellm": {
      "options": {
        "baseURL": "https://gateway.company.com/v1"
      }
    }
  }
}

OpenCode should:

  • Detect the configured LiteLLM/OpenAI-compatible endpoint
  • Call:
GET /v1/models
  • Compare remote models against the locally cached/provider models
  • Automatically add newly discovered models
  • Optionally remove stale/unavailable models
  • Refresh the model list without requiring manual edits to opencode.json

Suggested sync behavior

Possible triggers:

  • On application startup
  • On provider/API key change
  • Manual refresh action
  • Periodic background sync (optional)

Suggested interval:

  • Every 15–60 minutes
  • Or configurable

Enterprise use case

This is especially useful in enterprise AI Gateway environments using LiteLLM as a centralized model router.

Example:

OpenCode
    ↓
LiteLLM Gateway
    ↓
OpenAI / OpenRouter / Huawei MaaS / Anthropic / DeepSeek

In this architecture:

  • Models are dynamically managed server-side
  • Aliases may change frequently
  • New approved models are constantly added
  • Internal aliases are preferred over provider-native names

Example aliases:

finnet-llm-v1
finnet-llm-v2
finnet-code-v2
finnet-reasoning-v3

Without auto-sync, every workstation requires manual configuration updates.


Benefits

  • Reduces operational overhead
  • Eliminates manual model management
  • Keeps OpenCode aligned with enterprise AI gateways
  • Improves governance consistency
  • Supports dynamic model rollout strategies
  • Better developer experience
  • Enables centralized model lifecycle management

Optional improvements

Potential optional enhancements:

  • Cache synced models locally
  • Show "Last synced at"
  • Sync only models accessible to the current API key
  • Allow disabling auto-sync
  • Allow filtering by provider or access group
  • UI button: "Refresh Models"

Additional context

LiteLLM already exposes standardized model discovery through:

GET /v1/models

This feature would make OpenCode significantly easier to operate in enterprise environments using LiteLLM as the centralized AI Gateway.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions