Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SELF_HOSTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ common provider keys into worker containers:
- `ZAI_CODING_PLAN_API_KEY` (Z.AI Coding Plan, `zai-coding-plan/...` models,
with `ZAI_CODING_PLAN_REGION`)
- `OPENCODE_API_KEY`
- `OPENCODE_GO_API_KEY` (OpenCode Go subscription, `opencode-go/...` models)

If your provider uses another env var name, list it in
`R_MODEL_ENV_KEYS`:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"providers/inference/openai",
"providers/inference/openai-compatible",
"providers/inference/opencode",
"providers/inference/opencode-go",
"providers/inference/openrouter",
"providers/inference/together-ai",
"providers/inference/vercel-ai-gateway",
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/environment-variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ as per-task auth tokens or workspace paths.
| `ZAI_REGION` | Provider key | Z.AI region: `global` (International) or `china`. Defaults to `global` when unset. |
| `ZAI_CODING_PLAN_API_KEY` | Provider key | Z.AI Coding Plan API key for `zai-coding-plan/...` models. Not a general platform key. |
| `ZAI_CODING_PLAN_REGION` | Provider key | Z.AI Coding Plan region: `global` (International) or `china`. Defaults to `global` when unset. |
| `OPENCODE_API_KEY` | Provider key | OpenCode Zen / Go API key. |
| `OPENCODE_API_KEY` | Provider key | OpenCode Zen API key. |
| `OPENCODE_GO_API_KEY` | Provider key | OpenCode API key for an active Go subscription and `opencode-go/...` models. |
| `GEMINI_API_KEY` | Provider key | Google Gemini API key. Can also be saved from **Settings > Models**. |
| `GOOGLE_GENERATIVE_AI_API_KEY` | Provider key | Alternate Google/Gemini provider key forwarded when configured or inferred. |
| `AWS_BEARER_TOKEN_BEDROCK` | Provider key | Amazon Bedrock Mantle API key. Can also be saved from **Settings > Models**. |
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ These connections use metered API billing or a provider-managed gateway:
| [MiniMax](/providers/inference/minimax) | MiniMax API key | MiniMax account |
| [Moonshot AI (Kimi)](/providers/inference/moonshot-ai) | Kimi Open Platform key | Moonshot Open Platform balance |
| [OpenAI](/providers/inference/openai) | OpenAI API key | OpenAI API project |
| [OpenCode Zen / Go](/providers/inference/opencode) | OpenCode API key | OpenCode account |
| [OpenCode Zen](/providers/inference/opencode) | OpenCode API key | OpenCode account |
| [OpenRouter](/providers/inference/openrouter) | OpenRouter API key | OpenRouter balance and key limit |
| [Together AI](/providers/inference/together-ai) | Together AI API key | Together AI account |
| [Vercel AI Gateway](/providers/inference/vercel-ai-gateway) | AI Gateway API key | Vercel team |
Expand All @@ -68,6 +68,7 @@ general API balance:
| [ChatGPT Subscription](/providers/inference/chatgpt) | OpenAI device authorization | ChatGPT plan windows |
| [GitHub Copilot](/providers/inference/github-copilot) | GitHub device authorization | Copilot plan allowance |
| [Kimi for Coding](/providers/inference/kimi-for-coding) | Kimi membership key | Coding membership allowance |
| [OpenCode Go](/providers/inference/opencode-go) | OpenCode API key | Go plan allowance |
| [xAI Grok Subscription](/providers/inference/xai-subscription) | xAI account authorization | SuperGrok or eligible X plan allowance |
| [Z.AI Coding Plan](/providers/inference/zai-coding-plan) | Regional Coding Plan key | Coding Plan quota windows |

Expand Down
55 changes: 55 additions & 0 deletions apps/docs/providers/inference/opencode-go.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: OpenCode Go
icon: 'https://unpkg.com/@lobehub/icons-static-svg@1.94.0/icons/opencode.svg'
description: Use an OpenCode Go subscription with Roomote.
---

OpenCode Go is a subscription for a curated catalog of coding models. Use this
provider when you want Roomote tasks to consume the allowance included with
your Go plan.

## Subscribe and get an API key

Sign in to [OpenCode](https://opencode.ai/auth), subscribe to Go, and copy your
API key. OpenCode currently allows one Go subscription per workspace.

## Configuration

Add **OpenCode Go** in **Settings > Models** and paste the key, or set:

```sh
OPENCODE_GO_API_KEY=...
```

Roomote uses a separate environment variable so Zen and Go can be configured
independently. Paste the OpenCode API key issued for the workspace; Roomote
binds it to OpenCode's `opencode-go` provider at runtime.

Go models use the `opencode-go/` prefix. Connecting the provider adds a curated
set of eligible models and recommends lower-cost options for helper work.

## Usage behavior

Requests consume the rolling and monthly allowances defined by your Go plan.
The OpenCode account console is authoritative for current usage and resets. If
you enable **Use balance** in OpenCode, requests can fall back to your Zen
balance after the included allowance is exhausted.

See [OpenCode Go documentation](https://opencode.ai/docs/go/) for current
models, limits, pricing, and retention details.

## Verify setup

1. save `OPENCODE_GO_API_KEY`
2. confirm OpenCode Go models appear in **Settings > Models**
3. apply a preset or assign an `opencode-go/...` model manually
4. run a small task and confirm it appears in OpenCode usage

## Common issues

- **The key is rejected.** Confirm the workspace has an active Go subscription
and that you copied its OpenCode API key.
- **A model is unavailable.** Go's catalog can change; select another model
shown in the OpenCode Go console.
- **Requests stop after sustained use.** Check the plan's rolling, weekly, and
monthly allowance windows in OpenCode.
6 changes: 3 additions & 3 deletions apps/docs/providers/inference/opencode.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: OpenCode Zen / Go
title: OpenCode Zen
icon: 'https://unpkg.com/@lobehub/icons-static-svg@1.94.0/icons/opencode.svg'
description: Use OpenCode's routed Zen model service with Roomote.
---
Expand All @@ -16,13 +16,13 @@ selected models.

## Configuration

Add **OpenCode Zen / Go** in **Settings > Models** and paste the key, or set:
Add **OpenCode Zen** in **Settings > Models** and paste the key, or set:

```sh
OPENCODE_API_KEY=...
```

Roomote exposes routed models under the `opencode/` prefix and adds a recommended
Roomote exposes routed Zen models under the `opencode/` prefix and adds a recommended
set after connection. The preset can use inexpensive routed models for helper
work and stronger models for coding, planning, vision, and review.

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/web/src/app/(onboarding)/setup/setup-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const MODEL_PROVIDER_DOC_PATHS: Partial<
openai: 'providers/inference/openai',
'openai-compatible': 'providers/inference/openai-compatible',
opencode: 'providers/inference/opencode',
'opencode-go': 'providers/inference/opencode-go',
openrouter: 'providers/inference/openrouter',
togetherai: 'providers/inference/together-ai',
vercel: 'providers/inference/vercel-ai-gateway',
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/trpc/commands/task-models/index.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions apps/worker/src/run-task/agent-home.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 45 additions & 10 deletions apps/worker/src/run-task/agent-home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
resolveOpenRouterVariantModelAlias,
OPENCODE_ARCHITECT_AGENT,
OPENCODE_AUTH_CONTENT_ENV_VAR_NAME,
OPENCODE_GO_API_KEY_ENV_VAR_NAME,
TaskPayloadKind,
type EnvironmentManualSkill,
type OpenRouterVariantModelAlias,
Expand Down Expand Up @@ -1095,6 +1096,37 @@ function mergeAzureCognitiveServicesProviderConfig(
};
}

/**
* OpenCode's catalog maps both Zen and Go to OPENCODE_API_KEY. Roomote keeps
* their credentials separate, so bind Go to its dedicated env var directly.
* Gateway mode replaces this value with the run token later.
*/
function mergeOpenCodeGoProviderConfig(
providerConfig: Record<string, unknown>,
modelIds: Array<string | undefined>,
): Record<string, unknown> {
const providerId = 'opencode-go';
if (
!modelIds.some((modelId) => modelId?.trim().startsWith(`${providerId}/`))
) {
return providerConfig;
}

const existingProvider = asRecord(providerConfig[providerId]);
const existingOptions = asRecord(existingProvider.options);

return {
...providerConfig,
[providerId]: {
...existingProvider,
options: {
apiKey: `{env:${OPENCODE_GO_API_KEY_ENV_VAR_NAME}}`,
...existingOptions,
},
},
};
}

function normalizeStringList(value: unknown): string[] {
if (Array.isArray(value)) {
return value.filter((entry): entry is string => typeof entry === 'string');
Expand Down Expand Up @@ -1703,26 +1735,29 @@ function resolveModelBackedOpenCodeConfig(
)
: providerReasoningConfig;
const providerConfig = mergeInferenceGatewayProviderConfig(
mergeAzureCognitiveServicesProviderConfig(
mergeAmazonBedrockProviderConfig(
mergeBedrockMantleProviderConfig(
mergeBedrockMantleOpenAiProviderConfig(
mergeOpenAiCompatibleProviderConfig(
mergeOpenRouterVariantAliasModels(
providerModelConfig,
variantAliases,
mergeOpenCodeGoProviderConfig(
mergeAzureCognitiveServicesProviderConfig(
mergeAmazonBedrockProviderConfig(
mergeBedrockMantleProviderConfig(
mergeBedrockMantleOpenAiProviderConfig(
mergeOpenAiCompatibleProviderConfig(
mergeOpenRouterVariantAliasModels(
providerModelConfig,
variantAliases,
),
runtimeEnv,
configuredModelIds,
visionModel ?? effectiveCodingModel,
),
runtimeEnv,
configuredModelIds,
visionModel ?? effectiveCodingModel,
),
runtimeEnv,
configuredModelIds,
),
runtimeEnv,
configuredModelIds,
),
runtimeEnv,
configuredModelIds,
),
configuredModelIds,
Expand Down
1 change: 1 addition & 0 deletions deploy/compose/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ x-roomote-inference-env: &roomote-inference-env
ZAI_CODING_PLAN_API_KEY: ${ZAI_CODING_PLAN_API_KEY:-}
ZAI_CODING_PLAN_REGION: ${ZAI_CODING_PLAN_REGION:-}
OPENCODE_API_KEY: ${OPENCODE_API_KEY:-}
OPENCODE_GO_API_KEY: ${OPENCODE_GO_API_KEY:-}
BASETEN_API_KEY: ${BASETEN_API_KEY:-}
TOGETHER_API_KEY: ${TOGETHER_API_KEY:-}

Expand Down
1 change: 1 addition & 0 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ x-roomote-production-env: &roomote-production-env
ZAI_CODING_PLAN_API_KEY: ${ZAI_CODING_PLAN_API_KEY:-}
ZAI_CODING_PLAN_REGION: ${ZAI_CODING_PLAN_REGION:-}
OPENCODE_API_KEY: ${OPENCODE_API_KEY:-}
OPENCODE_GO_API_KEY: ${OPENCODE_GO_API_KEY:-}
BASETEN_API_KEY: ${BASETEN_API_KEY:-}
TOGETHER_API_KEY: ${TOGETHER_API_KEY:-}
GITHUB_TOKEN: ${GITHUB_TOKEN:-}
Expand Down
1 change: 1 addition & 0 deletions docker-compose.self-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ x-roomote-env: &roomote-env
ZAI_CODING_PLAN_API_KEY: ${ZAI_CODING_PLAN_API_KEY:-}
ZAI_CODING_PLAN_REGION: ${ZAI_CODING_PLAN_REGION:-}
OPENCODE_API_KEY: ${OPENCODE_API_KEY:-}
OPENCODE_GO_API_KEY: ${OPENCODE_GO_API_KEY:-}
BASETEN_API_KEY: ${BASETEN_API_KEY:-}
TOGETHER_API_KEY: ${TOGETHER_API_KEY:-}
GITHUB_TOKEN: ${GITHUB_TOKEN:-}
Expand Down
27 changes: 27 additions & 0 deletions packages/types/src/__tests__/inference-gateway.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions packages/types/src/inference-gateway.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { SetupModelProviderId } from './model-provider-config';
import { OPENCODE_GO_API_KEY_ENV_VAR_NAME } from './model-provider-config';
import {
getOpenAiCompatibleProviderInstance,
isOpenAiCompatibleProviderEnvVarName,
Expand Down Expand Up @@ -379,6 +380,19 @@ export const INFERENCE_GATEWAY_PROVIDERS: readonly InferenceGatewayProvider[] =
allowedPaths: OPENAI_COMPATIBLE_INFERENCE_PATHS,
openCodeBaseUrlSuffix: '/v1',
},
{
id: 'opencode-go',
name: 'OpenCode Go',
envVarNames: [OPENCODE_GO_API_KEY_ENV_VAR_NAME],
upstreamBaseUrl: 'https://opencode.ai/zen/go',
authHeader: { name: 'authorization', scheme: 'bearer' },
allowedPaths: [
...OPENAI_COMPATIBLE_INFERENCE_PATHS,
...OPENAI_RESPONSES_INFERENCE_PATHS,
...ANTHROPIC_COMPATIBLE_INFERENCE_PATHS,
],
openCodeBaseUrlSuffix: '/v1',
},
{
id: 'xai',
name: 'xAI',
Expand Down
Loading
Loading