Quick Start
Hello World in 30 Seconds
Python
pip install computer-agentsfrom 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_KEYenvironment variable. Get one here →
Step-by-Step Guide
Want more control? Here’s the full walkthrough.
1. Install the SDK
Python
pip install computer-agents2. 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_here3. Run a Task with Streaming
Python
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_xyz7894. Continue the Conversation
The threadId maintains context. Use it to build on previous work:
Python
# 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:
Python
# 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:
Python
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"):
- Environment — The SDK checks for a default environment; creates one if needed
- Thread — A new conversation thread is created in the cloud
- Execution — Your task is sent to a Claude agent running in an isolated container
- Streaming — The agent’s work streams back in real-time via SSE
- 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
- API Resources - Learn about all available resources
- Streaming & Events - Handle events in real-time
- Advanced Patterns - Production patterns and best practices
Last updated on