This guide will help you quickly set up and run your first Inferable agent workflow.

We will build a simple workflow that greets the user, as an illustration of the basic concepts.

1

Create a demo cluster

A cluster is a logical grouping of tools, agents and workflows that work together.
mkdir inferable-demo
cd inferable-demo
curl -XPOST https://api.inferable.ai/ephemeral-setup > cluster.json
2

Install dependencies

bash npm init -y npm install inferable tsx

3

Create a simple tool

Tools are plain old functions that allow the agent to take actions on your behalf. All tools run on the machine that they are registered on.

Create a file called tools.ts:

import { Inferable } from "inferable";
import os from "os";

const inferable = new Inferable({
  apiSecret: require('./cluster.json').apiKey,
});

// Register a simple tool that returns a greeting
inferable.tools.register({
  name: "greet",
  func: async (input) => {
    return `Hello, ${input.name}! My name is ${os.hostname()}.`;
  },
  schema: {
    input: z.object({
      name: z.string(),
    }),
  },
});

inferable.tools.listen();
4

Create a workflow

Workflows are a way to orchestrate agents. They are durable, distributed, and run on the machine that they are registered on.

Create a file called workflow.ts:

import { Inferable, helpers } from "inferable";

const inferable = new Inferable({
  apiSecret: require('./cluster.json').apiKey,
});

const workflow = inferable.workflows.create({
  name: "greeting",
  inputSchema: z.object({
    executionId: z.string(),
    userName: z.string(),
  }),
});

workflow.version(1).define(async (ctx, input) => {
  const greetingAgent = ctx.agent({
    name: "greeter",
    systemPrompt: helpers.structuredPrompt({
      facts: ["You are a friendly greeter"],
      goals: ["Return a greeting to the user"]
    }),
    resultSchema: z.object({
      greeting: z.string(),
    }),
  });

  const result = await greetingAgent.trigger({
    data: {
      name: input.userName,
    }
  });

  console.log(result.result.greeting);
});

workflow.listen();
5

Run the workflow

Workflows can be triggered from anywhere, including from other workflows.

# Get your cluster details
CLUSTER_ID=$(cat cluster.json | jq -r .id)
API_SECRET=$(cat cluster.json | jq -r .apiKey)

# Run the workflow
curl -XPOST https://api.inferable.ai/clusters/$CLUSTER_ID/workflows/greeting/executions \
  -d '{"executionId": "123", "userName": "Alice"}' \
  -H "Authorization: Bearer $API_SECRET"

That’s it! You’ve created your first Inferable workflow. This simple example demonstrates the basic concepts of:

  • Creating a cluster
  • Registering tools
  • Defining a workflow
  • Creating an agent
  • Running the workflow

For a more complex example involving customer support and database interactions, check out our From Scratch guide.