Skip to main content

Official Python SDK for the Computer Agents Cloud API. Execute Claude-powered AI agents in isolated cloud containers.

Project description

Computer Agents Python SDK

PyPI version Python versions License: MIT

The official Python SDK for the Computer Agents Cloud API. Execute Claude-powered AI agents in isolated cloud containers.

Installation

pip install computer-agents

Quick Start

from computer_agents import ComputerAgentsClient

client = ComputerAgentsClient(api_key="ca_your_api_key")

# Execute a task
result = client.run(
    "Create a REST API with Flask",
    environment_id="env_xxx",
    on_event=lambda e: print(e["type"]),
)

print(result.content)
print(f"Thread ID: {result.thread_id}")

Multi-Turn Conversations

# Create a thread for persistent conversation
thread = client.threads.create(environment_id="env_xxx")

# First message
result = client.threads.send_message(
    thread["id"],
    content="Create a Python web server",
    on_event=lambda e: print(e),
)

# Follow-up (continues same session)
result2 = client.threads.send_message(
    thread["id"],
    content="Add authentication to the server",
)

Environments

# Create a custom environment
env = client.environments.create(
    name="data-science",
    internet_access=True,
    runtimes={"python": "3.12"},
)

# Install packages
client.environments.install_packages(env["id"], "python", ["pandas", "numpy"])

# Add MCP servers
client.environments.update(
    env["id"],
    mcp_servers=[{
        "type": "stdio",
        "name": "filesystem",
        "command": "npx",
        "args": ["@modelcontextprotocol/server-filesystem", "/workspace"],
    }],
)

Agents

# Create a custom agent
agent = client.agents.create(
    name="Code Reviewer",
    model="claude-sonnet-4-5",
    instructions="You are a thorough code reviewer.",
    enabled_skills=["web_search"],
)

# Use the agent
thread = client.threads.create(
    environment_id="env_xxx",
    agent_id=agent["id"],
)

Files

# Upload a file
client.files.upload_file(
    "env_xxx",
    filename="app.py",
    content='print("hello")',
    path="src",
)

# Download a file
content = client.files.get_file("env_xxx", "src/app.py")

# List files
files = client.files.list_files("env_xxx")

Git Operations

diff = client.git.diff("env_xxx")
client.git.commit("env_xxx", message="Update feature")
client.git.push("env_xxx")

Schedules

schedule = client.schedules.create(
    name="Daily Report",
    agent_id="agent_xxx",
    agent_name="Reporter",
    task="Generate daily report",
    schedule_type="recurring",
    cron_expression="0 9 * * *",
)

Configuration

The API key can be provided via:

  1. Constructor argument: ComputerAgentsClient(api_key="ca_...")
  2. Environment variable: COMPUTER_AGENTS_API_KEY
# Custom base URL and timeout
client = ComputerAgentsClient(
    api_key="ca_...",
    base_url="https://custom-api.example.com",
    timeout=120.0,
    debug=True,
)

Context Manager

with ComputerAgentsClient(api_key="ca_...") as client:
    result = client.run("Hello world", environment_id="env_xxx")
    print(result.content)
# Client is automatically closed

API Resources

Resource Description
client.threads Conversation management with SSE streaming
client.environments Environment configuration and container lifecycle
client.agents Agent configuration (model, instructions, skills)
client.files File management in environment workspaces
client.schedules Scheduled task management
client.triggers Event-driven triggers
client.orchestrations Agent-to-agent orchestration
client.budget Budget and usage tracking
client.billing Billing records and statistics
client.git Git operations on workspaces

Requirements

  • Python >= 3.9
  • httpx >= 0.25.0

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

MIT - see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

computer_agents-2.3.0.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

computer_agents-2.3.0-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

Details for the file computer_agents-2.3.0.tar.gz.

File metadata

  • Download URL: computer_agents-2.3.0.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for computer_agents-2.3.0.tar.gz
Algorithm Hash digest
SHA256 cc5de63f5cfdeff303b326d4370cd8e423f8bdc3c43abc1ed0904e2adc5bbc01
MD5 7263cd4decc99679d88c668f53689851
BLAKE2b-256 3d70256d859e23d8c33156885cb4d15e0cd9c3aee2d3212a44b5dfcca088473b

See more details on using hashes here.

File details

Details for the file computer_agents-2.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for computer_agents-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea1e42e51e3d4c5dd08826a10218a835ea08e44a8888e615e9695400e349166a
MD5 d8c8977cf5688bcbf7626b746f92cc41
BLAKE2b-256 b0a89eb4cffd4a6b395f2caaa51f32d705ffa0cca24d789b7d5325609176f30e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page