今日已更新 166 条资讯 | 累计 20138 条内容
关于我们

Access 40+ AI Providers with One API Key: Building with the Onlist SDK

alan 2026年06月20日 20:15 2 次阅读 来源:Dev.to

If you've worked with multiple AI APIs, you know the pain: different auth flows, different SDKs, different billing dashboards, different rate limits. You end up with a providers/ folder full of wrapper code just to normalize the responses. Onlist solves this by putting 40+ AI providers behind a single OpenAI-compatible endpoint. One API key, one billing account, same chat.completions.create() call you already know. We just shipped official SDKs for Python and JavaScript/TypeScript, so I wanted to walk through what they look like in practice. The 30-Second Setup Python: pip install onlist from onlist import Onlist client = Onlist () # reads ONLIST_API_KEY from env response = client . chat . completions . create ( model = " openai/chatgpt-5.5 " , messages = [{ " role " : " user " , " content " : " Hello! " }], ) print ( response . choices [ 0 ]. message . content ) TypeScript: npm install @onlist/sdk import { Onlist } from " @onlist/sdk " ; const client = new Onlist (); const response = await client . chat . completions . create ({ model : " openai/chatgpt-5.5 " , messages : [{ role : " user " , content : " Hello! " }], }); console . log ( response . choices [ 0 ]. message . content ); That's it. No base URL to configure, no special headers to set. If you've used the openai package before, you already know how to use this. Why Not Just Use the OpenAI SDK Directly? You absolutely can. Onlist is fully OpenAI-compatible, so this works fine: from openai import OpenAI client = OpenAI ( base_url = " https://onlist.io/v1 " , api_key = " your-key " , ) The SDK adds three things on top of that: Default configuration. No base_url to remember. The ONLIST_API_KEY env var just works. Marketplace API. A .marketplace namespace for browsing models and providers programmatically. Proper User-Agent. Helps us debug issues when you reach out for support. If you're already using OpenAI or OpenRouter, switching takes one line: - from openai import OpenAI + from onlist import Onlist - clien

本文内容来源于互联网,版权归原作者所有
查看原文