Skip to content
Open
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
151 changes: 150 additions & 1 deletion packages/opencode/src/provider/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,158 @@ export namespace ModelsDev {
return JSON.parse(json)
})

export const BUILTIN_PROVIDERS: Record<string, Provider> = {
"bailian-coding-plan": {
id: "bailian-coding-plan",
env: ["BAILIAN_CODING_PLAN_API_KEY"],
npm: "@ai-sdk/anthropic",
api: "https://coding.dashscope.aliyuncs.com/apps/anthropic/v1",
name: "Model Studio Coding Plan",
models: {
"qwen3.5-plus": {
id: "qwen3.5-plus",
name: "Qwen3.5 Plus",
family: "qwen",
attachment: true,
reasoning: true,
tool_call: true,
temperature: true,
release_date: "2024-09-01",
modalities: { input: ["text", "image"], output: ["text"] },
cost: { input: 0, output: 0 },
limit: { context: 131072, output: 8192 },
options: {
thinking: {
type: "enabled",
budgetTokens: 1024,
},
},
},
"qwen3-max-2026-01-23": {
id: "qwen3-max-2026-01-23",
name: "Qwen3 Max 2026-01-23",
family: "qwen",
attachment: true,
reasoning: false,
tool_call: true,
temperature: true,
release_date: "2026-01-23",
modalities: { input: ["text", "image"], output: ["text"] },
cost: { input: 0, output: 0 },
limit: { context: 131072, output: 8192 },
options: {},
},
"qwen3-coder-next": {
id: "qwen3-coder-next",
name: "Qwen3 Coder Next",
family: "qwen",
attachment: true,
reasoning: false,
tool_call: true,
temperature: true,
release_date: "2025-01-01",
modalities: { input: ["text", "image"], output: ["text"] },
cost: { input: 0, output: 0 },
limit: { context: 131072, output: 8192 },
options: {},
},
"qwen3-coder-plus": {
id: "qwen3-coder-plus",
name: "Qwen3 Coder Plus",
family: "qwen",
attachment: true,
reasoning: false,
tool_call: true,
temperature: true,
release_date: "2025-01-01",
modalities: { input: ["text", "image"], output: ["text"] },
cost: { input: 0, output: 0 },
limit: { context: 131072, output: 8192 },
options: {},
},
"MiniMax-M2.5": {
id: "MiniMax-M2.5",
name: "MiniMax M2.5",
family: "minimax",
attachment: true,
reasoning: true,
tool_call: true,
temperature: true,
release_date: "2025-01-01",
modalities: { input: ["text", "image"], output: ["text"] },
cost: { input: 0, output: 0 },
limit: { context: 131072, output: 8192 },
options: {
thinking: {
type: "enabled",
budgetTokens: 1024,
},
},
},
"glm-5": {
id: "glm-5",
name: "GLM-5",
family: "glm",
attachment: true,
reasoning: true,
tool_call: true,
temperature: true,
release_date: "2025-01-01",
modalities: { input: ["text", "image"], output: ["text"] },
cost: { input: 0, output: 0 },
limit: { context: 131072, output: 8192 },
options: {
thinking: {
type: "enabled",
budgetTokens: 1024,
},
},
},
"glm-4.7": {
id: "glm-4.7",
name: "GLM-4.7",
family: "glm",
attachment: true,
reasoning: true,
tool_call: true,
temperature: true,
release_date: "2025-01-01",
modalities: { input: ["text", "image"], output: ["text"] },
cost: { input: 0, output: 0 },
limit: { context: 131072, output: 8192 },
options: {
thinking: {
type: "enabled",
budgetTokens: 1024,
},
},
},
"kimi-k2.5": {
id: "kimi-k2.5",
name: "Kimi K2.5",
family: "kimi",
attachment: true,
reasoning: true,
tool_call: true,
temperature: true,
release_date: "2025-01-01",
modalities: { input: ["text", "image"], output: ["text"] },
cost: { input: 0, output: 0 },
limit: { context: 131072, output: 8192 },
options: {
thinking: {
type: "enabled",
budgetTokens: 1024,
},
},
},
},
},
}

export async function get() {
const result = await Data()
return result as Record<string, Provider>
return { ...result, ...BUILTIN_PROVIDERS } as Record<string, Provider>
}

export async function refresh() {
Expand Down
17 changes: 17 additions & 0 deletions packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,23 @@ export namespace Provider {
},
}
},
"bailian-coding-plan": async (input) => {
const hasKey = await (async () => {
const env = Env.all()
if (input.env.some((item) => env[item])) return true
if (await Auth.get(input.id)) return true
const config = await Config.get()
if (config.provider?.["bailian-coding-plan"]?.options?.apiKey) return true
return false
})()

return {
autoload: hasKey,
options: {
baseURL: "https://coding.dashscope.aliyuncs.com/apps/anthropic/v1",
},
}
},
}

export const Model = z
Expand Down
138 changes: 138 additions & 0 deletions packages/opencode/test/tool/fixtures/models-api.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,142 @@
{
"bailian-coding-plan": {
"id": "bailian-coding-plan",
"env": ["BAILIAN_CODING_PLAN_API_KEY"],
"npm": "@ai-sdk/anthropic",
"api": "https://coding.dashscope.aliyuncs.com/apps/anthropic/v1",
"name": "Model Studio Coding Plan",
"doc": "https://help.aliyun.com/zh/model-studio/developer-reference/use-qwen-by-calling-api",
"models": {
"qwen3.5-plus": {
"id": "qwen3.5-plus",
"name": "Qwen3.5 Plus",
"family": "qwen",
"attachment": true,
"reasoning": true,
"tool_call": true,
"temperature": true,
"knowledge": "2024-09",
"release_date": "2024-09-01",
"last_updated": "2024-09-01",
"modalities": { "input": ["text", "image"], "output": ["text"] },
"open_weights": false,
"cost": { "input": 0, "output": 0 },
"limit": { "context": 131072, "output": 8192 }
},
"qwen3-max-2026-01-23": {
"id": "qwen3-max-2026-01-23",
"name": "Qwen3 Max 2026-01-23",
"family": "qwen",
"attachment": true,
"reasoning": false,
"tool_call": true,
"temperature": true,
"knowledge": "2025-01",
"release_date": "2026-01-23",
"last_updated": "2026-01-23",
"modalities": { "input": ["text", "image"], "output": ["text"] },
"open_weights": false,
"cost": { "input": 0, "output": 0 },
"limit": { "context": 131072, "output": 8192 }
},
"qwen3-coder-next": {
"id": "qwen3-coder-next",
"name": "Qwen3 Coder Next",
"family": "qwen",
"attachment": true,
"reasoning": false,
"tool_call": true,
"temperature": true,
"knowledge": "2025-01",
"release_date": "2025-01-01",
"last_updated": "2025-01-01",
"modalities": { "input": ["text", "image"], "output": ["text"] },
"open_weights": false,
"cost": { "input": 0, "output": 0 },
"limit": { "context": 131072, "output": 8192 }
},
"qwen3-coder-plus": {
"id": "qwen3-coder-plus",
"name": "Qwen3 Coder Plus",
"family": "qwen",
"attachment": true,
"reasoning": false,
"tool_call": true,
"temperature": true,
"knowledge": "2025-01",
"release_date": "2025-01-01",
"last_updated": "2025-01-01",
"modalities": { "input": ["text", "image"], "output": ["text"] },
"open_weights": false,
"cost": { "input": 0, "output": 0 },
"limit": { "context": 131072, "output": 8192 }
},
"MiniMax-M2.5": {
"id": "MiniMax-M2.5",
"name": "MiniMax M2.5",
"family": "minimax",
"attachment": true,
"reasoning": true,
"tool_call": true,
"temperature": true,
"knowledge": "2025-01",
"release_date": "2025-01-01",
"last_updated": "2025-01-01",
"modalities": { "input": ["text", "image"], "output": ["text"] },
"open_weights": false,
"cost": { "input": 0, "output": 0 },
"limit": { "context": 131072, "output": 8192 }
},
"glm-5": {
"id": "glm-5",
"name": "GLM-5",
"family": "glm",
"attachment": true,
"reasoning": true,
"tool_call": true,
"temperature": true,
"knowledge": "2025-01",
"release_date": "2025-01-01",
"last_updated": "2025-01-01",
"modalities": { "input": ["text", "image"], "output": ["text"] },
"open_weights": false,
"cost": { "input": 0, "output": 0 },
"limit": { "context": 131072, "output": 8192 }
},
"glm-4.7": {
"id": "glm-4.7",
"name": "GLM-4.7",
"family": "glm",
"attachment": true,
"reasoning": true,
"tool_call": true,
"temperature": true,
"knowledge": "2025-01",
"release_date": "2025-01-01",
"last_updated": "2025-01-01",
"modalities": { "input": ["text", "image"], "output": ["text"] },
"open_weights": false,
"cost": { "input": 0, "output": 0 },
"limit": { "context": 131072, "output": 8192 }
},
"kimi-k2.5": {
"id": "kimi-k2.5",
"name": "Kimi K2.5",
"family": "kimi",
"attachment": true,
"reasoning": true,
"tool_call": true,
"temperature": true,
"knowledge": "2025-01",
"release_date": "2025-01-01",
"last_updated": "2025-01-01",
"modalities": { "input": ["text", "image"], "output": ["text"] },
"open_weights": false,
"cost": { "input": 0, "output": 0 },
"limit": { "context": 131072, "output": 8192 }
}
}
},
"privatemode-ai": {
"id": "privatemode-ai",
"env": ["PRIVATEMODE_API_KEY", "PRIVATEMODE_ENDPOINT"],
Expand Down
Loading