Blog · 2026-07-19

Free OpenAI-Compatible API: Just Switch Your base_url

DreamPrompting is a free OpenAI-compatible API that forwards your requests to the free tiers of many providers (Groq, NVIDIA, OpenRouter, Cohere, Google Gemini, and more) with automatic failover. Because it speaks the exact same protocol as OpenAI, you do not rewrite anything. You change the base_url, drop in a free API key from your account page, keep the rest of your code, and start sending requests. This post explains what "OpenAI-compatible" really means and shows the same call working through the OpenAI SDK (Python and JavaScript), LangChain, and plain curl.

What "OpenAI-compatible" means

When people say a service is OpenAI-compatible, they mean it implements the same HTTP contract that OpenAI publishes: a POST /chat/completions endpoint that accepts a JSON body with model and messages, and returns the same response shape (a choices array with a message). Streaming uses the same Server-Sent Events chunks. Because the contract is identical, any client library built for OpenAI works without modification. That is the whole trick behind a free OpenAI-compatible API: your existing tooling already knows how to talk to it.

This matters because the OpenAI request format has become a de facto standard. Groq, NVIDIA, OpenRouter, Cohere, Google Gemini, and dozens of other services expose the same shape, and so do frameworks like LangChain, LlamaIndex, and editor plugins such as Continue. DreamPrompting sits in front of the free tiers of those providers as a single gateway. When one provider is rate limited or slow, it fails over to another automatically, so you get one stable endpoint instead of juggling many keys, base URLs, and quota rules. You write against the OpenAI protocol once, and the gateway handles the routing behind the scenes.

For model you can send "auto" and let the gateway pick a healthy provider, or name one directly like "groq/openai/gpt-oss-120b" or "google/gemini-3.1-flash-lite". Browse the full list on the models page.

Python: the OpenAI SDK, one line changed

This is the entire migration. Set base_url and your free api_key, then use the client exactly as you always have.

from openai import OpenAI

client = OpenAI(
    base_url="https://dreamprompting.com/api/v1",
    api_key="YOUR_API_KEY",
)

resp = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Explain OpenAI compatibility in one line."}],
)
print(resp.choices[0].message.content)

JavaScript: same idea in Node

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://dreamprompting.com/api/v1",
  apiKey: process.env.DREAM_API_KEY,
});

const resp = await client.chat.completions.create({
  model: "groq/openai/gpt-oss-120b",
  messages: [{ role: "user", content: "Hello from a free OpenAI-compatible API" }],
});
console.log(resp.choices[0].message.content);

curl: no SDK at all

If you can send an HTTP request, you can use this free OpenAI-compatible API. Nothing here is DreamPrompting-specific except the host.

curl https://dreamprompting.com/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [{"role": "user", "content": "Say hi"}]
  }'

LangChain: point ChatOpenAI at the gateway

LangChain's ChatOpenAI accepts a custom base URL, so the same swap works for chains, agents, and RAG pipelines. If you are wiring up tools or an agent runtime, see the notes on using DreamPrompting for agents.

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://dreamprompting.com/api/v1",
    api_key="YOUR_API_KEY",
    model="auto",
)

print(llm.invoke("Summarize what a free OpenAI-compatible API does.").content)

Streaming works the same way

Set "stream": true and you receive OpenAI-compatible SSE chunks, delivered as they are generated. Your existing streaming loop does not change.

stream = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Count to five."}],
    stream=True,
)
for chunk in stream:
    delta = chunk.choices[0].delta.content or ""
    print(delta, end="", flush=True)

Discovering models and quota

Two helper endpoints round out the free OpenAI-compatible API. GET /api/v1/models returns the models you can request, in the same shape OpenAI uses for its list endpoint, so SDK model pickers populate automatically. GET /api/v1/quota reports how much of your per-minute burst and your account's rolling 24 hour account quota remains, which is handy before a batch of requests. Both are plain GET calls that take the same Bearer token, so you can hit them from a script or the same SDK you already use. There are currently 24 providers configured, including the keyless ch.at, and because the gateway routes with automatic failover, a busy or degraded provider does not stop your request from completing.

curl https://dreamprompting.com/api/v1/models -H "Authorization: Bearer YOUR_API_KEY"
curl https://dreamprompting.com/api/v1/quota  -H "Authorization: Bearer YOUR_API_KEY"

Want to try prompts before writing any code? Open the web chat, or read the full reference on the API docs page.

FAQ

Do I need to change my code? Barely. Change base_url and the key, and your OpenAI SDK, LangChain, or curl calls keep working unchanged.

Does streaming work? Yes. Pass "stream": true and you get standard OpenAI-compatible SSE chunks, so your existing streaming code is fine.

Is there an API key? Yes, and it is free. Sign in with Google, copy your key, and send it as Authorization: Bearer YOUR_API_KEY. No credit card. The service is limited to 100 requests per minute per IP plus a rolling 24 hour account quota.

Start now

Copy one of the snippets above, point base_url at https://dreamprompting.com/api/v1, paste in your free key from the account page, and send a request. Read the full API docs and browse the available models to pick the right one for your workload.