Skip to content

feat: Add support for the OpenRouter. #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 27, 2025

Conversation

L-excellence
Copy link
Contributor

关联 issue 链接:#12

变更说明:

  1. 安装 AI SDK 接入 OpenRouter 的模块
pnpm install @openrouter/ai-sdk-provider -w
  1. 在 AI 工作流程中接入 OpenRouter 供应商模型逻辑
...
+ import { createOpenRouter } from "@openrouter/ai-sdk-provider"

export const getAIClient = (provider: AIProvider, model: string) => {
  const modelConfig = findModelConfig(provider, model)

  switch (provider) {
    ...
+   case "openrouter":
+     return createOpenRouter({
+       baseURL: modelConfig.baseURL,
+       apiKey: modelConfig.apiKey,
+     }).chat(modelConfig.model)
    default:
      throw new Error(`Unsupported AI provider: ${provider}`)
  }
}
  1. 在 data/config.template.json 模型配置文件中加入 OpenRouter 常用模型
{
    "providers": [
        ... 
+       {
+         "provider": "openrouter",
+         "models": [
+           {
+             "model": "anthropic/claude-3.7-sonnet",
+             "title": "Claude 3.7 Sonnet",
+             "baseURL": "https://openrouter.ai/api/v1",
+             "features": ["vision"],
+             "apiKey": "sk-****"
+           },
+           ...
+         ]
+       }
    ]
}

@IamLiuLv IamLiuLv merged commit 5542d36 into IamLiuLv:main Jul 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants