feat: support canonical opencode provider

This commit is contained in:
hamb1y
2026-07-06 12:13:00 +08:00
committed by Xubin Ren
parent f0c989ba2d
commit 400369f0b0
3 changed files with 40 additions and 6 deletions
+1
View File
@@ -260,6 +260,7 @@ class ProvidersConfig(Base):
github_copilot: ProviderConfig = Field(default_factory=ProviderConfig, exclude=True) # Github Copilot (OAuth)
qianfan: ProviderConfig = Field(default_factory=ProviderConfig) # Qianfan (百度千帆)
nvidia: ProviderConfig = Field(default_factory=ProviderConfig) # NVIDIA NIM (nvapi- keys)
opencode: ProviderConfig = Field(default_factory=ProviderConfig) # OpenCode Zen (canonical provider id)
opencode_zen: ProviderConfig = Field(default_factory=ProviderConfig) # OpenCode Zen (curated coding models)
opencode_go: ProviderConfig = Field(default_factory=ProviderConfig) # OpenCode Go (low-cost coding models)
+14 -1
View File
@@ -179,7 +179,20 @@ PROVIDERS: tuple[ProviderSpec, ...] = (
gateway_reasoning_style="reasoning_effort",
),
# OpenCode Zen: OpenAI-compatible chat-completions gateway for coding models.
# OpenCode's own config uses "opencode/<model>"; send the bare model upstream.
# models.dev/OpenCode use provider id "opencode" and model ids like
# "opencode/<model>"; send the bare model upstream.
ProviderSpec(
name="opencode",
keywords=("opencode/", "opencode", "opencode-zen", "opencode_zen"),
env_key="OPENCODE_API_KEY",
display_name="OpenCode Zen",
backend="openai_compat",
is_gateway=True,
detect_by_base_keyword="opencode.ai/zen",
default_api_base="https://opencode.ai/zen/v1",
strip_model_prefixes=("opencode", "opencode_zen", "opencode-zen"),
),
# Compatibility alias for configs that already used providers.opencodeZen.
ProviderSpec(
name="opencode_zen",
keywords=("opencode/", "opencode_zen", "opencode-zen"),