Tooling that makes working with the OpenDunes API faster and easier to debug.
These tools and techniques reduce friction during development — from typed completions in your editor to request-level tracing in the dashboard.
The openai SDK ships full TypeScript types. Even if you write Python or Go, your IDE autocompletes request parameters, response fields, and error shapes — catching mistakes before they hit the wire.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://opendunes.com/v1",
apiKey: process.env.OPENDUNES_API_KEY!,
});
// `resp` is fully typed — no casting needed
const resp = await client.chat.completions.create({
model: "anthropic/claude-opus-4.8",
messages: [{ role: "user", content: "Hello" }],
});
const text: string = resp.choices[0].message.content ?? "";X-Request-Id#Every response from the OpenDunes API includes an X-Request-Id header containing a UUID v7 trace identifier. Log it with every request so you can look up the exact call in your dashboard if something goes wrong.
import os
from openai import OpenAI
import httpx
# Intercept the raw HTTP response to extract headers
class TracingTransport(httpx.HTTPTransport):
def handle_request(self, request):
response = super().handle_request(request)
request_id = response.headers.get("X-Request-Id", "")
print(f"[trace] X-Request-Id: {request_id}")
return response
http_client = httpx.Client(transport=TracingTransport())
client = OpenAI(
base_url="https://opendunes.com/v1",
api_key=os.environ["OPENDUNES_API_KEY"],
http_client=http_client,
)Note. When contacting support about a failed request, always include the
X-Request-Id. It's the fastest way to locate the call server-side.
Your dashboard gives you a live view of:
Use the trace ID from X-Request-Id to jump directly to a specific request in the log.
Keep secrets out of source code. The one variable you always need:
export OPENDUNES_API_KEY=sk-0a1b2c3d4e5f...For local development, a .env file works well — just make sure it's in .gitignore.
# .env
OPENDUNES_API_KEY=sk-0a1b2c3d4e5f...
OPENDUNES_BASE_URL=http://localhost:8000/v1One header lets you monitor spend inline without extra API calls:
| Header | Value |
|---|---|
X-Balance-Available | Remaining balance in micro-DA, after this request's charge. Not on a streamed answer |
There is no cap on the number of requests, so there is no request counter to watch. A 429 is the provider's and carries Retry-After; see Limits.
Point at http://localhost:8000/v1 when running the stack locally. Everything — auth, billing, models — behaves identically to production.
import os
base_url = os.environ.get("OPENDUNES_BASE_URL", "https://opendunes.com/v1")
client = OpenAI(base_url=base_url, api_key=os.environ["OPENDUNES_API_KEY"])