diff --git a/chat/server.js b/chat/server.js index 548cb3c..c7219bc 100644 --- a/chat/server.js +++ b/chat/server.js @@ -512,7 +512,7 @@ const PLAN_PRICES = { }; const AUTO_MODEL_TOKEN = 'auto'; const DEFAULT_PROVIDER_FALLBACK = 'opencode'; -const DEFAULT_PROVIDER_SEEDS = ['openrouter', 'mistral', 'google', 'groq', 'nvidia', 'chutes', 'cerebras', 'ollama', DEFAULT_PROVIDER_FALLBACK, 'cohere']; +const DEFAULT_PROVIDER_SEEDS = ['openrouter', 'mistral', 'google', 'groq', 'nvidia', 'chutes', 'cerebras', 'ollama', DEFAULT_PROVIDER_FALLBACK, 'cohere', 'kilo']; const PROVIDER_PERSIST_DEBOUNCE_MS = 200; const TOKEN_ESTIMATION_BUFFER = 400; const BOOST_PACK_SIZE = 500_000; @@ -1539,7 +1539,7 @@ let mistralSettings = { backupModel2: MISTRAL_MODEL_BACKUP_2, backupModel3: MISTRAL_MODEL_BACKUP_3, }; -const PLANNING_PROVIDERS = ['openrouter', 'mistral', 'google', 'groq', 'nvidia', 'ollama', 'cohere']; +const PLANNING_PROVIDERS = ['openrouter', 'mistral', 'google', 'groq', 'nvidia', 'ollama', 'cohere', 'kilo']; let planSettings = { provider: 'openrouter', // legacy field, retained for backwards compatibility freePlanModel: '', @@ -5229,6 +5229,10 @@ async function ensureOpencodeConfig(session) { nvidia: { apiKey: NVIDIA_API_KEY, baseURL: 'https://integrate.api.nvidia.com/v1' + }, + kilo: { + apiKey: process.env.KILO_API_KEY, + baseURL: 'https://api.kilo.ai/api/gateway' } }; @@ -16177,6 +16181,7 @@ async function handleAdminEnvConfig(req, res) { const mistralKey = process.env.MISTRAL_API_KEY || process.env.MISTRAL_API_TOKEN || ''; const openrouterKey = process.env.OPENROUTER_API_KEY || process.env.OPENROUTER_API_TOKEN || ''; const chutesKey = process.env.PLUGIN_COMPASS_CHUTES_API_KEY || process.env.CHUTES_API_KEY || process.env.CHUTES_API_TOKEN || ''; + const kiloKey = process.env.KILO_API_KEY || ''; const payload = { GROQ: { @@ -16199,6 +16204,11 @@ async function handleAdminEnvConfig(req, res) { prefix: chutesKey ? `${chutesKey.substring(0, 8)}...` : null, source: chutesKey ? (process.env.PLUGIN_COMPASS_CHUTES_API_KEY ? 'PLUGIN_COMPASS_CHUTES_API_KEY' : process.env.CHUTES_API_KEY ? 'CHUTES_API_KEY' : 'CHUTES_API_TOKEN') : null, }, + KILO: { + configured: !!kiloKey, + prefix: kiloKey ? `${kiloKey.substring(0, 8)}...` : null, + source: kiloKey ? 'KILO_API_KEY' : null, + }, }; sendJson(res, 200, { ok: true, env: payload }); diff --git a/opencode/packages/opencode/src/cli/cmd/auth.ts b/opencode/packages/opencode/src/cli/cmd/auth.ts index 34e2269..befe579 100644 --- a/opencode/packages/opencode/src/cli/cmd/auth.ts +++ b/opencode/packages/opencode/src/cli/cmd/auth.ts @@ -358,6 +358,12 @@ export const AuthLoginCommand = cmd({ ) } + if (provider === "kilo") { + prompts.log.info( + "Get your Kilo Gateway API key at https://app.kilo.ai/api-keys", + ) + } + const key = await prompts.password({ message: "Enter your API key", validate: (x) => (x && x.length > 0 ? undefined : "Required"), diff --git a/opencode/packages/opencode/src/provider/provider.ts b/opencode/packages/opencode/src/provider/provider.ts index be87e29..bc6e940 100644 --- a/opencode/packages/opencode/src/provider/provider.ts +++ b/opencode/packages/opencode/src/provider/provider.ts @@ -636,6 +636,24 @@ export namespace Provider { options: {}, } }, + kilo: async (input) => { + const apiKey = await (async () => { + const envKey = Env.get("KILO_API_KEY") + if (envKey) return envKey + const auth = await Auth.get(input.id) + if (auth?.type === "api") return auth.key + return undefined + })() + + if (!apiKey) { + return { autoload: false } + } + + return { + autoload: true, + options: {}, + } + }, } export const Model = z