Skip to main content
The Codegen SDK is a thin pythonic wrapper around the Codegen API with all the same capabilities for creating and managing AI agents programmatically.
Go to developer settings to generate an API token
from codegen import Agent

# Initialize the Agent with your organization ID and API token
agent = Agent(org_id="...", token="...")

# Run an agent with a prompt
task = agent.run(prompt="Leave a review on PR #123")

# Check the initial status
print(task.status)

# Refresh the task to get updated status (tasks can take time)
task.refresh()

if task.status == "completed":
    print(task.result)  # Result often contains code, summaries, or links

Installation

Install the codegen package from PyPI using your preferred package manager:
# Using pip
pip install codegen

# Using pipx (for CLI usage)
pipx install codegen

# Using uv
uv pip install codegen
# or
uv tool install codegen

Keeping Up to Date

The CLI includes a built-in self-update system that checks for updates daily:
# Update to latest version
codegen update

# Check for updates
codegen update --check

Get Started

I