文章目录
在 VSCcode Cline 中调用 Smithery 中的海量server 可参考文章:
MCP 极简入门 - 三分钟 Cline + Smithery 运行 time 服务
https://blog.csdn.net/lovechris00/article/details/147017408
OpenRouter
申请/管理 API Keys
https://openrouter.ai/settings/keys
Credit limit (optional) 可以先不写
查找模型
你可以在首页点击 模型,也可以直接访问
https://openrouter.ai/models
OpenRouter 提供了很多免费模型,输入 free 即可搜索查看:
你也可以在左侧根据需要,来过滤
Python - OpenAI 接口调用测试
from openai import OpenAI
API_KEY = 'sk-or-v1-606bbec...da48a536'
client = OpenAI(api_key= API_KEY ,base_url= "https://openrouter.ai/api/v1" )
model_name = 'meta-llama/llama-3.3-70b-instruct:free'
# model_name = 'deepseek/deepseek-chat-v3-0324:free'
response = client.chat.completions.create(
model= model_name ,
messages=[
{ "role" : "system" , "content" : "You are a helpful assistant." },
{ "role" : "user" , "content" : " Who are you?" },
],
stream= False
)
ret = response.choices[0].message.content
print(ret)
Cline 配置使用
在 VS Code 插件市场搜索 Cline
安装后,先登录 Cline,点击下方的 Get Started for Free
设置 API Provider
然后点击设置按钮,API Provider 选择OpenRouter
设置
输入Key后,选择模型
输入 free 可以看到很多免费模型
最后点击 Done
按钮完成配置
调用
在 Cline 下方输入框,输入你的对话内容。
下方会显示 当前选择的模型等信息。
报错 - API Request Failed
404 No endpoints found matching your data policy. Enable prompt training here: https://openrouter.ai/settings/privacy
出现这个问题是因为,一些free模型会将用户输入用于魔性训练,如果不同意就无法调用。
如果不是敏感数据,可以同意。
解决方法:前往 Privacy 勾选允许 Model Training
https://openrouter.ai/settings/privacy
2025-04-05(六)