tian-minghui / openai-style-api

支持将openai、claude、azure openai, gemini,kimi, 智谱AI,通义千问,讯飞星火API等模型服务方的调用转为openai方式调用。屏蔽不同大模型API的差异,统一用openai api标准格式使用大模型(Shield the differences between different large model APIs and use large models in a unified openai API standard format)
MIT License
328 stars 55 forks source link

期望添加或检查 OpenRouter 支持 #28

Open YigesMx opened 3 months ago

YigesMx commented 3 months ago

当前类 OpenAI 类型的 API 比如 KIMI 是能正常使用的,根据 OpenRouter 的文档,理论上也可以使用 OpenAI 的接口,文档给出了使用 openai 包的示例。

根据示例也能正常使用:

openrouter_client = OpenAI(
    api_key='xxx',
    base_url = 'https://openrouter.ai/api/v1'
)

chat_completion = openrouter_client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test",
        }
    ],
    model="meta-llama/llama-3-8b-instruct:free",
)

print(chat_completion.choices[0].message.content)

但是以下配置,OpenRouter 会返回 404 页面:

[
    {
        "token": "xxx",
        "type": "openai",
        "config": {
            "api_base": "https://openrouter.ai/api/v1",
            "api_key": "xxx",
            "model": "meta-llama/llama-3-8b-instruct:free"
        }
    }
]

请问这是配置的问题,还是 API 规范的问题,希望添加或检查 OpenRouter 的支持,谢谢!

tian-minghui commented 3 months ago

日志应该 能看到调用openrouter的url,看是是否符合预期