opendunes
Get started
Copy page ▾

Move to OpenDunes

Move an app already running on the OpenAI or Anthropic library: three values change, the code stays.

Paste this into your agent

Move this project's OpenAI or Anthropic client to OpenDunes. Change three values and nothing else. Base URL: https://opendunes.com/v1 for the OpenAI library, https://opendunes.com for the Anthropic library. Key: read it from the environment variable OPENDUNES_API_KEY; never write it in a file. Model IDs: lab/model, for example anthropic/claude-sonnet-4.5. Docs: https://opendunes.com/docs/llms.txt

  1. Get a key and a balance.
  2. Change the base URL and the key.
  3. Change the model ID.
  4. Send one request to check.
  5. Read what the answer adds.

1. Get a key and a balance

You needWhere
an API keyAPI keyThe key you create and send with every request that calls a model.More on API keys →API Keys, in the app: see API keys
a balanceBalanceWhat you can spend, in DA.More on Balance and charges → above zeroCredit, in the app: depositDepositMoney entering your balance, by CIB or Edahabia card.More on Balance and charges → by Edahabia or CIB
the key in your environmentexport OPENDUNES_API_KEY="…"

No foreign card: the balance is in DADAThe Algerian dinar, the one currency the docs show.More on Balance and charges →, and every request is charged to it.

2. Change the base URL and the key

LibraryBase URLKey
OpenAI libraryhttps://opendunes.com/v1OPENDUNES_API_KEY
Anthropic libraryhttps://opendunes.comOPENDUNES_API_KEY

Where your code builds the client, change two arguments.

TabOpenAI libraryAnthropic library
PythonOpenAI(base_url=…, api_key=…)Anthropic(base_url=…, api_key=…)
JavaScriptnew OpenAI({ baseURL, apiKey })new Anthropic({ baseURL, apiKey })
Gooption.WithBaseURL(…), option.WithAPIKey(…)the same two options
cURLthe address, and Authorization: Bearerthe address, and x-api-key
Watch out

The Anthropic library adds /v1 itself. Give it https://opendunes.com, without /v1.

If your code builds the client with no arguments, the library reads both values from the environment. Set them there and change no line of code.

Shell
# OpenAI library
export OPENAI_BASE_URL="https://opendunes.com/v1"
export OPENAI_API_KEY="$OPENDUNES_API_KEY"

# Anthropic library
export ANTHROPIC_BASE_URL="https://opendunes.com"
export ANTHROPIC_API_KEY="$OPENDUNES_API_KEY"

3. Change the model ID

Every model is named lab/model. Put the lab in front of the name you use today; a Claude model also takes a dot in its version, and no date.

LibraryModel IDModel IDThe name a request calls a model by, lab/model, copied from Models.More on Models → todayModel ID on OpenDunes
OpenAI librarygpt-6-solopenai/gpt-6-sol
Anthropic libraryclaude-opus-5-5anthropic/claude-opus-5.5
Anthropic libraryclaude-haiku-4-5-20251001anthropic/claude-haiku-4.5

The rest of the request stays as it is: the same body, with the new ID in model.

JSON
{
  "model": "anthropic/claude-opus-5.5",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Two lines to welcome a shop in Oran."
    }
  ]
}
Good to know

Copy an ID from its page in Models rather than typing it: see Models. One key reaches every lab.

4. Send one request to check

Send one short request on the library your app uses. A printed answer and a charge mean the move worked.

With the OpenAI library

import os
from openai import OpenAI

API_KEY = os.environ["OPENDUNES_API_KEY"]
BASE_URL = "https://opendunes.com/v1"
MODEL = "anthropic/claude-sonnet-4.5"

client = OpenAI(base_url=BASE_URL, api_key=API_KEY)

reply = client.chat.completions.create(
    model=MODEL,
    messages=[{"role": "user", "content": "Reply with OK."}],
)

print(reply.choices[0].message.content)
print(reply.usage.cost)

With the Anthropic library

import os
from anthropic import Anthropic

API_KEY = os.environ["OPENDUNES_API_KEY"]
BASE_URL = "https://opendunes.com"
MODEL = "anthropic/claude-sonnet-4.5"

client = Anthropic(base_url=BASE_URL, api_key=API_KEY)

message = client.messages.create(
    model=MODEL,
    max_tokens=1024,
    messages=[{"role": "user", "content": "Reply with OK."}],
)

print(message.content[0].text)
print(message.usage.cost)

A 401 means the key did not reach the request: check OPENDUNES_API_KEY is set in this terminal. Every other status: Errors and retries.

5. Read what the answer adds

The answer keeps the shape your code already reads. Two things are new, and one status.

WhereWhat it isIllustrative
usage.cost, in the answerthe charge, in DA0.020166 DA
X-Balance-Available, the headeryour balance after it, in µDAµDAA millionth of a DA: 1 DA = 1 000 000 µDA.More on Balance and charges →499979834 µDA
a 402the balance is at zero or below, or cannot pay the request's holdnew requests refused until a deposit

A streamed answer carries no X-Balance-Available: its charge is usage.cost, in the closing event. Streaming shows it, and Balance and charges says how each request is charged.

Watch out

No library retries a 402: the same request gets the same answer until a deposit covers what the balance owes. If your app retries on every error, let it stop on a 402.

Next: Quickstart chat app · OpenAI and Anthropic libraries · Frameworks

Last modified on