opendunes
Get started · 2 min
Copy page ▾

Client SDKs

The OpenAI library and the Anthropic library work against OpenDunes with two fields swapped: the address and the key.

  1. Install a library.
  2. Swap the address and the key.
  3. Send with the OpenAI library.
  4. Send with the Anthropic library.
  5. Read the charge and the balance.

1. Install a library

TabOpenAI libraryAnthropic library
Pythonpip install openaipip install anthropic
JavaScriptnpm install openainpm install @anthropic-ai/sdk
Gogo get github.com/openai/openai-go/v3go get github.com/anthropics/anthropic-sdk-go
cURLnonenone

2. Swap the address and the key

LibraryAddressKey
OpenAI libraryhttps://opendunes.com/v1OPENDUNES_API_KEY
Anthropic libraryhttps://opendunes.comOPENDUNES_API_KEY

Everything else in your code stays as it is. The OpenAI library sends a conversation to POST /v1/chat/completions, the Anthropic library to POST /v1/messages. Create a key first if you have none.

Watch out

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

3. Send 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)

raw = client.chat.completions.with_raw_response.create(
    model=MODEL,
    messages=[
        {"role": "user", "content": "Two lines to welcome a shop in Oran."},
    ],
)
reply = raw.parse()

print(reply.choices[0].message.content)
print(reply.usage.cost)
print(raw.headers["X-Balance-Available"])

With -i, X-Balance-Available is among the headers, and usage.cost is in the body.

4. Send 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)

raw = client.messages.with_raw_response.create(
    model=MODEL,
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Two lines to welcome a shop in Oran."},
    ],
)
message = raw.parse()

print(message.content[0].text)
print(message.usage.cost)
print(raw.headers["X-Balance-Available"])

With -i, X-Balance-Available is among the headers, and usage.cost is in the body.

5. Read the charge and the balance

These are the two fields only OpenDunes returns; the libraries pass them through, and the samples above read them.

FieldWhereHolds
usage.costthe answerthe charge, in DADAThe Algerian dinar, the one currency the docs show.More on Balance and charges →
X-Balance-Availablethe headeryour balanceBalanceWhat you can spend, in DA.More on Balance and charges → after it, in µDAµDAA millionth of a DA: 1 DA = 1 000 000 µDA.More on Balance and charges →
Good to know

A streamed answer carries no X-Balance-Available. Its charge is usage.cost, in the closing event: see Streaming.

Working in a framework? Frameworks gives the two fields each needs.