Skip to main content

Qodo Python SDK for AI-powered agents

Project description

Qodo Python SDK

PyPI version Python versions License: MIT

Python SDK for building and running AI-powered agents on the Qodo platform. The async-first Python counterpart to @qodo/sdk.

Installation

# Using uv (recommended)
uv add qodo-sdk

# Using pip
pip install qodo-sdk

# With OpenTelemetry tracing support
uv add "qodo-sdk[tracing]"

Requirements

  • Python 3.10+
  • A Qodo API key (set as QODO_API_KEY environment variable or in ~/.qodo/auth.key)

Quick Start

import asyncio
from qodo import QodoSDK, SdkEventType

async def main():
    async with QodoSDK(project_path="/path/to/project") as sdk:
        # Blocking run
        result = await sdk.prompt("Hello, world!")
        print(f"Output: {result.result.get('final_output')}")

        # Streaming
        async for event in sdk.stream_prompt("Write a greeting"):
            if event.type == SdkEventType.MESSAGE_DELTA:
                print(event.data.delta, end="", flush=True)
            elif event.type == SdkEventType.FINAL:
                print(f"\nDone! Success: {event.data.success}")

asyncio.run(main())

Custom Agents

Define agents with Pydantic models for type-safe structured output:

from pydantic import BaseModel, Field
from qodo import QodoSDK, sdk_agent, sdk_command

class ReviewOutput(BaseModel):
    issues: list[str] = Field(description="List of found issues")
    score: float = Field(description="Code quality score 0-10")
    summary: str = Field(description="Brief review summary")

agent = sdk_agent(
    instructions="You are a code reviewer.",
    commands={
        "review": sdk_command(
            name="review",
            description="Review code files",
            output=ReviewOutput,
            available_tools=["filesystem", "git"],
        )
    }
)

async with QodoSDK.from_agent(agent, project_path=".") as sdk:
    result = await sdk.run("review", args={"files": ["src/main.py"]})
    output = result.result.get("structured_output")
    print(f"Score: {output['score']}")

Pipelines

Build multi-step workflows with the pipeline DSL:

from qodo import QodoSDK, sdk_pipeline, run_pipeline

pipeline = (
    sdk_pipeline("code-review")
    .step("analyze", analyze_code)
    .step("report", generate_report)
    .build()
)

async with QodoSDK(project_path=".") as sdk:
    result = await run_pipeline(sdk, pipeline, {"repo": "."})

Tool Approval Policies

Control tool execution with declarative policies:

from qodo import QodoSDK, sdk_policy

policy = (
    sdk_policy()
    .approve("filesystem.*")       # Auto-approve filesystem reads
    .deny("shell.rm*")             # Block destructive commands
    .require_human("git.push*")    # Require human approval for pushes
    .build()
)

sdk = QodoSDK(project_path=".", tool_approval=policy.evaluate)

Features

Feature Description
Async-first Built on asyncio with async with context manager
Streaming Real-time event streaming with delta support
Structured Output Pydantic v2 model validation for agent responses
Pipelines Multi-step workflows with parallel execution
Tool Middleware Pre/post hooks for tool call interception
Policies Declarative tool approval with glob matching
Artifacts Typed storage for pipeline intermediate results
Tracing OpenTelemetry integration (optional [tracing] extra)
Type Safety Full py.typed support with strict mypy
Environment Isolation Multiple SDK instances via contextvars

More Examples

See the examples/ directory for 14 runnable scripts covering all SDK features.

Development

# Install dev dependencies
uv pip install -e ".[dev]"

# Run tests
uv run pytest

# Lint & format
uv run ruff check src/qodo
uv run ruff format src/qodo

# Type check
uv run mypy src/qodo

See CONTRIBUTING.md for the full development guide.

License

MIT

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

qodo_sdk-0.1.0.tar.gz (145.7 kB view details)

Uploaded Source

Built Distribution

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

qodo_sdk-0.1.0-py3-none-any.whl (134.2 kB view details)

Uploaded Python 3

File details

Details for the file qodo_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: qodo_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 145.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qodo_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d4eb4d47edccf93834a6e96b067508aa69e860d0a656410bb5eb5a95e8bf7e53
MD5 27b585dbc17b0c7b661bce20ad3349c1
BLAKE2b-256 9a3e06818acef858ea70b52a4752e2c90a13b7a779649c472769b9a83918c483

See more details on using hashes here.

Provenance

The following attestation bundles were made for qodo_sdk-0.1.0.tar.gz:

Publisher: publish.yml on qodo-ai/qodo-py-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qodo_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qodo_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 134.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qodo_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6a2d1df1bf556f754a9a1da3fb0c4bf273123dcdc9e727bf99e86cb6e128276
MD5 badb58b235dc8fc2d851d3be80cf534e
BLAKE2b-256 ffc9346ca8dc189ec78c9eab2ea3bb65d2c4ccd2efcc80a5ef8b9e9b93a8845c

See more details on using hashes here.

Provenance

The following attestation bundles were made for qodo_sdk-0.1.0-py3-none-any.whl:

Publisher: publish.yml on qodo-ai/qodo-py-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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