const response = await fetch(
"https://gateway.deepmako.com/v1/chat/completions",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"x-wallet-address": "0xYourWalletAddress",
},
body: JSON.stringify({
model: "conductor",
messages: [{ role: "user", content: "what is gas on base?" }],
stream: true,
}),
}
);
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value);
for (const line of text.split("\n")) {
if (!line.startsWith("data: ")) continue;
const payload = line.slice(6);
if (payload === "[DONE]") break;
const event = JSON.parse(payload);
if (event.type === "tool_start") {
console.log(`🔧 Calling ${event.tool}...`);
} else if (event.type === "tool_trace") {
console.log(`✅ ${event.tool}: ${JSON.stringify(event.result)}`);
} else if (event.choices?.[0]?.delta?.content) {
process.stdout.write(event.choices[0].delta.content);
}
}
}