1 line
6.9 KiB
JSON
1 line
6.9 KiB
JSON
{"repo": "alikestocode/multillm-proxy", "files": {"docs/opencode-go.md": {"8f778190318d9842f8d7d73cf7dad482047b44de": {"t": 1785596347.0065885, "n": 6619, "h": "3fd9a97d945101a5", "c": "# OpenCode Go integration\n\nMultiLLM Proxy exposes the OpenCode Go subscription API under `/opencode/*`.\nThe integration follows the live\n[OpenCode Go documentation](https://opencode.ai/docs/go).\n\nThe canonical `/opencode/v1/*` routes preserve OpenAI and Anthropic request\nbodies, streaming events, JSON bytes, status codes, repeated query parameters,\nand safe rate-limit/request headers. The proxy does not translate one protocol\ninto the other.\n\n## Configuration\n\n```env\nOPENCODE_GO_API_KEY=your-opencode-go-api-key\n\n# Compatibility alias\n# OPENCODE_API_KEY=your-opencode-go-api-key\n\n# Optional upstream override\n# OPENCODE_GO_BASE_URL=https://opencode.ai/zen/go/v1\n```\n\n`OPENCODE_GO_API_KEY` takes precedence when both key names are set.\n\n## Client base URLs\n\n| Client | Proxy base URL |\n| --- | --- |\n| OpenAI-compatible SDK | `$PROXY_BASE_URL/opencode/v1` |\n| Anthropic SDK | `$PROXY_BASE_URL/opencode` |\n| Direct HTTP | `$PROXY_BASE_URL/opencode` plus `/v1/...` |\n\nOpenAI-compatible example:\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=\"YOUR_MULTILLM_PROXY_KEY\",\n base_url=\"https://your-proxy.example/opencode/v1\",\n)\n\nresponse = client.chat.completions.create(\n model=\"kimi-k3\",\n messages=[{\"role\": \"user\", \"content\": \"Review this function.\"}],\n)\n```\n\nAnthropic-compatible example:\n\n```python\nimport anthropic\n\nclient = anthropic.Anthropic(\n api_key=\"YOUR_MULTILLM_PROXY_KEY\",\n base_url=\"https://your-proxy.example/opencode\",\n)\n\nresponse = client.messages.create(\n model=\"minimax-m3\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": \"Review this function.\"}],\n)\n```\n\nThe OpenAI client authenticates MultiLLM Proxy with `Authorization: Bearer`.\nThe Anthropic client can authenticate it with `X-Api-Key`. The proxy replaces\nthat credential with the configured OpenCode Go key and uses the native\nupstream header for the selected protocol.\n\n## Endpoints\n\n| Capability | Direct OpenCode Go URL | Proxy URL |\n| --- | --- | --- |\n| OpenAI Chat Completions | `POST https://opencode.ai/zen/go/v1/chat/completions` | `POST /opencode/v1/chat/completions` |\n| Anthropic Messages | `POST https://opencode.ai/zen/go/v1/messages` | `POST /opencode/v1/messages` |\n| Model discovery | `GET https://opencode.ai/zen/go/v1/models` | `GET /opencode/v1/models` |\n\nUse the model catalog at runtime because OpenCode may add or remove models as\nit tests provider/model combinations.\n\n## Current model and protocol mapping\n\n| Model | Request model ID | Protocol |\n| --- | --- | --- |\n| Grok 4.5 | `grok-4.5` | OpenAI Chat Completions |\n| GLM-5.2 | `glm-5.2` | OpenAI Chat Completions |\n| GLM-5.1 | `glm-5.1` | OpenAI Chat Completions |\n| Kimi K3 | `kimi-k3` | OpenAI Chat Completions |\n| Kimi K2.7 Code | `kimi-k2.7-code` | OpenAI Chat Completions |\n| Kimi K2.6 | `kimi-k2.6` | OpenAI Chat Completions |\n| MiMo-V2.5 | `mimo-v2.5` | OpenAI Chat Completions |\n| MiMo-V2.5-Pro | `mimo-v2.5-pro` | OpenAI Chat Completions |\n| DeepSeek V4 Pro | `deepseek-v4-pro` | OpenAI Chat Completions |\n| DeepSeek V4 Flash | `deepseek-v4-flash` | OpenAI Chat Completions |\n| Hy3 | `hy3` | OpenAI Chat Completions |\n| MiniMax M3 | `minimax-m3` | Anthropic Messages |\n| MiniMax M2.7 | `minimax-m2.7` | Anthropic Messages |\n| MiniMax M2.5 | `minimax-m2.5` | Anthropic Messages |\n| Qwen3.7 Max | `qwen3.7-max` | Anthropic Messages |\n| Qwen3.7 Plus | `qwen3.7-plus` | Anthropic Messages |\n| Qwen3.6 Plus | `qwen3.6-plus` | Anthropic Messages |\n\nOpenCode configuration uses `opencode-go/<model-id>`, for example\n`opencode-go/kimi-k3`. That prefix belongs to OpenCode's own configuration.\nDirect API requests through this proxy send only `kimi-k3`. MultiLLM's unified\nChat route instead uses its normal `provider:model` form:\n\n```json\n{\n \"model\": \"opencode:kimi-k3\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello\"}]\n}\n```\n\n## Streaming and compatibility\n\n`POST /opencode/v1/chat/completions` preserves OpenAI SSE frames.\n`POST /opencode/v1/messages` preserves Anthropic events such as\n`message_start`, `content_block_delta`, `message_delta`, and `message_stop`.\n\nThe older `POST /opencode/chat/completions` route remains available for\nbackward compatibility. It retains MultiLLM Proxy's historical OpenAI stream\nnormalization, including visible reasoning blocks and recovery from a specific\nlegacy OpenCode timeout payload. New clients should use the protocol-native\n`/opencode/v1/...` routes.\n\nNative routes are single-attempt and do not follow upstream redirects or retain\nupstream cookies. This prevents duplicate coding requests and credential\ncross-contamination. Retry a failed request in the client only when doing so is\nsafe for that operation.\n\n## Caller-owned OpenCode Go keys\n\nTo use a different OpenCode Go subscription for one request, authenticate\nMultiLLM Proxy separately:\n\n```bash\ncurl \"$PROXY_BASE_URL/opencode/v1/chat/completions\" \\\n -H \"X-MultiLLM-Api-Key: $ADMIN_API_KEY\" \\\n -H \"Authorization: Bearer $CALLER_OPENCODE_GO_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"model\":\"kimi-k3\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello\"}]}'\n```\n\nFor Anthropic Messages, combine `X-MultiLLM-Api-Key` with the caller's\n`X-Api-Key`. Caller-owned credentials work even when the server has no\n`OPENCODE_GO_API_KEY`.\n\n## Subscription and upstream limits\n\nOpenCode currently advertises Go at $5 for the first month and $10/month\nafterward. The upstream subscription windows are:\n\n| Window | Included usage value |\n| --- | ---: |\n| Five hours | $12 |\n| Week | $30 |\n| Month | $60 |\n\nActual request counts depend on the selected model, cached-token volume, and\ninput/output length. Some models currently have $15 rather than $60 of monthly\nincluded model usage because their upstream discount multiplier is lower.\nOpenCode documents the current estimates and token prices in its Go page.\n\nThese are upstream monetary limits, not MultiLLM request-rate limits. The proxy\ndoes not duplicate or predict OpenCode's billing calculation. Track authoritative\nusage in the OpenCode console. If the subscription reaches a limit, OpenCode\nallows free models, and users with Zen credits can enable the console's\n`Use balance` fallback.\n\nOnly one member per OpenCode workspace can subscribe to Go.\n\n## Privacy and hosting\n\nOpenCode describes Go as intended primarily for international users, with\nmodels hosted in the United States, European Union, and Singapore. Its\ndocumentation states that the serving providers follow a zero-retention policy\nand do not use request data for model training. Evaluate that upstream policy\nagainst your own data-handling requirements before sending sensitive code.\n"}}}} |