惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
B
Blog
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Jina AI
Jina AI
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
L
LangChain Blog
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
F
Fortinet All Blogs
H
Help Net Security
B
Blog RSS Feed
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Access 40+ AI Providers with One API Key: Building with t...
alan · 2026-06-20 · via DEV Community
Cover image for Access 40+ AI Providers with One API Key: Building with the Onlist SDK

alan

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:

  1. Default configuration. No base_url to remember. The ONLIST_API_KEY env var just works.
  2. Marketplace API. A .marketplace namespace for browsing models and providers programmatically.
  3. 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

- client = OpenAI(api_key="sk-...")
+ client = Onlist(api_key="sk-...")

Every method call stays exactly the same.

Provider Routing

This is where things get interesting. When you call openai/chatgpt-5.5 on Onlist, there might be multiple upstream providers serving that model at different prices. You can control which one handles your request:

response = client.chat.completions.create(
    model="openai/gpt-4o",
    messages=[{"role": "user", "content": "Summarize this document"}],
    extra_body={
        "provider": {
            "sort": "price",          # cheapest provider first
            "allow_fallbacks": True,  # try another if the first fails
        }
    },
)

You can also pin to a specific provider if you've found one you trust:

extra_body={"provider": {"only": ["alice-ai"]}}

This is passed through the standard OpenAI extra_body parameter, so no special SDK features needed.

Browsing the Marketplace

The .marketplace namespace lets you explore what's available:

# What models are out there?
models = client.marketplace.models.list(limit=5)
for m in models.data:
    print(m.id)

# Who's selling ChatGPT 5.5?
detail = client.marketplace.models.get("openai/chatgpt-5.5")
for offer in detail.providers:
    print(f"  {offer.name}")

The same API is available in the TypeScript SDK with identical method names.

Streaming

Works exactly like the OpenAI SDK:

stream = client.chat.completions.create(
    model="openai/chatgpt-5.5",
    messages=[{"role": "user", "content": "Write a haiku about code"}],
    stream=True,
)

for chunk in stream:
    content = chunk.choices[0].delta.content
    if content:
        print(content, end="", flush=True)

Vercel AI SDK

If you're using the Vercel AI SDK, we also have a provider package:

npm install @onlist/ai-sdk-provider ai

import { createOnlist } from "@onlist/ai-sdk-provider";
import { generateText } from "ai";

const onlist = createOnlist();

const { text } = await generateText({
  model: onlist("openai/chatgpt-5.5"),
  prompt: "Explain quantum computing briefly.",
});

It's built on top of @ai-sdk/openai-compatible, so all the AI SDK features (streaming, tool calling, structured outputs) work out of the box.

What Onlist Actually Is

Onlist is an open marketplace where independent API providers list their services. Think of it like a comparison shopping site for AI APIs. Providers compete on price and reliability, buyers get transparent pricing and the ability to switch providers without changing code.

The SDKs are all MIT licensed and available on GitHub.

Links