@staticeng/opencode-litellm
v0.1.6
Published
OpenCode plugin that discovers LiteLLM models at runtime.
Maintainers
Readme
opencode-litellm
Runtime LiteLLM model autodiscovery for OpenCode. The plugin fetches LiteLLM /model/info at OpenCode startup and adds an in-memory provider named LiteLLM by default.
Install
Install the package by npm name, then add it to OpenCode plugin config:
npm install @staticeng/opencode-litellm{
"$schema": "https://opencode.ai/config.json",
"plugin": [
[
"@staticeng/opencode-litellm",
{
"baseURL": "https://litellm.example.com/v1",
"apiKeyEnv": "LITELLM_API_KEY"
}
]
]
}Set the API key in your environment before starting OpenCode:
export LITELLM_API_KEY="..."Do not put real API keys in opencode.json. If you pass apiKey directly, the plugin uses it only in memory and never logs it, but environment variables are recommended.
Options
| Option | Default | Purpose |
| --- | --- | --- |
| baseURL | LITELLM_BASE_URL | LiteLLM proxy base URL. /v1 URLs are supported. |
| apiKey | env value | Bearer token for LiteLLM. |
| apiKeyEnv | LITELLM_API_KEY | Environment variable used when apiKey is not set. |
| providerKey | LiteLLM | Key written to cfg.provider[providerKey]. |
| providerName | LiteLLM | Human provider name. |
| overrides | {} | Per-model deep-merge overrides. |
| providerOverrides | {} | Provider-level deep-merge overrides. |
| includeModes | chat, responses | LiteLLM modes to include. |
| includeModels | all included modes | Optional allowlist by model name. |
| excludeModels | none | Optional denylist by model name. |
| timeoutMs | 30000 | /model/info request timeout. |
| strict | false | Throw on fetch/mapping failures instead of warning. |
The LiteLLM key must have permission to call GET /model/info.
Overrides
LiteLLM metadata does not expose every OpenCode model field. Use overrides to add variants, thinking controls, cache costs, interleaved reasoning settings, limits, modalities, timeouts, or provider-specific options.
{
"plugin": [
[
"@staticeng/opencode-litellm",
{
"baseURL": "https://litellm.example.com/v1",
"apiKeyEnv": "LITELLM_API_KEY",
"overrides": {
"chatgpt/gpt-5.5": {
"limit": { "context": 262144, "output": 128000 },
"variants": {
"high": { "options": { "reasoning_effort": "high" } }
},
"interleaved": { "field": "reasoning_details" }
}
},
"providerOverrides": {
"options": {
"timeout": 600000
}
}
}
]
]
}Overrides win over generated values through a recursive deep merge. Arrays and scalar values are replaced rather than concatenated.
Runtime Behavior
- Fetches
${baseURL}/model/infowithAuthorization: Bearer <token>. - Handles base URLs with or without a trailing slash, including
/v1. - Adds or replaces
cfg.provider[providerKey]during OpenCode's plugin config hook. - Does not write
opencode.json, cache model metadata, or persist generated provider data. - Includes
chatandresponsesmodes by default; non-chat modes such asembeddingandrerankare excluded unless explicitly included. - No HuggingFace fallback is included in v1.
Publish Notes
The package is ESM-only and publishes the compiled dist/ directory.
npm install
npm run build
npm test
npm pack --dry-runConfirm package contents before publishing and keep secrets out of fixtures, docs, logs, and config examples.
