Overview

This guide will help you get started with Julep in just 5 minutes. You’ll learn how to create your first AI agent and execute a simple task.

What we’ll build

We’ll build a simple agent that uses tasks to write a short story.

Agent YAML
name: Story Generator
model: claude-3.5-sonnet
about: A helpful AI assistant that specializes in writing and editing.
Task YAML
name: Write a short story
description: Write a short story about a magical garden
main:
- prompt:
  - role: system
    content: You are a creative story writer.
  - role: user
    content: $ f'Write a short story about {steps[0].input.topic}'

Prerequisites

Step 1: Install Julep

Choose your preferred language:

pip install julep

Step 2: Initialize the Client

from julep import Julep

client = Julep(api_key="your_julep_api_key")

Step 3: Create Your First Agent

Let’s create a simple AI agent that can help with writing tasks:

agent = client.agents.create(
    name="Writing Assistant",
    model="claude-3.5-sonnet",
    about="A helpful AI assistant that specializes in writing and editing."
)

Step 4: Create a Simple Task

Let’s create a task that generates a short story based on a given topic:

import yaml 

task_definition = yaml.safe_load("""
name: Story Generator
description: Generate a short story based on a given topic
main:
- prompt:
  - role: system
    content: You are a creative story writer.
  - role: user
    content: $ f'Write a short story about {steps[0].input.topic}'
""")

task = client.tasks.create(
    agent_id=agent.id,
    **task_definition # Unpack the task definition
)

Step 5: Execute the Task

Now let’s run the task with a specific topic:

execution = client.executions.create(
    task_id=task.id,
    input={"topic": "a magical garden"}
)

# Wait for the execution to complete
while (result := client.executions.get(execution.id)).status not in ['succeeded', 'failed']:
    print(result.status)
    time.sleep(1)

if result.status == "succeeded":
    print(result.output)
else:
    print(f"Error: {result.error}")

Next Steps

Congratulations! You’ve created your first Julep agent and executed a task. Here’s what you can explore next: