Use the official OpenAI Python and Node SDKs with OpenDunes by pointing them at the OpenDunes base URL.
The OpenAI SDK is the canonical way to call OpenDunes from code. Because OpenDunes is OpenAI-compatible, you only need to change two things: the base URL and the API key. No other SDK configuration is needed.
pip install openaiPass base_url (Python) or baseURL (Node/TypeScript) when constructing the client. Use your OPENDUNES_API_KEY environment variable — never a hardcoded key.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://opendunes.com/v1",
api_key=os.environ["OPENDUNES_API_KEY"],
)import os
from openai import OpenAI
client = OpenAI(
base_url="https://opendunes.com/v1",
api_key=os.environ["OPENDUNES_API_KEY"],
)
resp = client.chat.completions.create(
model="anthropic/claude-sonnet-5",
messages=[{"role": "user", "content": "Marhba! Say hello in one line."}],
)
print(resp.choices[0].message.content)Set stream=True (Python) or stream: true (Node) to receive incremental delta chunks via server-sent events.
stream = client.chat.completions.create(
model="google/gemini-2.5-pro",
messages=[{"role": "user", "content": "Write a short poem about the Sahara."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)OpenDunes uses provider/model slugs — not the model IDs you pass to OpenAI. Browse the full catalog at /models or via the API at GET /api/models. Example slugs:
anthropic/claude-opus-4.8anthropic/claude-sonnet-5openai/gpt-5.4google/gemini-2.5-prometa-llama/llama-4-maverickThe SDK's request surface is honored today: model, messages, stream, max_tokens, max_completion_tokens, temperature (0–2), top_p (0–1), tools, tool_choice, parallel_tool_calls, response_format, stop, seed, frequency_penalty, presence_penalty, logprobs, top_logprobs, logit_bias, and more. OpenDunes extensions (models fallbacks, provider routing, the reasoning object) pass through extra_body. Check the API reference for the full list.
Create and manage keys from your dashboard. Keys look like sk- followed by a hex string and are shown once at creation. Store them as environment variables — never commit them to source control.