Get started | WorkflowAI

Get started

WorkflowAI Python SDK is a library that allows you to programmatically create and run agents in Python, while being able to use the full power of the WorkflowAI platform.

workflowai requires Python >= 3.9.

PyPI versionarrow-up-right

Get your API key from your WorkflowAI Cloud dashboardarrow-up-right or from your self-hosted WorkflowAI dashboard.

Set the WORKFLOWAI_API_KEY environment variable.

import os
import workflowai

workflowai.init( # This initialization is optional when using default settings
    api_key=os.environ.get("WORKFLOWAI_API_KEY"),  # This is the default and can be omitted
    url="https://run.workflowai.com",  # This is the default and can be omitted
)

You can also set the WORKFLOWAI_API_URL environment variable to point to your self-hosted WorkflowAI.

An agent is in essence an async function with the added constraints that:

  • it has a single argument that is a Pydantic model, which is the input to the agent

  • it has a single return value that is a Pydantic model, which is the output of the agent

  • it is decorated with the @workflowai.agent() decorator

The following agent, given a city, returns the country, capital, and a fun fact about the city.

You have created your first agent! Congratulations.

Agents created by the SDK are also available in the Playgroundarrow-up-right.

Playgroundarrow-up-right

Runs are automatically logged as well from the Runsarrow-up-right section.

Runsarrow-up-right

Let's go through in more detail how to setup an agent.

Last updated