OpenRouter
官网,国内可以直接使用,不需要魔法, 在左边的 Prompt pricing 选择最低的 free,然后右边的列表就显示了带有 free 的免费模型,在个人中心创建一个 api-key(或者使用已经存在的 api-key),在使用 api-key 的时候指定使用的模型,听说每天限制 1000token,充值后有增加
from openai import OpenAI
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key="<OPENROUTER_API_KEY>",
)
completion = client.chat.completions.create(
extra_headers={"HTTP-Referer": "<YOUR_SITE_URL>", # Optional. Site URL for rankings on openrouter.ai.
"X-Title": "<YOUR_SITE_NAME>", # Optional. Site title for rankings on openrouter.ai.
},
extra_body={},
model="google/gemini-2.0-flash-exp:free", # 指定模型
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this and image?"
},
{
"type": "image_url",
"image_url": {"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"}
}
]
}
]
)
print(completion.choices[0].message.content)
魔搭社区
地址 ,国内阿里的平台,免费的模型每天可以调用 2000token,必须绑定阿里云账户, 教程

claude-code-router 使用
# C:\Users\admin\.claude-code-router\config.json { "APIKEY": "","LOG": true,"API_TIMEOUT_MS": 600000,"NON_INTERACTIVE_MODE": false,"Providers": [ { "name": "modelscope", "api_base_url": "https://api-inference.modelscope.cn/v1/chat/completions", "api_key": "xx--xxxxxxxxxx",// 个人中心的访问令牌 "models": ["MiniMax/MiniMax-M2","Qwen/Qwen3-Coder-480B-A35B-Instruct", "Qwen/Qwen3-235B-A22B-Thinking-2507"],// 选择的模型 "transformer": { "use": [ [ "maxtoken", {"max_tokens": 2000} ], "enhancetool" ], "Qwen/Qwen3-235B-A22B-Thinking-2507": {"use": ["reasoning"] } } }, ], "Router": { "default": "modelscope,MiniMax/MiniMax-M2",// 选择模型 "think": "modelscope,MiniMax/MiniMax-M2",// 选择模型 } }
智谱开放平台
地址,模型 API 调用不限制,但是模型数量有限

正文完
发表至: AI
2025-11-09