Not yet available. The Agent SDK is tracked to be built — today, use the Client SDKs against the live chat completions API. The example below illustrates the intended API.
This example shows an agent that answers weather questions by calling a live weather tool. It covers tool definition, a simple agent loop with a stop condition, streaming output, and cost logging.
import type { Tool } from "@opendunes/agent-sdk";
interface WeatherResult {
city: string;
tempC: number;
condition: string;
humidity: number;
}
async function fetchWeather(city: string): Promise<WeatherResult> {
const res = await fetch(
`https://api.example-weather.com/current?city=${encodeURIComponent(city)}&key=${process.env.WEATHER_API_KEY}`
);
if (!res.ok) throw new Error(`Weather API error: ${res.status}`);
return res.json();
}
export const weatherTool: Tool = {
name: "get_weather",
description:
"Get the current weather for a city. Returns temperature in Celsius, condition summary, and humidity percentage.",
parameters: {
type: "object",
properties: {
city: {
type: "string",
description: "City name. Examples: Algiers, Oran, Constantine, Tlemcen.",
},
},
required: ["city"],
},
execute: async ({ city }) => {
const data = await fetchWeather(String(city));
return `${data.city}: ${data.tempC}°C, ${data.condition}, ${data.humidity}% humidity.`;
},
};
import { OpenDunes } from "@opendunes/agent-sdk";
import { weatherTool } from "./tools/weather";
const client = new OpenDunes({
apiKey: process.env.OPENDUNES_API_KEY!,
});
async function askWeather(question: string) {
const result = await client.callModel({
model: "google/gemini-2.5-pro",
messages: [
{
role: "system",
content:
"You are a helpful weather assistant. Use the get_weather tool to answer questions about current conditions.",
},
{ role: "user", content: question },
],
tools: [weatherTool],
stopConditions: [
{ type: "no_tool_calls" },
{ type: "max_turns", maxTurns: 5 },
],
stream: true,
onToken: (delta) => process.stdout.write(delta),
});
console.log("\n");
const daCost = Number(result.usage.costMicroDA) / 1_000_000;
console.log(`Tool calls: ${result.items.filter((i) => i.type === "tool_call").length}`);
console.log(`Cost: ${daCost.toFixed(4)} DA`);
console.log(`Balance remaining: ${Number(result.balance) / 1_000_000} DA`);
}
askWeather("What's the weather like in Algiers and Oran right now?");
- The user asks about weather in two cities.
- The model issues two
get_weather tool calls (parallel, if the model supports it).
- The SDK executes both calls, appends the results.
- The model generates a natural-language response comparing the two cities.
- No more tool calls →
no_tool_calls stop condition fires → loop ends.
Algiers is currently warm at 32°C with clear skies and 45% humidity. Oran is slightly
cooler at 29°C with a light sea breeze and some coastal haze, humidity at 62%.
Tool calls: 2
Cost: 0.0081 DA
Balance remaining: 142.3 DA
- Tools — full tool API.
- Stop Conditions —
no_tool_calls and others.
- Streaming — streaming inside a tool loop.
- Example: Skills Loader — dynamic tool loading.