Run agents built with the Anthropic Agent SDK on OpenDunes, billed in DA.
The Anthropic Agent SDK builds agents in Python or TypeScript. It runs on Claude Code, which speaks the Anthropic Messages API — carried by OpenDunes at /v1/messages. So the same environment variables as Claude Code connect it, and every call is billed to your wallet in DA.
Set these before running your agent:
export ANTHROPIC_BASE_URL="https://opendunes.com"
export ANTHROPIC_AUTH_TOKEN="$OPENDUNES_API_KEY"
export ANTHROPIC_API_KEY="" # must be empty
# Model names OpenDunes sells, for each class the SDK uses
export ANTHROPIC_DEFAULT_OPUS_MODEL="~anthropic/claude-opus-latest"
export ANTHROPIC_DEFAULT_SONNET_MODEL="~anthropic/claude-sonnet-latest"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="~anthropic/claude-haiku-latest"The model variables are needed: the SDK's built-in model names are not names OpenDunes sells, and answer 404.
npm install @anthropic-ai/claude-agent-sdkimport { query } from "@anthropic-ai/claude-agent-sdk";
async function main() {
for await (const message of query({
prompt: "Find and fix the bug in auth.py",
options: {
allowedTools: ["Read", "Edit", "Bash"],
},
})) {
if (message.type === "assistant") {
console.log(message.message.content);
}
}
}
main();pip install claude-agent-sdkimport asyncio
from claude_agent_sdk import query, ClaudeAgentOptions
async def main():
async for message in query(
prompt="Find and fix the bug in auth.py",
options=ClaudeAgentOptions(allowed_tools=["Read", "Edit", "Bash"]),
):
print(message)
asyncio.run(main())Without the Agent SDK, the plain anthropic client works the same way: give it OpenDunes as its base URL and your key, and name a model OpenDunes sells.
import os
from anthropic import Anthropic
client = Anthropic(base_url="https://opendunes.com", api_key=os.environ["OPENDUNES_API_KEY"])
message = client.messages.create(
model="anthropic/claude-sonnet-5",
max_tokens=512,
messages=[{"role": "user", "content": "Marhba! Say hello in one line."}],
)
print(message.content[0].text)