Getting started with the cloudcode SDK is straightforward. Follow these steps to install and set up the SDK in your environment.

Prerequisites

  • Python 3.10 or higher
  • Pip package manager
  • Access to cloudcode API key (or provider API keys)

Installation Steps

1. Install via pip

The simplest way to install the cloudcode SDK is via pip:

pip install cloudcode

This will install both the Local SDK and the Sandbox SDK components.

2. Verify Installation

You can verify the installation by importing the SDK in a Python script:

from cloudcode import Local

# Check available models
models = Local.list_models()
print(models)  # This should print a list of available AI models

Setting Up API Keys

import os
from cloudcode import Local

# Set environment variable (recommended for security)
os.environ["CLOUDCODE_API_KEY"] = "your_cloudcode_api_key"

# Or pass directly to the SDK
sdk = Local(
    working_dir="/path/to/your/project",
    api_key="your_cloudcode_api_key"
)

Using the cloudcode API key is recommended as it automatically handles provider keys and enables credit tracking.

Option 2: Using Provider API Keys Directly

from cloudcode import Local

sdk = Local(
    working_dir="/path/to/your/project",
    api_key=os.getenv("CLOUD_CODE_API_KEY")
)

Note that this legacy method only supports OpenAI and Anthropic keys.

Next Steps

Once you’ve installed the SDK and set up your API keys, you can:

For more advanced usage, check out the Advanced Usage guide.

Quick Start Example

After installing and setting up your API key, try the included Quick Start script:

python cloud-coding/examples/quick-start.py

This script will:

  • Create src/calculator.py
  • Add multiply and divide functions with zero-division handling
  • Print the diff and updated file content