Skip to Content
AgentsQuick Start

Quick Start

Hello World in 30 Seconds

pip install computer-agents
from computer_agents import ComputerAgentsClient client = ComputerAgentsClient() result = client.run("Create a file called hello.py that prints Hello World") print(result.content)

That’s it. Three lines of code. The SDK automatically creates a default cloud environment, provisions a thread, streams the agent’s work, and returns the result.

Prerequisites: A Computer Agents API key set as COMPUTER_AGENTS_API_KEY environment variable. Get one here → 


Step-by-Step Guide

Want more control? Here’s the full walkthrough.

1. Install the SDK

pip install computer-agents

2. Set Your API Key

export COMPUTER_AGENTS_API_KEY="tb_your_api_key_here"

Or create a .env file:

COMPUTER_AGENTS_API_KEY=tb_your_api_key_here

3. Run a Task with Streaming

from computer_agents import ComputerAgentsClient client = ComputerAgentsClient() # Run with streaming events result = client.run( "Create a Flask API with a /health endpoint", on_event=lambda e: print(f"[{e['type']}]"), ) print(f"\nResult: {result.content}") print(f"Thread ID: {result.thread_id}")

You should see output like:

[response.started] [response.item.completed] [response.item.completed] [response.completed] Result: I've created a Flask API with a /health endpoint. Thread ID: thread_xyz789

4. Continue the Conversation

The threadId maintains context. Use it to build on previous work:

# Continue from the previous result follow_up = client.run( "Add a /api/users endpoint that returns sample data", thread_id=result.thread_id, ) print(follow_up.content)

5. Work with Files

Upload files to your environment and let the agent use them:

# Get your default environment setup = client.quick_setup() env_id = setup["environment"]["id"] # Upload a file client.files.upload_file( env_id, filename="config.json", content='{"debug": true}', ) # Ask the agent to use it client.run("Read config.json and print its contents") # Download files the agent created content = client.files.get_file(env_id, "hello.py") print(content)

Complete Example

A more complete example with error handling and multi-step tasks:

from computer_agents import ComputerAgentsClient, ApiClientError client = ComputerAgentsClient() def main(): try: # Task 1: Create a project r1 = client.run( "Create a simple Express.js server with a /health endpoint", on_event=lambda e: print(f"[{e['type']}]"), ) print("\n--- Task 1 Complete ---") print(r1.content) # Task 2: Add features (continues the conversation) r2 = client.run( "Add a /api/users endpoint that returns sample user data", thread_id=r1.thread_id, ) print("\n--- Task 2 Complete ---") print(r2.content) # Task 3: Add tests r3 = client.run( "Create Jest tests for the endpoints", thread_id=r1.thread_id, ) print("\n--- Task 3 Complete ---") print(r3.content) except ApiClientError as e: print(f"API Error: {e.message}") print(f"Status: {e.status}") main()

What’s Happening Under the Hood

When you call client.run("task"):

  1. Environment — The SDK checks for a default environment; creates one if needed
  2. Thread — A new conversation thread is created in the cloud
  3. Execution — Your task is sent to a Claude agent running in an isolated container
  4. Streaming — The agent’s work streams back in real-time via SSE
  5. Result — You get the response content and a thread ID for follow-ups

All files the agent creates persist in your environment’s cloud workspace.

Next Steps

Last updated on