The Codegen SDK enables developers to programmatically interact with Codegen SWE agents via API.

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

Codegen agents can research code, create PRs, modify Linear tickets, and more.

Installation

Install the SDK using pip or uv:

pip install codegen
# or
uv pip install codegen

What can I do with the Codegen SDK?

The Codegen SDK is your gateway to programmatically interacting with your AI Software Engineer. You can use it to:

  • Automate development tasks: Assign tasks like implementing features, fixing bugs, writing tests, or improving documentation to the agent.
  • Integrate AI into your workflows: Trigger agent tasks from your CI/CD pipelines, scripts, or other development tools.
  • Provide context and guidance: Supply the agent with specific instructions, relevant code snippets, or background information to ensure it performs tasks according to your requirements.

Essentially, the SDK allows you to leverage Codegen’s AI capabilities wherever you can run Python code.

Get Started

Was this page helpful?