These examples are aligned with the current SDK surfaces documented on the TypeScript SDK and Python SDK pages.Documentation Index
Fetch the complete documentation index at: https://docs.asteroid.ai/llms.txt
Use this file to discover all available pages before exploring further.
- Basic Execution
- Interactive Run
- Files
Start an execution and poll until the result is available.
import { client, agentExecutePost, executionGet } from 'asteroid-odyssey';
client.setConfig({
headers: { 'X-Asteroid-Agents-Api-Key': process.env.ASTEROID_API_KEY! },
});
const { data, error } = await agentExecutePost({
path: { agentId: 'your-agent-id' },
body: {
inputs: {
patientName: 'Jane Doe',
appointmentDate: '2026-03-27',
},
metadata: {
source: 'cookbook-basic',
},
},
});
if (error) throw new Error(JSON.stringify(error));
const executionId = data.executionId;
let exec;
do {
await new Promise((r) => setTimeout(r, 3000));
const res = await executionGet({ path: { executionId } });
exec = res.data;
} while (exec?.status === 'running' || exec?.status === 'starting');
console.log(exec?.status, exec?.inputs);
Handle runs that pause and need a user message before they can continue.
import {
client,
agentExecutePost,
executionGet,
executionUserMessagesAdd,
} from 'asteroid-odyssey';
client.setConfig({
headers: { 'X-Asteroid-Agents-Api-Key': process.env.ASTEROID_API_KEY! },
});
const { data, error } = await agentExecutePost({
path: { agentId: 'your-agent-id' },
body: {
inputs: {
task: 'Ask the user to confirm before submitting the final form',
},
},
});
if (error) throw new Error(JSON.stringify(error));
const executionId = data.executionId;
// Wait for the agent to pause for input
let exec;
do {
await new Promise((r) => setTimeout(r, 3000));
const res = await executionGet({ path: { executionId } });
exec = res.data;
} while (exec?.status === 'running' || exec?.status === 'starting');
if (exec?.status === 'paused_by_agent') {
await executionUserMessagesAdd({
path: { executionId },
body: { message: 'Confirmed. Please continue.' },
});
}
// Continue polling until terminal state
do {
await new Promise((r) => setTimeout(r, 3000));
const res = await executionGet({ path: { executionId } });
exec = res.data;
} while (exec?.status === 'running' || exec?.status === 'paused_by_agent');
console.log(exec?.status);
Attach files to executions and download the files produced by a run.
import {
client,
agentExecutePost,
tempFilesStage,
executionContextFilesUpload,
executionContextFilesGet,
} from 'asteroid-odyssey';
import { readFileSync, writeFileSync } from 'node:fs';
client.setConfig({
headers: { 'X-Asteroid-Agents-Api-Key': process.env.ASTEROID_API_KEY! },
});
const invoiceBytes = readFileSync('./invoice.pdf');
const invoice = new File([invoiceBytes], 'invoice.pdf', { type: 'application/pdf' });
const { data: staged } = await tempFilesStage({
path: { organizationId: 'your-org-id' },
body: { files: [invoice] },
});
const { data, error } = await agentExecutePost({
path: { agentId: 'your-agent-id' },
body: {
inputs: {
task: 'Read the attached invoice and summarize it',
},
tempFiles: staged?.tempFiles,
},
});
if (error) throw new Error(JSON.stringify(error));
const executionId = data.executionId;
await executionContextFilesUpload({
path: { executionId },
body: { files: [invoice] },
});
const { data: files } = await executionContextFilesGet({
path: { executionId },
});
for (const file of files ?? []) {
const response = await fetch(file.downloadUrl, {
headers: { 'X-Asteroid-Agents-Api-Key': process.env.ASTEROID_API_KEY! },
});
if (!response.ok) throw new Error(`Download failed: ${response.status}`);
writeFileSync(`./downloads/${file.fileName}`, Buffer.from(await response.arrayBuffer()));
}
Related Resources
TypeScript SDK
See the current TypeScript helper and generated namespaces
Python SDK
See the current Python high-level client and generated subpackages

