free-claude-code/providers/opencode/client.py
Rizki Kotet 32e2e4d755
Some checks are pending
CI / checks (push) Waiting to run
feat(opencode): integrate OpenCode Zen provider and API key support (#426)
2026-05-12 08:44:54 -07:00

31 lines
969 B
Python

"""OpenCode Zen provider implementation (OpenAI-compatible Chat Completions)."""
from __future__ import annotations
from typing import Any
from providers.base import ProviderConfig
from providers.defaults import OPENCODE_DEFAULT_BASE
from providers.openai_compat import OpenAIChatTransport
from .request import build_request_body
class OpenCodeProvider(OpenAIChatTransport):
"""OpenCode Zen provider using ``https://opencode.ai/zen/v1/chat/completions``."""
def __init__(self, config: ProviderConfig):
super().__init__(
config,
provider_name="OPENCODE",
base_url=config.base_url or OPENCODE_DEFAULT_BASE,
api_key=config.api_key,
)
def _build_request_body(
self, request: Any, thinking_enabled: bool | None = None
) -> dict:
return build_request_body(
request,
thinking_enabled=self._is_thinking_enabled(request, thinking_enabled),
)