Quick Start
Get up and running with Cyberdesk in under 5 minutes. This guide assumes you’ve already created workflows in the Cyberdesk Dashboard.1
Install the SDK
2
Initialize the client and create a run
- Async
- Sync
Create and manage workflows in the Cyberdesk Dashboard. The dashboard supports rich, multimodal prompts — you can insert images alongside text to help the agent understand tricky UI elements. Use the SDK to execute runs against those workflows.
Installation & Setup
Prerequisites
- Python 3.10 or higher
- pip, poetry, or pipenv for package management
Installation
- pip
- poetry
- pipenv
Virtual Environment Setup
Authentication
Creating a Client
Custom Base URL
For self-hosted or enterprise deployments:Using Context Managers
The client supports standard context managers for proper resource cleanup:Automatic Retries
The SDK automatically retries failed requests with exponential backoff, following industry best practices similar to the Stripe SDK. This handles transient network issues and server errors gracefully without requiring any code changes.Default Behavior
- Retry count: 3 retries (4 total attempts)
- Retryable errors: Network failures, connection timeouts, DNS errors
- Retryable status codes: 408, 429, 500, 502, 503, 504, and
409only whenIdempotency-Status: in_progress - Non-retryable: Most 4xx client errors
- Backoff strategy: Exponential backoff with full jitter (250ms initial, 8s max)
- Retry-After header: Respected when present
Configuring Retries
Retries only occur for network-level failures and specific HTTP status codes that indicate temporary server issues. Most client errors (4xx) are not retried because they indicate a problem with the request itself.
Idempotency
For write requests (POST, PUT, PATCH, DELETE), the SDK automatically adds anIdempotency-Key header. If a completed request is retried with the same key, the API replays the stored response. If the original request is still in progress, the API returns 409 with Retry-After. 5xx responses are not replay-cached, so a later retry with the same key may execute again.
Default Behavior
- Enabled by default: All write requests automatically include an idempotency key
- Key generation: Uses
uuid.uuid4()to generate unique keys - Server-side handling: Completed responses are replayed for duplicate keys; in-progress duplicates return
409
Configuring Idempotency
Sync vs Async
The Cyberdesk Python SDK provides both synchronous and asynchronous methods for all operations.When to Use Async
Use async methods when:- Building web applications with async frameworks (FastAPI, aiohttp)
- Making multiple concurrent API calls
- Integrating with other async libraries
- Building high-performance applications
When to Use Sync
Use sync methods when:- Writing simple scripts
- Working in Jupyter notebooks
- Integrating with sync-only frameworks (Django, Flask)
- Learning or prototyping
Method Naming Convention
- Async methods:
client.resource.method() - Sync methods:
client.resource.method_sync()
Working with Runs
Runs are the primary way to execute workflows in Cyberdesk. Here’s everything you need to know about managing runs through the SDK.Creating a Run
- Async
- Sync
Prioritizing a Run
Setis_priority=True when a run should be matched before normal queued runs:
False. RunBulkCreate and WorkflowChainCreate also accept is_priority; one value applies to every run created by that request. Priority affects the next eligible machine assignment only—it does not interrupt running work or let a later run bypass an earlier run in the same session or chain. In-place retries keep the run’s existing priority unless the retry request supplies an is_priority override.
Priority runs are processed before normal runs. A sustained stream of priority work can delay normal queued runs.
Creating a Run with Sensitive Input Values
If your workflow prompt references sensitive variables using the{$variable} syntax (for example, {$password}), pass those values via sensitive_input_values.
- Async
- Sync
Sensitive inputs are stored in a secure third‑party secret vault (Basis Theory) only for the duration of the run. They are not logged in Cyberdesk, and they are not sent to any LLMs. The values are only resolved at the last moment during actual computer actions (e.g., when typing). After the run completes, these sensitive values are deleted from the vault. On the dashboard, sensitive inputs are never displayed and will not be prefilled when repeating a run.
Creating a Run with Machine Pools
You can specify pool requirements when creating a run. This ensures your run is executed on a machine that belongs to ALL specified pools. This is especially useful for:- Running workflows on customer-specific machines
- Requiring machines with specific software installed
- Organizing machines by location or capability
- Async
- Sync
Pool Matching Logic: When you specify multiple pools, Cyberdesk will only select machines that belong to ALL specified pools (intersection). For example, if you specify
["Customer A", "Has Excel"], only machines that are in both pools will be considered.If you provide a
machine_id when creating a run, pool_ids are ignored. Cyberdesk will only attempt the specified machine; if it’s busy or unavailable, the run will wait until that machine is free (no fallback to other machines or pools).Creating a Run with File Inputs
You can attach files to a run at creation. This is useful for workflows that need to process or manipulate files on the remote machine.- Async
- Sync
string
required
The name of the file, including its extension.
string
required
The base64-encoded content of the file.
string
The absolute path on the remote machine where the file should be saved. If not provided, it defaults to
~/CyberdeskTransfers/.boolean
If
True, the file will be deleted from the remote machine after the run completes (whether it succeeds or fails). Defaults to False.Listing Runs
- Async
- Sync
Faster lists with fields projection
Use the optional
fields parameter to return only selected fields per run. This reduces payload size and speeds up listing, especially when you do not need heavy JSON fields like run_message_history.Need to fetch screenshots referenced in
run_message_history? See Run Screenshots for signed URL examples.- Base fields always included:
id,workflow_id,machine_id,status,created_at. - Add more by passing
fields=[...].
- Async
- Sync
If you need full records (including
run_message_history), call list() without fields.Getting a Specific Run
- Async
- Sync
Updating a Run
Run updates are typically handled automatically by the Cyberdesk system. Manual updates are rarely needed.
- Async
- Sync
Retrying a Run (same run_id)
Use retry when you want to re-run the exact same run id, clearing outputs and optionally providing fresh inputs/files. Sensitive values: always re-sendsensitive_input_values on retry; secrets are deleted after each run.
File inputs: if you set cleanup_imports_after_run=True, files are deleted from the remote machine after the run; include file_inputs again if you need a fresh copy or when no input attachments exist (providing file_inputs replaces prior input attachments).
Regular inputs: only send input_values if you want to change them; otherwise the previous ones are reused.
- Async
- Sync
Behavior:
- Retry is allowed only for terminal runs:
success,task_failed,error, orcancelled. - Outputs, history, and output attachments are always cleared.
- Prior input attachments are kept unless you provide
file_inputs(then they are replaced). - If you provide
sensitive_input_values, new secrets are created; otherwise sensitive aliases are cleared. - When a
session_idis present and the session is busy, immediate assignment is skipped and the retried run queues. - Avoid sending both
machine_idandpool_idson retry; if both are present,pool_idstake precedence.
Deleting a Run
- Async
- Sync
Polling for Run Completion
Here’s a robust pattern for waiting for runs to complete:- Async
- Sync
Working with File Attachments
Manage files associated with your runs, such as input files uploaded at creation or output files generated by a workflow.Listing Run Attachments
You can list all attachments for a specific run and filter them by type (INPUT or OUTPUT).
- Async
- Sync
Downloading an Attachment
There are multiple ways to download attachments depending on your use case:Method 1: Get a Download URL
Get a signed URL that triggers automatic download when accessed. This is perfect for web applications where you want to provide download links to users.- Async
- Sync
Method 2: Download Raw File Content
Download the file content directly as bytes. Useful when you need to process the file in memory.- Async
- Sync
Method 3: Save to File (Convenience Method)
The SDK provides a convenience method that downloads and saves the file in one operation.- Async
- Sync
Example: Upload, Process, and Download
Here’s a full example of a workflow that processes a file.- Workflow Prompt:
"Take the file at ~/CyberdeskTransfers/report.txt, add a summary to the end of it, and mark it for export." - Workflow Setting:
includes_file_exportsis set toTrue.
Sessions and Chained Runs
At its core, a session is a reservation of a single machine. While a session is active, that machine is dedicated to your session only — no unrelated runs will be scheduled onto it. This guarantees your multi‑step automations run back‑to‑back on the same desktop without interference. What you get from a session:- Exclusive access to one machine for the session’s duration (strong scheduling guarantee)
- Deterministic “step 1 → step 2 → …” behavior with no opportunistic interleaving
Passing data between steps with refs
Once you have multiple workflows running in the same session, you’ll often want to pass outputs from earlier steps as inputs to later ones. Refs make this seamless — simply reference a previous step’s output using a JSON object:Start a new session and run a chain (best when you know the whole sequence)
- Provide
machine_idto target a specific machine, orpool_idsto match any machine in all specified pools (intersection). - The chain runs on one reserved session. If you omit
session_id, the API creates one and reserves a machine before step 1. shared_inputsare merged into each step, and step-levelinputsoverride shared values when the same key appears in both places.shared_sensitive_inputsare available to all steps in the chain.sensitive_inputsin individual steps provide step-specific sensitive values that override or extend the shared ones. If the same key exists in both, the step-specific value takes precedence.shared_file_inputs(if provided) are attached to the first run in the chain.
Join an existing session
session_id or machine_id/pool_ids, not both.
Keep the session alive after the chain
session_id to continue work on the same machine.
Ad‑hoc sessions without a chain (start with a single run, then add more)
You can start a session with a normal run and then submit additional runs referencing the samesession_id — useful when downstream steps are conditional or discovered at runtime.
Automatic session release with release_session_after
When creating individual runs in a session (not using chains), you can userelease_session_after=True to automatically release the session when that run completes (regardless of success or failure):
Detecting session completion via webhooks
Therelease_session_after field on a run indicates whether this run released the session. You can use this in your webhook handler to detect when all runs in a session are complete:
True when:
- You explicitly set
release_session_after=Trueon a run - A chain completes with
keep_session_after_completion=False(the last run gets this flag) - A run errors, task-fails, or is cancelled and causes the session to be released
Polling chain runs
The chain API returns run_ids in creation order; you can poll them individually, or receive a webhook when any of those runs completeReal‑world cases that require sessions
- EHR workflows: Log into Epic, navigate to a specific patient, extract their data, then upload documents to their chart — all with no interruptions from other miscellaneous runs.
- Financial reporting: Export monthly reports from your ERP system, transform the data in Excel, then re‑import the processed results — all back‑to‑back without interference.
- Document processing: Download files from a web portal, process them with a local application, then upload the results back — ensuring no other runs interfere with your workflow.
Bulk Creating Runs with Pools
When creating multiple runs in bulk, you can also specify pool requirements. All runs will be distributed across machines that match the pool criteria.If you provide a
machine_id in a bulk run request, pool_ids are ignored for those runs. Each run will only target the specified machine; if it is busy, the run will wait for that machine rather than falling back to other machines or pools.- Async
- Sync
Bulk Run Assignment: When bulk creating runs with pool requirements, Cyberdesk attempts to assign each run to any available machine that meets all specified pools. If no matching machine is available, runs remain in scheduling until one is free. No specific load balancing guarantees are made.
Real-World Example: Healthcare Integration
Here’s a complete example of retrieving patient data from an Epic EHR system using Cyberdesk:- FastAPI Integration
- Django Integration
- Script Example
Other SDK Resources
Pools
Pools
- Async
- Sync
Machines
Machines
- Async
- Sync
Workflows
Workflows
- Async
- Sync
Workflow Prompt Images
Workflow Prompt Images
Upload and manage images for use in workflow prompts. The returned
supabase_url can be embedded directly in workflow prompt HTML.- Async
- Sync
Using prompt images in workflows: After uploading, copy the Cyberdesk automatically resolves these URLs when running workflows, displaying the images to the AI agent.
supabase_url and use it in your workflow’s main_prompt HTML:Connections
Connections
- Async
- Sync
Trajectories
Trajectories
- Async
- Sync
Workflow Tag Groups
Workflow Tag Groups
Group tags for organization and mutual exclusivity. Only one tag from a group can be assigned to a workflow at a time.
- Async
- Sync
Model Configurations
Model Configurations
- Async
- Sync
Usage
Usage
- Async
- Sync
Error Handling
All SDK methods return anApiResponse object with data and error attributes:
Common Error Types
- Unexpected HTTP status / transport errors: surfaced in
response.erroras exceptions. For HTTP failures, checkgetattr(response.error, "status_code", None). - Validation errors (
422): returned inresponse.data.detail, notresponse.error. - Successful responses: returned in
response.data.
Exception Handling Pattern
Type Hints and IDE Support
The SDK provides comprehensive type hints for better IDE support:Working with Jupyter Notebooks
The SDK works seamlessly in Jupyter notebooks:Best Practices
Use Environment Variables
Store API keys and workflow IDs in environment variables, never in code.
Built-in Retry Logic
The SDK automatically retries on transient failures with exponential backoff. Adjust
retry=RetryConfig(...) if needed.Handle Timeouts
Set reasonable timeouts for run completion based on your workflow complexity.
Log Everything
Keep detailed logs of run IDs and statuses for debugging and audit trails.
Use Type Hints
Leverage type hints for better IDE support and fewer runtime errors.
Close Connections
Use context managers or explicitly close clients to free resources.
Performance Optimization
Concurrent Operations
When working with multiple operations, use asyncio for better performance:Connection Pooling
The SDK automatically manages connection pooling for optimal performance. No additional configuration is needed.Next Steps
API Reference
Explore the complete API documentation
Dashboard
Create and manage workflows in the dashboard
Examples
Browse more code examples and use cases