Switch an existing OpenAI integration to OpenDunes by changing two lines.
If your app already calls the OpenAI API, switching to OpenDunes is two changes: the base URL and the key. Every request shape, SDK method, and streaming behavior stays identical.
Wherever you construct your OpenAI client, update baseURL and apiKey:
# Before
from openai import OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
# After
from openai import OpenAI
client = OpenAI(
base_url="https://opendunes.com/v1",
api_key=os.environ["OPENDUNES_API_KEY"],
)That's it. All your existing chat.completions.create(...) calls work without further modification.
OpenDunes uses provider/model slugs instead of bare model names. Swap them out:
| Your current value | OpenDunes equivalent |
|---|---|
gpt-5.4 (or similar) | openai/gpt-5.4 |
claude-opus-4.8 | anthropic/claude-opus-4.8 |
gemini-2.5-pro | google/gemini-2.5-pro |
llama-4-70b | meta-llama/llama-4-maverick |
Browse the full catalog at /models — every listing shows the exact slug to use.
Add the new key and (optionally) keep the old one during a parallel-run period:
# .env (or your CI/CD secrets)
OPENDUNES_API_KEY=sk-0a1b2c3d4e5f...
# OPENAI_API_KEY=sk-... ← keep until traffic is fully migratedGet your OpenDunes key from Dashboard → Keys. If you haven't created a custom key yet, the default key is ready to use immediately after signup.
Everything in chat/completions that you use today transfers over directly:
messages array with system, user, assistant rolesstream: true with the same SSE delta formatmax_tokens, temperature, top_pOpenDunes bills in Algerian Dinars (DA). Before your first request, deposit DA with a CIB or Edahabia card from Dashboard → Billing. Pricing is shown per million tokens in DA on the models page.
The response header X-Balance-Available tells you your remaining balance after every call, so you can build low-balance warnings without polling.
Almost everything transfers. Tool/function calling, JSON mode, structured outputs (response_format), and embeddings (/v1/embeddings) are all supported today. The Responses API is carried too: /v1/responses takes the same body, and its errors come back in the Responses shape — see Responses.
Validation is forgiving: unknown fields in the request body are simply ignored, and an invalid field value returns a 422 validation error naming the field to fix.
Everything else — chat completions, streaming, vision inputs, multi-turn history — works today. There is no cap on the number of requests; a key's limit is a spending cap in DA.
A quick sanity check after you've updated the client:
curl https://opendunes.com/v1/chat/completions \
-H "Authorization: Bearer $OPENDUNES_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-5",
"messages": [{ "role": "user", "content": "Reply with OK." }]
}'A 200 with a valid choice means the migration is complete.