Page cover image

API Code Examples

This page provides code examples for running the APIs in Python.

Before running any of the scripts, run export ARCEE_API_TOKEN=$YOUR_TOKEN.

List Available Workflows

import requests
import os

# Setup
API_BASE_URL = "https://orchestra.arcee.ai/api/v1/workflow"
API_KEY = os.environ.get("ARCEE_API_TOKEN")
headers = {"Authorization": f"Bearer {API_KEY}"}

# List workflows
response = requests.get(f"{API_BASE_URL}/workflows", headers=headers)
print(response.json())

Workflow Execution

import requests
import os

# Setup
API_BASE_URL = "https://orchestra.arcee.ai/api/v1/workflow"
API_KEY = os.environ.get("ARCEE_API_TOKEN")
headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
workflow_id = "YOUR_WORKFLOW_ID"

# Execute a workflow
payload = {"prompt": "Tell me a joke about the weather"}
response = requests.post(f"{API_BASE_URL}/workflows/{workflow_id}/execute", 
                        headers=headers, 
                        json=payload)

print(response.json())

Workflow Execution Steps

import requests
import os

# Setup
API_BASE_URL = "https://orchestra.arcee.ai/api/v1/workflow"
API_KEY = os.environ.get("ARCEE_API_TOKEN")
headers = {"Authorization": f"Bearer {API_KEY}"}
workflow_id = "YOUR_WORKFLOW_ID"
run_id = "YOUR_RUN_ID"

# Get workflow execution steps
response = requests.get(f"{API_BASE_URL}/workflows/{workflow_id}/runs/{run_id}/steps", headers=headers)
run_details = response.json()
print(run_details)

Execution History

import requests
import os

# Setup
API_BASE_URL = "https://orchestra.arcee.ai/api/v1/workflow"
API_KEY = os.environ.get("ARCEE_API_TOKEN")
headers = {"Authorization": f"Bearer {API_KEY}"}
workflow_id = "YOUR_WORKFLOW_ID"
limit = 10
offset = 0

# Get execution history
response = requests.get(f"{API_BASE_URL}/workflows/{workflow_id}/runs?limit={limit}&offset={offset}", headers=headers)
print(response.json())

Workflow Diagram

import requests
import os

# Setup
API_BASE_URL = "https://orchestra.arcee.ai/api/v1/workflow"
API_KEY = os.environ.get("ARCEE_API_TOKEN")
headers = {"Authorization": f"Bearer {API_KEY}"}
workflow_id = "YOUR_WORKFLOW_ID"

# Get workflow diagram
response = requests.get(f"{API_BASE_URL}/workflows/{workflow_id}/diagram", headers=headers)
print(response.json())

Last updated