If your app already talks to OpenAI's API, switching to Brievio takes about ten minutes — most of which is signing up. You keep your SDK and your codebase; you get the genuine models on reliable infrastructure with honest token billing. This guide walks through the four flavors of integration most teams have and the one-line change each needs.
Step 0 — Get a key (2 minutes)
- Sign up at brievio.com/app/signup. You get $2 of credit on sign-up; no card required.
- Visit /app/keys and create a key. It starts with
sk-brievio-. - Set the env var:
export BRIEVIO_API_KEY=sk-brievio-....
Step 1 — Switch your SDK (1 minute)
Python (openai package)
# Before — pointing at OpenAI directly
from openai import OpenAI
client = OpenAI(
api_key=os.environ["OPENAI_API_KEY"],
)
# After — pointing at Brievio. Everything else stays the same.
from openai import OpenAI
client = OpenAI(
api_key=os.environ["BRIEVIO_API_KEY"],
base_url="https://api.brievio.com/v1",
)Node / TypeScript
// Before
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
// After
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.BRIEVIO_API_KEY,
baseURL: "https://api.brievio.com/v1",
});LangChain
LangChain uses the same OpenAI client internally, so the change is identical. The model id is now a Brievio slug — see /models for the live list (try claude-sonnet-4-6, gemini-2.5-flash, claude-opus-4-7).
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="claude-sonnet-4-6", # switched the model
api_key=os.environ["BRIEVIO_API_KEY"],
base_url="https://api.brievio.com/v1",
)Vercel AI SDK
@ai-sdk/openai reads its base URL and API key from env vars by default. Set those and you're done — every framework helper (streamText, generateObject, retries, tool routing) works unchanged.
import { openai } from "@ai-sdk/openai";
// @ai-sdk/openai reads OPENAI_BASE_URL automatically
process.env.OPENAI_BASE_URL = "https://api.brievio.com/v1";
process.env.OPENAI_API_KEY = process.env.BRIEVIO_API_KEY;
const model = openai("claude-sonnet-4-6");
// then use streamText / generateText / streamObject as beforeAnthropic SDK (if you're on Claude already)
Brievio exposes Anthropic's native Messages API at /v1/messages as well as the OpenAI shape — so you don't have to switch SDKs.
from anthropic import Anthropic
# Before — Anthropic SDK against api.anthropic.com
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
# After — same SDK, against Brievio. Caching, thinking, tools all pass through.
client = Anthropic(
api_key=os.environ["BRIEVIO_API_KEY"],
base_url="https://api.brievio.com", # SDK appends /v1/messages
)Step 2 — Smoke-test the wallet (1 minute)
Before touching production code, run a cheap test against claude-haiku-4-5. If this returns successfully, your key works, billing works, the routing layer is healthy.
# Cheap, deterministic-ish smoke test for migration validation.
resp = client.chat.completions.create(
model="claude-haiku-4-5", # the cheapest Claude
messages=[{"role": "user", "content": "ping"}],
max_tokens=8,
temperature=0,
)
assert resp.choices[0].message.content, "empty response"
print("ok — Brievio wallet works, total cost ~$0.0001")Step 3 — Move traffic (5 minutes)
The safe pattern: two environment variables in your app — AI_BASE_URL and AI_API_KEY — selected per-environment. Production stays on OpenAI; staging swaps to Brievio. After 24 hours, flip prod over.
If you're curious about cost impact before you cut over, Brievio's dashboard shows per-call cost vs the upstream official rate — easy to compute the projected monthly delta on your real prompts.
What stays the same
- Your SDK and codebase.
- Streaming, function calling, tool use, vision, structured outputs.
- OpenAI's exact request and response schemas.
- Error shape (
error.message/error.type/error.code).
What changes for the better
- Authenticity. The genuine first-party model on every call — full context, native tools and caching, no silent downgrades or re-wrapped proxies.
- Pricing. Every model is priced roughly 5% under the provider's official list, billed on true token counts — see /pricing.
- Modality. The same SDK reaches Claude (
claude-opus-4-7), Gemini (gemini-2.5-pro), GPT-Image-2, Veo 3, Nano Banana — see /models. - Billing. Stripe-native wallet — cards, Apple Pay, Google Pay, ACH, SEPA, Alipay, WeChat Pay. One auditable bill.
- Reliability. Monitored, automatic failover — we re-route the moment an upstream degrades, typically before your retry loop fires.
The unhappy-path notes
- OpenAI-specific endpoints we don't cover today:
/v1/responses(use/v1/chat/completions),/v1/assistants(state on your side; we're a stateless gateway),/v1/realtime(planned). - Some Claude-specific features —
cache_control, extendedthinking— work best via the native /v1/messages endpoint, not the OpenAI shape.
Stuck? contact@brievio.com — a human replies within a working day. If you're running a serious migration we'll get on a call.