Skip to main content

A unified Python interface to interact with popular coding agents.

Project description

Blocks Control SDK

A unified Python interface to interact with popular coding agents.

Think of it like litellm, but for coding agents

Supported Agents

  • Claude Code - Anthropic's Claude
  • Gemini CLI - Google's Gemini
  • Codex CLI - OpenAI's Codex
  • Cursor CLI - Cursor's AI agent
  • OpenCode - OpenCode CLI agent
  • Kimi CLI - Kimi's AI agent

Installation

pip install blocks-control-sdk

You must also have the dependent agent packages installed to use a specific agent.

npm i -g @anthropic-ai/claude-code   # For Claude Code
npm i -g @google/gemini-cli           # For Gemini CLI
npm i -g @openai/codex-cli            # For Codex CLI
npm i -g @anthropic-ai/cursor-cli     # For Cursor CLI (if applicable)

Usage

Async Streaming

import asyncio
from blocks_control_sdk import ClaudeCode


async def main():
    agent = ClaudeCode()
    async for message in agent.stream("Write a python script to print 'Hello, World!'"):
        if isinstance(message, tuple):
            tool_name, args = message
            print(f"Tool call: {tool_name} with args {args}")
        else:
            print(message.content)

if __name__ == "__main__":
    asyncio.run(main())

Sync with Callbacks

from blocks_control_sdk import Codex

agent = Codex()

def on_message(notification):
    print(notification.message.content)

agent.register_notification(agent.notifications.NOTIFY_MESSAGE_V2, on_message)

agent.query("Write a python script to print 'Hello, World!'")

All Agents

from blocks_control_sdk import ClaudeCode, Codex, GeminiCLI, CursorCLI, OpenCode, KimiCLI

# Claude
claude = ClaudeCode()

# Gemini
gemini = GeminiCLI()

# Codex
codex = Codex()

# Cursor
cursor = CursorCLI()

# OpenCode
opencode = OpenCode()

# Kimi
kimi = KimiCLI()

Environment Variables

export ANTHROPIC_API_KEY="your-key"  # For Claude
export GEMINI_API_KEY="your-key"     # For Gemini
export OPENAI_API_KEY="your-key"     # For Codex
export CURSOR_API_KEY="your-key"     # For Cursor

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blocks_control_sdk-0.2.0rc2.tar.gz (130.9 kB view details)

Uploaded Source

File details

Details for the file blocks_control_sdk-0.2.0rc2.tar.gz.

File metadata

  • Download URL: blocks_control_sdk-0.2.0rc2.tar.gz
  • Upload date:
  • Size: 130.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for blocks_control_sdk-0.2.0rc2.tar.gz
Algorithm Hash digest
SHA256 9327d06fb7e52aad1587ef0d7e5c7479f5c52703aa6829e96b08708bf4072476
MD5 8a250e58fe6c9b1c174b816b92e757a3
BLAKE2b-256 d6e52549c99cb49f23addbf919d00ec7f94a4bc96d1d3897d1b73a61aa0c6508

See more details on using hashes here.

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