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
5 changes: 5 additions & 0 deletions .changeset/zai-inference-provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@roomote/web': minor
---

Add Z.AI and Z.AI Coding Plan as inference providers with International or China region on connect.
4 changes: 4 additions & 0 deletions .env.production.example
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ OPENROUTER_API_KEY=
# MOONSHOT_API_KEY=
# KIMI_API_KEY=
# MINIMAX_API_KEY=
# ZAI_API_KEY=
# ZAI_REGION=global
# ZAI_CODING_PLAN_API_KEY=
# ZAI_CODING_PLAN_REGION=global
# OPENCODE_API_KEY=

# Compute provider. Use docker for a single-host deployment, or
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ cleans up after itself.
2. **API keys (BYOK).** Paste a key from OpenRouter, Anthropic, OpenAI, xAI,
Google Gemini, Amazon Bedrock, Vercel AI Gateway,
Baseten, Together AI, Moonshot AI (Kimi), Kimi for Coding, MiniMax,
OpenCode Zen / Go, or GitHub Copilot.
Z.AI (including Coding Plan), OpenCode Zen / Go, or GitHub Copilot.

**Sandbox compute:** Modal, E2B, Daytona, Blaxel, and Local Docker.

Expand Down Expand Up @@ -231,8 +231,8 @@ it runs.
Two options. Connect your ChatGPT Plus or Pro subscription directly (no API key
needed), or paste an API key from OpenRouter, Anthropic, OpenAI, xAI, Google
Gemini, Amazon Bedrock, Vercel AI Gateway, Baseten,
Together AI, Moonshot AI (Kimi), Kimi for Coding, MiniMax, OpenCode Zen / Go,
or GitHub Copilot.
Together AI, Moonshot AI (Kimi), Kimi for Coding, MiniMax, Z.AI (including
Coding Plan), OpenCode Zen / Go, or GitHub Copilot.

**What sandboxes does it support?**
Modal, E2B, Daytona, Blaxel, and Local Docker.
Expand Down
3 changes: 3 additions & 0 deletions SELF_HOSTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ common provider keys into worker containers:
- `MOONSHOT_API_KEY`
- `KIMI_API_KEY` (Kimi for Coding, `kimi-for-coding/...` models)
- `MINIMAX_API_KEY`
- `ZAI_API_KEY` (with `ZAI_REGION`: `global` or `china`, defaults to `global`)
- `ZAI_CODING_PLAN_API_KEY` (Z.AI Coding Plan, `zai-coding-plan/...` models,
with `ZAI_CODING_PLAN_REGION`)
- `OPENCODE_API_KEY`

If your provider uses another env var name, list it in
Expand Down
109 changes: 106 additions & 3 deletions apps/api/src/handlers/inference/__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 apps/api/src/handlers/inference/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,20 @@ async function resolveProviderUpstreamBaseUrl(
(await resolveModelProviderEnvValue([provider.region.envVarName])) ??
provider.region.default;

// Providers with discrete regional hosts select a base outright; the
// `{region}` template and its cloud-region pattern do not apply to them.
if (provider.region.baseUrls) {
const baseUrl = provider.region.baseUrls[region];

if (!baseUrl) {
throw new Error(
`${provider.region.envVarName} must be one of ${Object.keys(provider.region.baseUrls).join(', ')} for ${provider.name}. Received "${region}".`,
);
}

return baseUrl;
}

if (!INFERENCE_GATEWAY_REGION_PATTERN.test(region)) {
throw new Error(
`${provider.region.envVarName} must be a valid region for ${provider.name}. Received "${region}".`,
Expand Down
4 changes: 4 additions & 0 deletions apps/docs/environment-variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ as per-task auth tokens or workspace paths.
| `MOONSHOT_API_KEY` | Provider key | Moonshot AI / Kimi Open Platform API key. |
| `KIMI_API_KEY` | Provider key | Kimi for Coding API key for `kimi-for-coding/...` models. |
| `MINIMAX_API_KEY` | Provider key | MiniMax API key. |
| `ZAI_API_KEY` | Provider key | Z.AI platform API key for the region set by `ZAI_REGION`. |
| `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. |
| `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. |
Expand Down
11 changes: 6 additions & 5 deletions apps/docs/models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ Configure models from **Settings > Models**.

An inference provider is the service that hosts or routes model calls. Roomote
supports providers such as OpenRouter, Vercel AI Gateway, Baseten,
Together AI, OpenAI, Anthropic, Moonshot AI, Kimi for Coding, MiniMax, OpenCode,
Amazon Bedrock, Google Gemini, xAI, GitHub Copilot, ChatGPT subscriptions, and
OpenAI-compatible endpoints such as LiteLLM, Ollama, and vLLM.
Together AI, OpenAI, Anthropic, Moonshot AI, Kimi for Coding, MiniMax, Z.AI,
Z.AI Coding Plan, OpenCode, Amazon Bedrock, Google Gemini, xAI, GitHub Copilot,
ChatGPT subscriptions, and OpenAI-compatible endpoints such as LiteLLM, Ollama,
and vLLM.

You can connect more than one inference provider in the same deployment. That
lets you mix and match models by provider instead of betting the whole
Expand Down Expand Up @@ -117,8 +118,8 @@ R_EXPLORE_MODEL=openrouter/openai/gpt-5.6-luna

Roomote automatically forwards common provider keys to task workers, including
OpenRouter, Vercel AI Gateway, OpenAI, Anthropic, Google Gemini,
Moonshot, Kimi for Coding, MiniMax, OpenCode, Amazon Bedrock, xAI, and GitHub
Copilot keys.
Moonshot, Kimi for Coding, MiniMax, Z.AI, OpenCode, Amazon Bedrock, xAI, and
GitHub Copilot keys.
Use `R_MODEL_ENV_KEYS` when a provider key uses a custom env var name:

```sh
Expand Down
27 changes: 19 additions & 8 deletions apps/web/src/app/(onboarding)/setup/StepInferenceProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { toast } from 'sonner';
import {
CHATGPT_SUBSCRIPTION_PROVIDER_ID,
OPENAI_COMPATIBLE_PROVIDER_ID,
getDefaultAdditionalEnvValues,
getSetupModelProvider,
type SetupModelProviderId,
type SetupModelStatus,
} from '@roomote/types';
Expand All @@ -23,6 +25,7 @@ import {
SelectValue,
Spinner,
} from '@/components/system';
import { AdditionalEnvFieldInput } from '@/components/settings/AdditionalEnvFieldInput';
import { ChatGptConnectDialog } from '@/components/settings/ChatGptConnectDialog';
import { GitHubCopilotConnectDialog } from '@/components/settings/GitHubCopilotConnectDialog';

Expand Down Expand Up @@ -133,7 +136,16 @@ export function StepInferenceProvider({
: '',
);
setConnectionName('');
setAdditionalEnvValues({});
// Seeded from the catalog rather than the fetched status so this effect
// stays keyed on `selectedProvider` alone; depending on the status query
// would reset in-progress input on every refetch.
setAdditionalEnvValues(
getDefaultAdditionalEnvValues(
selectedProvider
? (getSetupModelProvider(selectedProvider).additionalEnvFields ?? [])
: [],
),
);
setEditingSavedValue(false);
setIsChatGptDialogOpen(false);
setIsGitHubCopilotDialogOpen(false);
Expand Down Expand Up @@ -452,19 +464,18 @@ export function StepInferenceProvider({
{field.label}
{field.required ? '' : ' (optional)'}
</span>
<Input
secret={field.secret}
<AdditionalEnvFieldInput
field={field}
value={additionalEnvValues[field.envVarName] ?? ''}
onChange={(event) =>
onValueChange={(value) =>
setAdditionalEnvValues((values) => ({
...values,
[field.envVarName]: event.target.value,
[field.envVarName]: value,
}))
}
placeholder={field.placeholder}
disabled={saveModelConfig.isPending}
aria-label={`${field.label} for ${selectedProviderStatus?.label ?? 'provider'}`}
data-1p-ignore
ariaLabel={`${field.label} for ${selectedProviderStatus?.label ?? 'provider'}`}
selectTriggerClassName="min-w-44"
/>
</div>
))}
Expand Down
72 changes: 72 additions & 0 deletions apps/web/src/components/settings/AdditionalEnvFieldInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'use client';

import type { SetupModelProviderEnvField } from '@roomote/types';

import {
Input,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/system';

/**
* One additional provider env field on a connect surface: a select when the
* field declares options, a text input otherwise. Shared by the settings
* dialog and the onboarding step so both render a field the same way.
*/
export function AdditionalEnvFieldInput({
field,
value,
onValueChange,
disabled,
ariaLabel,
inputClassName,
selectTriggerClassName,
}: {
field: SetupModelProviderEnvField;
value: string;
onValueChange: (value: string) => void;
disabled: boolean;
ariaLabel: string;
inputClassName?: string;
selectTriggerClassName?: string;
}) {
if (field.options && field.options.length > 0) {
return (
<Select
value={value || field.options[0]?.value || ''}
onValueChange={onValueChange}
disabled={disabled}
>
<SelectTrigger
className={selectTriggerClassName}
aria-label={ariaLabel}
>
<SelectValue placeholder={field.placeholder ?? field.label} />
</SelectTrigger>
<SelectContent>
{field.options.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</SelectContent>
</Select>
);
}

return (
<Input
secret={field.secret}
className={inputClassName}
value={value}
onChange={(event) => onValueChange(event.target.value)}
placeholder={field.placeholder}
disabled={disabled}
aria-label={ariaLabel}
data-1p-ignore
/>
);
}
Loading
Loading