Python SDK
The Vyre Python SDK lets you integrate Vyre's agentic coding capabilities into your Python workflows, CI/CD scripts, automated test suits, and AI data engineering pipelines.
Installation
Install the package via pip or poetry:
bash
# pip
pip install vyre-sdk
# poetry
poetry add vyre-sdkInitialization
Initialize the SDK by providing your API key. By default, the SDK looks for the VYRE_API_KEY environment variable.
python
from vyre import VyreClient
import os
# Explicit key or automatically loaded from environment
client = VyreClient(api_key=os.getenv("VYRE_API_KEY"))Basic Usage
Running an Autonomous Agent Task
You can spawn local or cloud agent sessions to complete complex tasks, watch the step execution, and read file diffs.
python
import time
from vyre import VyreClient
client = VyreClient()
def run_task():
session = client.sessions.create(
project_path="/home/user/workspace/app",
task="Identify all print statements and replace them with standard Python logging.",
model="claude-sonnet-4-5",
cloud=True
)
print(f"Session started: {session.id}")
# Watch and print agent stream
for event in session.stream_events():
if event["type"] == "text":
print(event["delta"], end="", flush=True)
elif event["type"] == "tool_call":
print(f"\n[Running: {event['tool_name']}]")
elif event["type"] == "completed":
print("\nAgent run completed successfully!")
if __name__ == "__main__":
run_task()Advanced Features
Syncing Repositories in Scripts
Keep your remote repository state current inside automation pipelines before kicking off cloud runs.
python
repo = client.repositories.sync(
path="/home/user/workspace/app",
branch="feature/update-logging"
)
print(f"Synced revision: {repo.commit_sha}")Handling Tool Execution Callbacks
You can inspect tool executions, intercept file writes, and inject approval logic directly in Python:
python
@client.on_tool_call
def verify_action(tool_name, arguments):
if tool_name == "run_command" and "rm" in arguments.get("command", ""):
return False # Reject tool call
return True # Approve tool callAsynchronous client (asyncio)
The Python SDK fully supports asynchronous execution natively:
python
from vyre import AsyncVyreClient
async_client = AsyncVyreClient()
# Use await async_client.sessions.create(...)