技巧精选

OpenRouter 如何自动选择最合适的 AI 模型后端

So you want to use OpenRouter?

精选理由

想用 OpenRouter 自动找最便宜的 AI 模型?得注意不同后端可能让模型表现不一样,比如视觉能力或推理方式,用 provider.only 选项能控制路由。

OpenRouter 通过单一 API 端点自动路由请求到不同提供商,但不同提供商的软件和设置不同,可能导致模型行为不一致。例如,某些提供商的视觉模型缺乏视觉能力,推理处理方式也可能不同。你可以通过 provider.only 选项控制路由,/endpoints 方法可返回特定模型 ID 的可用提供商列表。

原文 · Simon Willison’s Weblog

So you want to use OpenRouter?

So you want to use OpenRouter? One of OpenRouter's selling points is that it "handles fallbacks automatically and picks the most cost-effective option for each request", so you can call a single API endpoint for a model and get routed to the best available backend provider. Mohamed Moustafa points out a whole set of ways that this can cause you problems. Different providers run different serving software with different optimizations and settings, which means that the same OpenRouter endpoint can serve model requests that behave in different ways. Some providers even lack vision capability for vision models, and the way the reasoning effort option is processed can differ as well. Thankfully you can control which provider is routed to using the provider.only option . The /endpoints method returns the list of available providers for a specific model ID. Via Hacker News Tags: ai , generative-ai , llms , openrouter