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!'")
Synchronous Blocking Query (Beta)
from blocks_control_sdk import ClaudeCode
agent = ClaudeCode()
result = agent.query_sync_beta("Write a python script to print 'Hello, World!'", timeout=120)
print(result) # Prints the agent's final message
query_sync_beta(prompt, timeout=None) blocks until the agent completes and returns the final message as a string. Pass an optional timeout in seconds — raises TimeoutError if exceeded, RuntimeError if the agent is interrupted.
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
Metadata
Release files for blocks-control-sdk 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blocks_control_sdk-0.2.2.tar.gz | 143.3 kB | Without provenance | Details for blocks_control_sdk-0.2.2.tar.gz |
Release files / blocks_control_sdk-0.2.2.tar.gz
| Download URL | blocks_control_sdk-0.2.2.tar.gz |
|---|---|
| Size | 143.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a76679b5f721cde161eeea5bbdf68edd8d7ae24b00e92454d4d37dbaa834d1d
|
|
BLAKE2b-256 checksum How to use checksums |
311b40099a4e7bbcf3525eca1f416b6dbfc6da9d3bf1bbf7e6ba8cf1836432c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.11
|
Security for blocks-control-sdk 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.