Add Nebius Token Factory support (merged with Xiaomi changes)

This commit is contained in:
kiranchilledout 2026-01-30 03:23:40 +05:30
parent 4583f88626
commit b54ca634f5
16 changed files with 376 additions and 181 deletions

View File

@ -118,6 +118,10 @@ Moltbot ships with the piai catalog. These providers require **no**
- OpenAI-compatible base URL: `https://api.cerebras.ai/v1`. - OpenAI-compatible base URL: `https://api.cerebras.ai/v1`.
- Mistral: `mistral` (`MISTRAL_API_KEY`) - Mistral: `mistral` (`MISTRAL_API_KEY`)
- GitHub Copilot: `github-copilot` (`COPILOT_GITHUB_TOKEN` / `GH_TOKEN` / `GITHUB_TOKEN`) - GitHub Copilot: `github-copilot` (`COPILOT_GITHUB_TOKEN` / `GH_TOKEN` / `GITHUB_TOKEN`)
- Nebius: `nebius` (`NEBIUS_API_KEY`)
- Example model: `Qwen/Qwen3-32B-fast` (recommended default)
- Available: Qwen, Llama, DeepSeek, GLM, and other open models
- OpenAI-compatible base URL: `https://api.tokenfactory.nebius.com/v1/`
## Providers via `models.providers` (custom/base URL) ## Providers via `models.providers` (custom/base URL)

View File

@ -2608,6 +2608,56 @@ Notes:
- Override the agent config root with `CLAWDBOT_AGENT_DIR` (or `PI_CODING_AGENT_DIR`) - Override the agent config root with `CLAWDBOT_AGENT_DIR` (or `PI_CODING_AGENT_DIR`)
if you want `models.json` stored elsewhere (default: `~/.clawdbot/agents/main/agent`). if you want `models.json` stored elsewhere (default: `~/.clawdbot/agents/main/agent`).
### Nebius (GLM 7 / GLM 5)
Use Nebius via their OpenAI-compatible endpoint:
```json5
{
env: {
NEBIUS_API_KEY: "" },
agents: {
defaults: {
model: {
primary: "Qwen/Qwen3-32B-fast",
fallbacks: ["meta-llama/Llama-3.3-70B-Instruct-fast"]
},
models: {
"Qwen/Qwen3-32B-fast": { alias: "Qwen3 32B Fast" },
"meta-llama/Llama-3.3-70B-Instruct-fast": { alias: "Llama 3.3 70B Fast" },
"deepseek-ai/DeepSeek-R1-0528-fast": { alias: "DeepSeek R1 Fast" },
"Qwen/Qwen2.5-VL-72B-Instruct": { alias: "Qwen2.5 VL 72B" }
}
}
},
models: {
mode: "merge",
providers: {
nebius: {
baseUrl: "https://api.tokenfactory.nebius.com/v1",
apiKey: "${NEBIUS_API_KEY}",
api: "openai-completions",
models: [
{ id: "Qwen/Qwen3-32B-fast", name: "Qwen3 32B Fast" },
{ id: "meta-llama/Meta-Llama-3.1-8B-Instruct-fast", name: "Llama 3.1 8B Fast" },
{ id: "meta-llama/Llama-3.3-70B-Instruct", name: "Llama 3.3 70B" },
{ id: "meta-llama/Llama-3.3-70B-Instruct-fast", name: "Llama 3.3 70B Fast" },
{ id: "deepseek-ai/DeepSeek-V3-0324-fast", name: "DeepSeek V3 Fast" },
{ id: "deepseek-ai/DeepSeek-R1-0528-fast", name: "DeepSeek R1 Fast", reasoning: true },
{ id: "Qwen/Qwen2.5-VL-72B-Instruct", name: "Qwen2.5 VL 72B", input: ["text", "image"] },
{ id: "Qwen/Qwen2.5-Coder-7B-fast", name: "Qwen2.5 Coder 7B Fast" },
{ id: "intfloat/e5-mistral-7b-instruct", name: "e5 Mistral 7B" },
{ id: "zai-org/GLM-4.7-FP8", name: "GLM 4.7 FP8" },
{ id: "zai-org/GLM-4.5", name: "GLM 4.5" }
]
}
}
}
}
### `session` ### `session`
Controls session scoping, reset policy, reset triggers, and where the session store is written. Controls session scoping, reset policy, reset triggers, and where the session store is written.

View File

@ -42,11 +42,11 @@ See [Venice AI](/providers/venice).
- [OpenCode Zen](/providers/opencode) - [OpenCode Zen](/providers/opencode)
- [Amazon Bedrock](/bedrock) - [Amazon Bedrock](/bedrock)
- [Z.AI](/providers/zai) - [Z.AI](/providers/zai)
- [Xiaomi](/providers/xiaomi)
- [GLM models](/providers/glm) - [GLM models](/providers/glm)
- [MiniMax](/providers/minimax) - [MiniMax](/providers/minimax)
- [Venius (Venice AI, privacy-focused)](/providers/venice) - [Venius (Venice AI, privacy-focused)](/providers/venice)
- [Ollama (local models)](/providers/ollama) - [Ollama (local models)](/providers/ollama)
- [Nebius](/providers/nebius)
## Transcription providers ## Transcription providers

68
docs/providers/nebius.md Normal file
View File

@ -0,0 +1,68 @@
---
summary: "Use Nebius OpenAI-compatible inference for frontier and open-source models"
read_when:
- You want to use Nebius inference
- You want to use Qwen, Llama, DeepSeek, and other open models
---
# Nebius
Nebius provides **OpenAI-compatible inference** for frontier and open-source models, including **Qwen**, **Llama**, **DeepSeek**, and **GLM**, via the Nebius TokenFactory API. This allows seamless drop-in usage with existing OpenAI-style clients and tooling.
## CLI setup
```bash
clawdbot onboard --auth-choice nebius-api-key
# or non-interactive
clawdbot onboard --nebius-api-key "$NEBIUS_API_KEY"
```
## Config snippet
```json5
{
env: { NEBIUS_API_KEY: "sk-..." },
agents: {
defaults: {
model: {
primary: "Qwen/Qwen3-32B-fast",
fallbacks: ["meta-llama/Llama-3.3-70B-Instruct-fast"]
}
}
}
}
```
## Available models
### Daily Driver (Fast, Capable)
- `Qwen/Qwen3-32B-fast` Qwen3 32B Fast (recommended default)
### Lightweight (Fast, Basic)
- `meta-llama/Meta-Llama-3.1-8B-Instruct-fast` Llama 3.1 8B Fast
### Heavy Lifting (More Complex)
- `meta-llama/Llama-3.3-70B-Instruct` Llama 3.3 70B
- `meta-llama/Llama-3.3-70B-Instruct-fast` Llama 3.3 70B Fast
- `deepseek-ai/DeepSeek-V3-0324-fast` DeepSeek V3 Fast
### Specialized (Reasoning)
- `deepseek-ai/DeepSeek-R1-0528-fast` DeepSeek R1 Fast
### Vision
- `Qwen/Qwen2.5-VL-72B-Instruct` Qwen2.5 VL 72B
### Coding
- `Qwen/Qwen2.5-Coder-7B-fast` Qwen2.5 Coder 7B Fast
### GLM Models
- `zai-org/GLM-4.7-FP8` GLM 4.7 FP8
- `zai-org/GLM-4.5` GLM 4.5
## Notes
- Base URL: https://api.tokenfactory.nebius.com/v1
- OpenAI-compatible Chat Completions API
- Model refs use nebius/<model> format
- Set NEBIUS_API_KEY in the environment or config
- Works with standard OpenAI SDKs (Python, JS, etc.)

View File

@ -281,11 +281,11 @@ export function resolveEnvApiKey(provider: string): EnvApiKeyResult | null {
moonshot: "MOONSHOT_API_KEY", moonshot: "MOONSHOT_API_KEY",
"kimi-code": "KIMICODE_API_KEY", "kimi-code": "KIMICODE_API_KEY",
minimax: "MINIMAX_API_KEY", minimax: "MINIMAX_API_KEY",
xiaomi: "XIAOMI_API_KEY",
synthetic: "SYNTHETIC_API_KEY", synthetic: "SYNTHETIC_API_KEY",
venice: "VENICE_API_KEY", venice: "VENICE_API_KEY",
mistral: "MISTRAL_API_KEY", mistral: "MISTRAL_API_KEY",
opencode: "OPENCODE_API_KEY", opencode: "OPENCODE_API_KEY",
nebius: "NEBIUS_API_KEY",
}; };
const envVar = envMap[normalized]; const envVar = envMap[normalized];
if (!envVar) return null; if (!envVar) return null;

View File

@ -30,17 +30,6 @@ const MINIMAX_API_COST = {
cacheWrite: 10, cacheWrite: 10,
}; };
const XIAOMI_BASE_URL = "https://api.xiaomimimo.com/anthropic";
export const XIAOMI_DEFAULT_MODEL_ID = "mimo-v2-flash";
const XIAOMI_DEFAULT_CONTEXT_WINDOW = 262144;
const XIAOMI_DEFAULT_MAX_TOKENS = 8192;
const XIAOMI_DEFAULT_COST = {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
};
const MOONSHOT_BASE_URL = "https://api.moonshot.ai/v1"; const MOONSHOT_BASE_URL = "https://api.moonshot.ai/v1";
const MOONSHOT_DEFAULT_MODEL_ID = "kimi-k2.5"; const MOONSHOT_DEFAULT_MODEL_ID = "kimi-k2.5";
const MOONSHOT_DEFAULT_CONTEXT_WINDOW = 256000; const MOONSHOT_DEFAULT_CONTEXT_WINDOW = 256000;
@ -75,6 +64,16 @@ const QWEN_PORTAL_DEFAULT_COST = {
cacheWrite: 0, cacheWrite: 0,
}; };
const NEBIUS_BASE_URL = "https://api.tokenfactory.nebius.com/v1";
const NEBIUS_DEFAULT_CONTEXT_WINDOW = 128000;
const NEBIUS_DEFAULT_MAX_TOKENS = 8192;
const NEBIUS_DEFAULT_COST = {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
};
const OLLAMA_BASE_URL = "http://127.0.0.1:11434/v1"; const OLLAMA_BASE_URL = "http://127.0.0.1:11434/v1";
const OLLAMA_API_BASE_URL = "http://127.0.0.1:11434"; const OLLAMA_API_BASE_URL = "http://127.0.0.1:11434";
const OLLAMA_DEFAULT_CONTEXT_WINDOW = 128000; const OLLAMA_DEFAULT_CONTEXT_WINDOW = 128000;
@ -352,24 +351,6 @@ function buildSyntheticProvider(): ProviderConfig {
}; };
} }
export function buildXiaomiProvider(): ProviderConfig {
return {
baseUrl: XIAOMI_BASE_URL,
api: "anthropic-messages",
models: [
{
id: XIAOMI_DEFAULT_MODEL_ID,
name: "Xiaomi MiMo V2 Flash",
reasoning: false,
input: ["text"],
cost: XIAOMI_DEFAULT_COST,
contextWindow: XIAOMI_DEFAULT_CONTEXT_WINDOW,
maxTokens: XIAOMI_DEFAULT_MAX_TOKENS,
},
],
};
}
async function buildVeniceProvider(): Promise<ProviderConfig> { async function buildVeniceProvider(): Promise<ProviderConfig> {
const models = await discoverVeniceModels(); const models = await discoverVeniceModels();
return { return {
@ -388,6 +369,105 @@ async function buildOllamaProvider(): Promise<ProviderConfig> {
}; };
} }
function buildNebiusProvider(): ProviderConfig {
return {
baseUrl: NEBIUS_BASE_URL,
api: "openai-completions",
models: [
{
id: "Qwen/Qwen3-32B-fast",
name: "Qwen3 32B Fast",
reasoning: false,
input: ["text"],
cost: NEBIUS_DEFAULT_COST,
contextWindow: NEBIUS_DEFAULT_CONTEXT_WINDOW,
maxTokens: NEBIUS_DEFAULT_MAX_TOKENS,
},
{
id: "meta-llama/Meta-Llama-3.1-8B-Instruct-fast",
name: "Llama 3.1 8B Fast",
reasoning: false,
input: ["text"],
cost: NEBIUS_DEFAULT_COST,
contextWindow: NEBIUS_DEFAULT_CONTEXT_WINDOW,
maxTokens: NEBIUS_DEFAULT_MAX_TOKENS,
},
{
id: "meta-llama/Llama-3.3-70B-Instruct",
name: "Llama 3.3 70B",
reasoning: false,
input: ["text"],
cost: NEBIUS_DEFAULT_COST,
contextWindow: NEBIUS_DEFAULT_CONTEXT_WINDOW,
maxTokens: NEBIUS_DEFAULT_MAX_TOKENS,
},
{
id: "meta-llama/Llama-3.3-70B-Instruct-fast",
name: "Llama 3.3 70B Fast",
reasoning: false,
input: ["text"],
cost: NEBIUS_DEFAULT_COST,
contextWindow: NEBIUS_DEFAULT_CONTEXT_WINDOW,
maxTokens: NEBIUS_DEFAULT_MAX_TOKENS,
},
{
id: "deepseek-ai/DeepSeek-V3-0324-fast",
name: "DeepSeek V3 Fast",
reasoning: false,
input: ["text"],
cost: NEBIUS_DEFAULT_COST,
contextWindow: NEBIUS_DEFAULT_CONTEXT_WINDOW,
maxTokens: NEBIUS_DEFAULT_MAX_TOKENS,
},
{
id: "deepseek-ai/DeepSeek-R1-0528-fast",
name: "DeepSeek R1 Fast",
reasoning: true,
input: ["text"],
cost: NEBIUS_DEFAULT_COST,
contextWindow: NEBIUS_DEFAULT_CONTEXT_WINDOW,
maxTokens: NEBIUS_DEFAULT_MAX_TOKENS,
},
{
id: "Qwen/Qwen2.5-VL-72B-Instruct",
name: "Qwen2.5 VL 72B",
reasoning: false,
input: ["text", "image"],
cost: NEBIUS_DEFAULT_COST,
contextWindow: NEBIUS_DEFAULT_CONTEXT_WINDOW,
maxTokens: NEBIUS_DEFAULT_MAX_TOKENS,
},
{
id: "Qwen/Qwen2.5-Coder-7B-fast",
name: "Qwen2.5 Coder 7B Fast",
reasoning: false,
input: ["text"],
cost: NEBIUS_DEFAULT_COST,
contextWindow: NEBIUS_DEFAULT_CONTEXT_WINDOW,
maxTokens: NEBIUS_DEFAULT_MAX_TOKENS,
},
{
id: "zai-org/GLM-4.7-FP8",
name: "GLM 4.7 FP8",
reasoning: false,
input: ["text"],
cost: NEBIUS_DEFAULT_COST,
contextWindow: NEBIUS_DEFAULT_CONTEXT_WINDOW,
maxTokens: NEBIUS_DEFAULT_MAX_TOKENS,
},
{
id: "zai-org/GLM-4.5",
name: "GLM 4.5",
reasoning: false,
input: ["text"],
cost: NEBIUS_DEFAULT_COST,
contextWindow: NEBIUS_DEFAULT_CONTEXT_WINDOW,
maxTokens: NEBIUS_DEFAULT_MAX_TOKENS,
},
],
};
}
export async function resolveImplicitProviders(params: { export async function resolveImplicitProviders(params: {
agentDir: string; agentDir: string;
}): Promise<ModelsConfig["providers"]> { }): Promise<ModelsConfig["providers"]> {
@ -439,13 +519,6 @@ export async function resolveImplicitProviders(params: {
}; };
} }
const xiaomiKey =
resolveEnvApiKeyVarName("xiaomi") ??
resolveApiKeyFromProfiles({ provider: "xiaomi", store: authStore });
if (xiaomiKey) {
providers.xiaomi = { ...buildXiaomiProvider(), apiKey: xiaomiKey };
}
// Ollama provider - only add if explicitly configured // Ollama provider - only add if explicitly configured
const ollamaKey = const ollamaKey =
resolveEnvApiKeyVarName("ollama") ?? resolveEnvApiKeyVarName("ollama") ??
@ -454,6 +527,14 @@ export async function resolveImplicitProviders(params: {
providers.ollama = { ...(await buildOllamaProvider()), apiKey: ollamaKey }; providers.ollama = { ...(await buildOllamaProvider()), apiKey: ollamaKey };
} }
const nebiusKey =
resolveEnvApiKeyVarName("nebius") ??
resolveApiKeyFromProfiles({ provider: "nebius", store: authStore });
if (nebiusKey) {
providers.nebius = { ...buildNebiusProvider(), apiKey: nebiusKey };
}
return providers; return providers;
} }

View File

@ -25,6 +25,7 @@ const MODEL_PICK_PROVIDER_PREFERENCE = [
"mistral", "mistral",
"xai", "xai",
"lmstudio", "lmstudio",
"nebius",
] as const; ] as const;
const PROVIDER_RANK = new Map<string, number>( const PROVIDER_RANK = new Map<string, number>(

View File

@ -52,7 +52,7 @@ export function registerOnboardCommand(program: Command) {
.option("--mode <mode>", "Wizard mode: local|remote") .option("--mode <mode>", "Wizard mode: local|remote")
.option( .option(
"--auth-choice <choice>", "--auth-choice <choice>",
"Auth: setup-token|token|chutes|openai-codex|openai-api-key|openrouter-api-key|ai-gateway-api-key|moonshot-api-key|kimi-code-api-key|synthetic-api-key|venice-api-key|gemini-api-key|zai-api-key|xiaomi-api-key|apiKey|minimax-api|minimax-api-lightning|opencode-zen|skip", "Auth: setup-token|token|chutes|openai-codex|openai-api-key|openrouter-api-key|ai-gateway-api-key|moonshot-api-key|kimi-code-api-key|synthetic-api-key|venice-api-key|gemini-api-key|zai-api-key|apiKey|minimax-api|minimax-api-lightning|opencode-zen|skip",
) )
.option( .option(
"--token-provider <id>", "--token-provider <id>",
@ -72,11 +72,11 @@ export function registerOnboardCommand(program: Command) {
.option("--kimi-code-api-key <key>", "Kimi Code API key") .option("--kimi-code-api-key <key>", "Kimi Code API key")
.option("--gemini-api-key <key>", "Gemini API key") .option("--gemini-api-key <key>", "Gemini API key")
.option("--zai-api-key <key>", "Z.AI API key") .option("--zai-api-key <key>", "Z.AI API key")
.option("--xiaomi-api-key <key>", "Xiaomi API key")
.option("--minimax-api-key <key>", "MiniMax API key") .option("--minimax-api-key <key>", "MiniMax API key")
.option("--synthetic-api-key <key>", "Synthetic API key") .option("--synthetic-api-key <key>", "Synthetic API key")
.option("--venice-api-key <key>", "Venice API key") .option("--venice-api-key <key>", "Venice API key")
.option("--opencode-zen-api-key <key>", "OpenCode Zen API key") .option("--opencode-zen-api-key <key>", "OpenCode Zen API key")
.option("--nebius-api-key <key>", "Nebius API key")
.option("--gateway-port <port>", "Gateway port") .option("--gateway-port <port>", "Gateway port")
.option("--gateway-bind <mode>", "Gateway bind: loopback|tailnet|lan|auto|custom") .option("--gateway-bind <mode>", "Gateway bind: loopback|tailnet|lan|auto|custom")
.option("--gateway-auth <mode>", "Gateway auth: token|password") .option("--gateway-auth <mode>", "Gateway auth: token|password")
@ -123,7 +123,6 @@ export function registerOnboardCommand(program: Command) {
kimiCodeApiKey: opts.kimiCodeApiKey as string | undefined, kimiCodeApiKey: opts.kimiCodeApiKey as string | undefined,
geminiApiKey: opts.geminiApiKey as string | undefined, geminiApiKey: opts.geminiApiKey as string | undefined,
zaiApiKey: opts.zaiApiKey as string | undefined, zaiApiKey: opts.zaiApiKey as string | undefined,
xiaomiApiKey: opts.xiaomiApiKey as string | undefined,
minimaxApiKey: opts.minimaxApiKey as string | undefined, minimaxApiKey: opts.minimaxApiKey as string | undefined,
syntheticApiKey: opts.syntheticApiKey as string | undefined, syntheticApiKey: opts.syntheticApiKey as string | undefined,
veniceApiKey: opts.veniceApiKey as string | undefined, veniceApiKey: opts.veniceApiKey as string | undefined,

View File

@ -16,11 +16,11 @@ export type AuthChoiceGroupId =
| "ai-gateway" | "ai-gateway"
| "moonshot" | "moonshot"
| "zai" | "zai"
| "xiaomi"
| "opencode-zen" | "opencode-zen"
| "minimax" | "minimax"
| "synthetic" | "synthetic"
| "venice" | "venice"
| "nebius"
| "qwen"; | "qwen";
export type AuthChoiceGroup = { export type AuthChoiceGroup = {
@ -109,10 +109,10 @@ const AUTH_CHOICE_GROUP_DEFS: {
choices: ["zai-api-key"], choices: ["zai-api-key"],
}, },
{ {
value: "xiaomi", value: "nebius",
label: "Xiaomi", label: "Nebius",
hint: "API key", hint: "Nebius Token Factory",
choices: ["xiaomi-api-key"], choices: ["nebius-api-key"],
}, },
{ {
value: "opencode-zen", value: "opencode-zen",
@ -171,10 +171,6 @@ export function buildAuthChoiceOptions(params: {
hint: "Uses the bundled Gemini CLI auth plugin", hint: "Uses the bundled Gemini CLI auth plugin",
}); });
options.push({ value: "zai-api-key", label: "Z.AI (GLM 4.7) API key" }); options.push({ value: "zai-api-key", label: "Z.AI (GLM 4.7) API key" });
options.push({
value: "xiaomi-api-key",
label: "Xiaomi API key",
});
options.push({ value: "qwen-portal", label: "Qwen OAuth" }); options.push({ value: "qwen-portal", label: "Qwen OAuth" });
options.push({ options.push({
value: "copilot-proxy", value: "copilot-proxy",
@ -189,6 +185,11 @@ export function buildAuthChoiceOptions(params: {
hint: "Claude, GPT, Gemini via opencode.ai/zen", hint: "Claude, GPT, Gemini via opencode.ai/zen",
}); });
options.push({ value: "minimax-api", label: "MiniMax M2.1" }); options.push({ value: "minimax-api", label: "MiniMax M2.1" });
options.push({
value: "nebius-api-key",
label: "Nebius API key",
hint: "Nebius Token Factory)",
});
options.push({ options.push({
value: "minimax-api-lightning", value: "minimax-api-lightning",
label: "MiniMax M2.1 Lightning", label: "MiniMax M2.1 Lightning",

View File

@ -17,6 +17,8 @@ import {
applyKimiCodeProviderConfig, applyKimiCodeProviderConfig,
applyMoonshotConfig, applyMoonshotConfig,
applyMoonshotProviderConfig, applyMoonshotProviderConfig,
applyNebiusConfig,
applyNebiusProviderConfig,
applyOpencodeZenConfig, applyOpencodeZenConfig,
applyOpencodeZenProviderConfig, applyOpencodeZenProviderConfig,
applyOpenrouterConfig, applyOpenrouterConfig,
@ -27,25 +29,23 @@ import {
applyVeniceProviderConfig, applyVeniceProviderConfig,
applyVercelAiGatewayConfig, applyVercelAiGatewayConfig,
applyVercelAiGatewayProviderConfig, applyVercelAiGatewayProviderConfig,
applyXiaomiConfig,
applyXiaomiProviderConfig,
applyZaiConfig, applyZaiConfig,
KIMI_CODE_MODEL_REF, KIMI_CODE_MODEL_REF,
MOONSHOT_DEFAULT_MODEL_REF, MOONSHOT_DEFAULT_MODEL_REF,
NEBIUS_DEFAULT_MODEL_REF,
OPENROUTER_DEFAULT_MODEL_REF, OPENROUTER_DEFAULT_MODEL_REF,
SYNTHETIC_DEFAULT_MODEL_REF, SYNTHETIC_DEFAULT_MODEL_REF,
VENICE_DEFAULT_MODEL_REF, VENICE_DEFAULT_MODEL_REF,
VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF, VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF,
XIAOMI_DEFAULT_MODEL_REF,
setGeminiApiKey, setGeminiApiKey,
setKimiCodeApiKey, setKimiCodeApiKey,
setMoonshotApiKey, setMoonshotApiKey,
setNebiusApiKey,
setOpencodeZenApiKey, setOpencodeZenApiKey,
setOpenrouterApiKey, setOpenrouterApiKey,
setSyntheticApiKey, setSyntheticApiKey,
setVeniceApiKey, setVeniceApiKey,
setVercelAiGatewayApiKey, setVercelAiGatewayApiKey,
setXiaomiApiKey,
setZaiApiKey, setZaiApiKey,
ZAI_DEFAULT_MODEL_REF, ZAI_DEFAULT_MODEL_REF,
} from "./onboard-auth.js"; } from "./onboard-auth.js";
@ -83,12 +83,12 @@ export async function applyAuthChoiceApiProviders(
authChoice = "gemini-api-key"; authChoice = "gemini-api-key";
} else if (params.opts.tokenProvider === "zai") { } else if (params.opts.tokenProvider === "zai") {
authChoice = "zai-api-key"; authChoice = "zai-api-key";
} else if (params.opts.tokenProvider === "xiaomi") {
authChoice = "xiaomi-api-key";
} else if (params.opts.tokenProvider === "synthetic") { } else if (params.opts.tokenProvider === "synthetic") {
authChoice = "synthetic-api-key"; authChoice = "synthetic-api-key";
} else if (params.opts.tokenProvider === "venice") { } else if (params.opts.tokenProvider === "venice") {
authChoice = "venice-api-key"; authChoice = "venice-api-key";
} else if (params.opts.tokenProvider === "nebius") {
authChoice = "nebius-api-key";
} else if (params.opts.tokenProvider === "opencode") { } else if (params.opts.tokenProvider === "opencode") {
authChoice = "opencode-zen"; authChoice = "opencode-zen";
} }
@ -437,54 +437,6 @@ export async function applyAuthChoiceApiProviders(
return { config: nextConfig, agentModelOverride }; return { config: nextConfig, agentModelOverride };
} }
if (authChoice === "xiaomi-api-key") {
let hasCredential = false;
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "xiaomi") {
await setXiaomiApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
hasCredential = true;
}
const envKey = resolveEnvApiKey("xiaomi");
if (envKey) {
const useExisting = await params.prompter.confirm({
message: `Use existing XIAOMI_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
initialValue: true,
});
if (useExisting) {
await setXiaomiApiKey(envKey.apiKey, params.agentDir);
hasCredential = true;
}
}
if (!hasCredential) {
const key = await params.prompter.text({
message: "Enter Xiaomi API key",
validate: validateApiKeyInput,
});
await setXiaomiApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
}
nextConfig = applyAuthProfileConfig(nextConfig, {
profileId: "xiaomi:default",
provider: "xiaomi",
mode: "api_key",
});
{
const applied = await applyDefaultModelChoice({
config: nextConfig,
setDefaultModel: params.setDefaultModel,
defaultModel: XIAOMI_DEFAULT_MODEL_REF,
applyDefaultConfig: applyXiaomiConfig,
applyProviderConfig: applyXiaomiProviderConfig,
noteDefault: XIAOMI_DEFAULT_MODEL_REF,
noteAgentModel,
prompter: params.prompter,
});
nextConfig = applied.config;
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
}
return { config: nextConfig, agentModelOverride };
}
if (authChoice === "synthetic-api-key") { if (authChoice === "synthetic-api-key") {
if (params.opts?.token && params.opts?.tokenProvider === "synthetic") { if (params.opts?.token && params.opts?.tokenProvider === "synthetic") {
await setSyntheticApiKey(String(params.opts.token).trim(), params.agentDir); await setSyntheticApiKey(String(params.opts.token).trim(), params.agentDir);
@ -576,6 +528,69 @@ export async function applyAuthChoiceApiProviders(
return { config: nextConfig, agentModelOverride }; return { config: nextConfig, agentModelOverride };
} }
if (authChoice === "nebius-api-key") {
let hasCredential = false;
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "nebius") {
await setNebiusApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
hasCredential = true;
}
if (!hasCredential) {
await params.prompter.note(
[
"Nebius provides OpenAI-compatible inference for frontier and open models.",
"Get your API key at: https://tokenfactory.nebius.com/",
"Available models: zai-glm-7, zai-glm-5",
].join("\n"),
"Nebius",
);
}
const envKey = resolveEnvApiKey("nebius");
if (envKey) {
const useExisting = await params.prompter.confirm({
message: `Use existing NEBIUS_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
initialValue: true,
});
if (useExisting) {
await setNebiusApiKey(envKey.apiKey, params.agentDir);
hasCredential = true;
}
}
if (!hasCredential) {
const key = await params.prompter.text({
message: "Enter Nebius API key",
validate: validateApiKeyInput,
});
await setNebiusApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
}
nextConfig = applyAuthProfileConfig(nextConfig, {
profileId: "nebius:default",
provider: "nebius",
mode: "api_key",
});
{
const applied = await applyDefaultModelChoice({
config: nextConfig,
setDefaultModel: params.setDefaultModel,
defaultModel: NEBIUS_DEFAULT_MODEL_REF,
applyDefaultConfig: applyNebiusConfig,
applyProviderConfig: applyNebiusProviderConfig,
noteDefault: NEBIUS_DEFAULT_MODEL_REF,
noteAgentModel,
prompter: params.prompter,
});
nextConfig = applied.config;
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
}
return { config: nextConfig, agentModelOverride };
}
if (authChoice === "opencode-zen") { if (authChoice === "opencode-zen") {
let hasCredential = false; let hasCredential = false;
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "opencode") { if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "opencode") {

View File

@ -134,6 +134,7 @@ export async function modelsStatusCommand(
"zai", "zai",
"mistral", "mistral",
"synthetic", "synthetic",
"nebius",
]; ];
for (const provider of envProbeProviders) { for (const provider of envProbeProviders) {
if (resolveEnvApiKey(provider)) providersFromEnv.add(provider); if (resolveEnvApiKey(provider)) providersFromEnv.add(provider);

View File

@ -1,4 +1,3 @@
import { buildXiaomiProvider, XIAOMI_DEFAULT_MODEL_ID } from "../agents/models-config.providers.js";
import { import {
buildSyntheticModelDefinition, buildSyntheticModelDefinition,
SYNTHETIC_BASE_URL, SYNTHETIC_BASE_URL,
@ -15,7 +14,6 @@ import type { MoltbotConfig } from "../config/config.js";
import { import {
OPENROUTER_DEFAULT_MODEL_REF, OPENROUTER_DEFAULT_MODEL_REF,
VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF, VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF,
XIAOMI_DEFAULT_MODEL_REF,
ZAI_DEFAULT_MODEL_REF, ZAI_DEFAULT_MODEL_REF,
} from "./onboard-auth.credentials.js"; } from "./onboard-auth.credentials.js";
import { import {
@ -338,37 +336,17 @@ export function applySyntheticConfig(cfg: MoltbotConfig): MoltbotConfig {
}; };
} }
export function applyXiaomiProviderConfig(cfg: MoltbotConfig): MoltbotConfig { export function applyNebiusProviderConfig(cfg: MoltbotConfig): MoltbotConfig {
const models = { ...cfg.agents?.defaults?.models }; const models = { ...cfg.agents?.defaults?.models };
models[XIAOMI_DEFAULT_MODEL_REF] = {
...models[XIAOMI_DEFAULT_MODEL_REF], models["zai-org/GLM-4.7-FP8"] = {
alias: models[XIAOMI_DEFAULT_MODEL_REF]?.alias ?? "Xiaomi", ...models["zai-org/GLM-4.7-FP8"],
alias: models["zai-org/GLM-4.7-FP8"]?.alias ?? "GLM 7",
}; };
const providers = { ...cfg.models?.providers }; models["zai-org/GLM-4.5"] = {
const existingProvider = providers.xiaomi; ...models["zai-org/GLM-4.5"],
const defaultProvider = buildXiaomiProvider(); alias: models["zai-org/GLM-4.5"]?.alias ?? "GLM 5",
const existingModels = Array.isArray(existingProvider?.models) ? existingProvider.models : [];
const defaultModels = defaultProvider.models ?? [];
const hasDefaultModel = existingModels.some((model) => model.id === XIAOMI_DEFAULT_MODEL_ID);
const mergedModels =
existingModels.length > 0
? hasDefaultModel
? existingModels
: [...existingModels, ...defaultModels]
: defaultModels;
const { apiKey: existingApiKey, ...existingProviderRest } = (existingProvider ?? {}) as Record<
string,
unknown
> as { apiKey?: string };
const resolvedApiKey = typeof existingApiKey === "string" ? existingApiKey : undefined;
const normalizedApiKey = resolvedApiKey?.trim();
providers.xiaomi = {
...existingProviderRest,
baseUrl: defaultProvider.baseUrl,
api: defaultProvider.api,
...(normalizedApiKey ? { apiKey: normalizedApiKey } : {}),
models: mergedModels.length > 0 ? mergedModels : defaultProvider.models,
}; };
return { return {
@ -380,16 +358,13 @@ export function applyXiaomiProviderConfig(cfg: MoltbotConfig): MoltbotConfig {
models, models,
}, },
}, },
models: {
mode: cfg.models?.mode ?? "merge",
providers,
},
}; };
} }
export function applyXiaomiConfig(cfg: MoltbotConfig): MoltbotConfig { export function applyNebiusConfig(cfg: MoltbotConfig): MoltbotConfig {
const next = applyXiaomiProviderConfig(cfg); const next = applyNebiusProviderConfig(cfg);
const existingModel = next.agents?.defaults?.model; const existingModel = next.agents?.defaults?.model;
return { return {
...next, ...next,
agents: { agents: {
@ -402,7 +377,7 @@ export function applyXiaomiConfig(cfg: MoltbotConfig): MoltbotConfig {
fallbacks: (existingModel as { fallbacks?: string[] }).fallbacks, fallbacks: (existingModel as { fallbacks?: string[] }).fallbacks,
} }
: undefined), : undefined),
primary: XIAOMI_DEFAULT_MODEL_REF, primary: "zai-org/GLM-4.7-FP8",
}, },
}, },
}, },

View File

@ -113,9 +113,9 @@ export async function setVeniceApiKey(key: string, agentDir?: string) {
} }
export const ZAI_DEFAULT_MODEL_REF = "zai/glm-4.7"; export const ZAI_DEFAULT_MODEL_REF = "zai/glm-4.7";
export const XIAOMI_DEFAULT_MODEL_REF = "xiaomi/mimo-v2-flash";
export const OPENROUTER_DEFAULT_MODEL_REF = "openrouter/auto"; export const OPENROUTER_DEFAULT_MODEL_REF = "openrouter/auto";
export const VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF = "vercel-ai-gateway/anthropic/claude-opus-4.5"; export const VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF = "vercel-ai-gateway/anthropic/claude-opus-4.5";
export const NEBIUS_DEFAULT_MODEL_REF = "Qwen/Qwen3-32B-fast";
export async function setZaiApiKey(key: string, agentDir?: string) { export async function setZaiApiKey(key: string, agentDir?: string) {
// Write to resolved agent dir so gateway finds credentials on startup. // Write to resolved agent dir so gateway finds credentials on startup.
@ -130,18 +130,6 @@ export async function setZaiApiKey(key: string, agentDir?: string) {
}); });
} }
export async function setXiaomiApiKey(key: string, agentDir?: string) {
upsertAuthProfile({
profileId: "xiaomi:default",
credential: {
type: "api_key",
provider: "xiaomi",
key,
},
agentDir: resolveAuthAgentDir(agentDir),
});
}
export async function setOpenrouterApiKey(key: string, agentDir?: string) { export async function setOpenrouterApiKey(key: string, agentDir?: string) {
upsertAuthProfile({ upsertAuthProfile({
profileId: "openrouter:default", profileId: "openrouter:default",
@ -177,3 +165,15 @@ export async function setOpencodeZenApiKey(key: string, agentDir?: string) {
agentDir: resolveAuthAgentDir(agentDir), agentDir: resolveAuthAgentDir(agentDir),
}); });
} }
export async function setNebiusApiKey(key: string, agentDir?: string) {
upsertAuthProfile({
profileId: "nebius:default",
credential: {
type: "api_key",
provider: "nebius",
key,
},
agentDir: resolveAuthAgentDir(agentDir),
});
}

View File

@ -9,6 +9,8 @@ export {
applyKimiCodeProviderConfig, applyKimiCodeProviderConfig,
applyMoonshotConfig, applyMoonshotConfig,
applyMoonshotProviderConfig, applyMoonshotProviderConfig,
applyNebiusConfig,
applyNebiusProviderConfig,
applyOpenrouterConfig, applyOpenrouterConfig,
applyOpenrouterProviderConfig, applyOpenrouterProviderConfig,
applySyntheticConfig, applySyntheticConfig,
@ -17,8 +19,6 @@ export {
applyVeniceProviderConfig, applyVeniceProviderConfig,
applyVercelAiGatewayConfig, applyVercelAiGatewayConfig,
applyVercelAiGatewayProviderConfig, applyVercelAiGatewayProviderConfig,
applyXiaomiConfig,
applyXiaomiProviderConfig,
applyZaiConfig, applyZaiConfig,
} from "./onboard-auth.config-core.js"; } from "./onboard-auth.config-core.js";
export { export {
@ -36,21 +36,21 @@ export {
} from "./onboard-auth.config-opencode.js"; } from "./onboard-auth.config-opencode.js";
export { export {
OPENROUTER_DEFAULT_MODEL_REF, OPENROUTER_DEFAULT_MODEL_REF,
NEBIUS_DEFAULT_MODEL_REF,
setAnthropicApiKey, setAnthropicApiKey,
setGeminiApiKey, setGeminiApiKey,
setKimiCodeApiKey, setKimiCodeApiKey,
setMinimaxApiKey, setMinimaxApiKey,
setMoonshotApiKey, setMoonshotApiKey,
setNebiusApiKey,
setOpencodeZenApiKey, setOpencodeZenApiKey,
setOpenrouterApiKey, setOpenrouterApiKey,
setSyntheticApiKey, setSyntheticApiKey,
setVeniceApiKey, setVeniceApiKey,
setVercelAiGatewayApiKey, setVercelAiGatewayApiKey,
setXiaomiApiKey,
setZaiApiKey, setZaiApiKey,
writeOAuthCredentials, writeOAuthCredentials,
VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF, VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF,
XIAOMI_DEFAULT_MODEL_REF,
ZAI_DEFAULT_MODEL_REF, ZAI_DEFAULT_MODEL_REF,
} from "./onboard-auth.credentials.js"; } from "./onboard-auth.credentials.js";
export { export {

View File

@ -12,24 +12,24 @@ import {
applyMinimaxApiConfig, applyMinimaxApiConfig,
applyMinimaxConfig, applyMinimaxConfig,
applyMoonshotConfig, applyMoonshotConfig,
applyNebiusConfig,
applyOpencodeZenConfig, applyOpencodeZenConfig,
applyOpenrouterConfig, applyOpenrouterConfig,
applySyntheticConfig, applySyntheticConfig,
applyVeniceConfig, applyVeniceConfig,
applyVercelAiGatewayConfig, applyVercelAiGatewayConfig,
applyXiaomiConfig,
applyZaiConfig, applyZaiConfig,
setAnthropicApiKey, setAnthropicApiKey,
setGeminiApiKey, setGeminiApiKey,
setKimiCodeApiKey, setKimiCodeApiKey,
setMinimaxApiKey, setMinimaxApiKey,
setMoonshotApiKey, setMoonshotApiKey,
setNebiusApiKey,
setOpencodeZenApiKey, setOpencodeZenApiKey,
setOpenrouterApiKey, setOpenrouterApiKey,
setSyntheticApiKey, setSyntheticApiKey,
setVeniceApiKey, setVeniceApiKey,
setVercelAiGatewayApiKey, setVercelAiGatewayApiKey,
setXiaomiApiKey,
setZaiApiKey, setZaiApiKey,
} from "../../onboard-auth.js"; } from "../../onboard-auth.js";
import type { AuthChoice, OnboardOptions } from "../../onboard-types.js"; import type { AuthChoice, OnboardOptions } from "../../onboard-types.js";
@ -179,25 +179,6 @@ export async function applyNonInteractiveAuthChoice(params: {
return applyZaiConfig(nextConfig); return applyZaiConfig(nextConfig);
} }
if (authChoice === "xiaomi-api-key") {
const resolved = await resolveNonInteractiveApiKey({
provider: "xiaomi",
cfg: baseConfig,
flagValue: opts.xiaomiApiKey,
flagName: "--xiaomi-api-key",
envVar: "XIAOMI_API_KEY",
runtime,
});
if (!resolved) return null;
if (resolved.source !== "profile") await setXiaomiApiKey(resolved.key);
nextConfig = applyAuthProfileConfig(nextConfig, {
profileId: "xiaomi:default",
provider: "xiaomi",
mode: "api_key",
});
return applyXiaomiConfig(nextConfig);
}
if (authChoice === "openai-api-key") { if (authChoice === "openai-api-key") {
const resolved = await resolveNonInteractiveApiKey({ const resolved = await resolveNonInteractiveApiKey({
provider: "openai", provider: "openai",
@ -357,6 +338,25 @@ export async function applyNonInteractiveAuthChoice(params: {
if (authChoice === "minimax") return applyMinimaxConfig(nextConfig); if (authChoice === "minimax") return applyMinimaxConfig(nextConfig);
if (authChoice === "nebius-api-key") {
const resolved = await resolveNonInteractiveApiKey({
provider: "nebius",
cfg: baseConfig,
flagValue: opts.nebiusApiKey,
flagName: "--nebius-api-key",
envVar: "NEBIUS_API_KEY",
runtime,
});
if (!resolved) return null;
if (resolved.source !== "profile") await setNebiusApiKey(resolved.key);
nextConfig = applyAuthProfileConfig(nextConfig, {
profileId: "nebius:default",
provider: "nebius",
mode: "api_key",
});
return applyNebiusConfig(nextConfig);
}
if (authChoice === "opencode-zen") { if (authChoice === "opencode-zen") {
const resolved = await resolveNonInteractiveApiKey({ const resolved = await resolveNonInteractiveApiKey({
provider: "opencode", provider: "opencode",

View File

@ -23,11 +23,11 @@ export type AuthChoice =
| "google-antigravity" | "google-antigravity"
| "google-gemini-cli" | "google-gemini-cli"
| "zai-api-key" | "zai-api-key"
| "xiaomi-api-key"
| "minimax-cloud" | "minimax-cloud"
| "minimax" | "minimax"
| "minimax-api" | "minimax-api"
| "minimax-api-lightning" | "minimax-api-lightning"
| "nebius-api-key"
| "opencode-zen" | "opencode-zen"
| "github-copilot" | "github-copilot"
| "copilot-proxy" | "copilot-proxy"
@ -68,8 +68,8 @@ export type OnboardOptions = {
kimiCodeApiKey?: string; kimiCodeApiKey?: string;
geminiApiKey?: string; geminiApiKey?: string;
zaiApiKey?: string; zaiApiKey?: string;
xiaomiApiKey?: string;
minimaxApiKey?: string; minimaxApiKey?: string;
nebiusApiKey?: string;
syntheticApiKey?: string; syntheticApiKey?: string;
veniceApiKey?: string; veniceApiKey?: string;
opencodeZenApiKey?: string; opencodeZenApiKey?: string;