The easiest way to get started is to head to our platform and run a workflow from there: https://platform.asteroid.ai

If you want to run a workflow from your own code, you can follow the steps below

1

Install dependencies

Install the asteroid-sdk TypeScript SDK (we have a Python SDK too)

npm install asteroid-odyssey
2

Generate an API key

Sign in to https://platform.asteroid.ai, head to API Keys and generate a new key.

  export ASTEROID_API_KEY="ast..."

See API Keys for more.

3

Initialise Asteroid

Before your agent starts running, you need to initialise Asteroid:

import { AsteroidAgents } from 'asteroid-odyssey';
import { CreateWorkflowRequest } from 'asteroid-odyssey/dist/generated/agents/models/CreateWorkflowRequest';

// Define a simple prompt with a single variable: {{.date}}
const prompt = `You are an AI assistant tasked with performing a simple task.
Use your available tools to navigate to {{.website}} and book a meeting with {{.name}}.
`;

// Initialize the Asteroid agent with your API key.
// Replace 'YOUR_ASTEROID_API_KEY' with your actual key.
const asteroid = new AsteroidAgents('astdaEUCZJHFeS1DDQMKWQYEb0ei2cgGWSt2fWrGqIEYBZQNSAAdV911ZcrJahVD');

/**
* This function creates a workflow, runs it with the current date,
* and polls until the workflow is completed.
*/
async function runSimpleWorkflowExample() {
try {
// Configure the workflow request
const workflowRequest: CreateWorkflowRequest = {
  name: "Simple Task Workflow",
  fields: {
    workflow_name: "Booking Assistant",
    start_url: "https://google.com"
  },
  prompts: [prompt],
  provider: CreateWorkflowRequest.provider.OPENAI
};

// Create the workflow
const workflowID = await asteroid.createWorkflow("ceres", workflowRequest);
console.log('Workflow created with ID:', workflowID);

// Run the workflow with the required variable
const runID = await asteroid.runWorkflow(workflowID, {
  website: "https://asteroid.ai",
  name: "Asteroid Team"
});
console.log('Workflow run initiated with ID:', runID);

// Poll for the workflow status until it is completed
let attempts = 0;
while (attempts < 200) {
  try {
    const status = await asteroid.getRunStatus(runID);
    console.log('Current workflow status:', status);
    if (status === 'completed') {
      break;
    }
  } catch (error) {
    console.log('Run is not ready')
  }
  attempts++;
  await new Promise(resolve => setTimeout(resolve, 1000));
}

// Retrieve and display the result after completion
const result = await asteroid.getRunResult(runID);
console.log('Workflow completed. Result:', result);
} catch (error) {
console.error('Error executing the workflow:', error);
}
}

// Execute the workflow example
runSimpleWorkflowExample();