Fix: Add Chutes and Cerebras provider config to opencode.json

When models from providers like Chutes or Cerebras were added via the admin panel,
they didn't work in the builder page because the opencode.json config file only
included the Ollama provider configuration.

This fix adds Chutes and Cerebras provider configurations to the opencode.json
file when their respective API keys are available in environment variables
(CHUTES_API_KEY and CEREBRAS_API_KEY).

Fixes the issue where chutes/deepseek-ai/DeepSeek-V3.2-TEE and similar models
would fail to load from the builder page.
This commit is contained in:
southseact-3d
2026-02-10 19:51:39 +00:00
parent 8b96273f47
commit 566442327a

View File

@@ -5116,6 +5116,31 @@ async function ensureOpencodeConfig(session) {
providerCfg.options.apiKey = OPENCODE_OLLAMA_API_KEY;
}
const providers = {
[providerName]: providerCfg
};
// Add Chutes provider if API key is configured
if (CHUTES_API_KEY) {
providers.chutes = {
options: {
apiKey: CHUTES_API_KEY
},
models: {}
};
}
// Add Cerebras provider if API key is configured
const cerebrasKey = process.env.CEREBRAS_API_KEY;
if (cerebrasKey) {
providers.cerebras = {
options: {
apiKey: cerebrasKey
},
models: {}
};
}
const config = {
$schema: 'https://opencode.ai/config.json',
model: `${providerName}/${modelId}`,
@@ -5127,10 +5152,8 @@ async function ensureOpencodeConfig(session) {
[`apps/${userSegment}/${appSegment}/*`]: 'allow'
}
},
provider: {
[providerName]: providerCfg
}
};
provider: providers
};
const configPath = path.join(session.workspaceDir, 'opencode.json');