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-odyssey 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 details.

3

Initialise Asteroid

Initialize and execute your workflow in your code:

import { 
  AsteroidClient, 
  // Optionally, you can create a new workflow using createNewWorkflow:
  // This only needs to be done once. You can also create a workflow on the platform.
  createNewWorkflow,
  executeWorkflowById, 
  waitForExecutionResult 
} from 'asteroid-odyssey';

(async () => {
  const client = AsteroidClient('YOUR_ASTEROID_API_KEY');

  const workflowId = await createNewWorkflow(client, 'iris', {
    name: "Example Workflow",
    start_url: "https://google.com",
    prompts: ["Go to the {{.repository}} GitHub repo and find the commit message of the {{.commit_number}} most recent commit."],
    provider: "openai"
  });
  console.log("View your new workflow at: https://platform.asteroid.ai/workflows/" + workflowId);

  // Execute an existing workflow.
  // Replace 'YOUR_WORKFLOW_ID' with your workflow ID and adjust the execution data as needed.
  const executionId = await executeWorkflowById(client, 'YOUR_WORKFLOW_ID', { repository: "kubernetes/kubernetes", commit_number: 3 });
  console.log("Workflow execution started:", "https://platform.asteroid.ai/executions/" + executionId);

  // Wait for execution to complete and retrieve the result.
  try {
    const result = await waitForExecutionResult(client, executionId, 2000);
    console.log("Workflow result:", result);
  } catch (err) {
    console.error("Workflow ended with an error:", err);
  }
})();