Introduction
The Kortix Python SDK enables you to create, manage, and interact with AI Workers programmatically. Built with modern async/await patterns, the SDK provides a clean and intuitive interface for building AI-powered applications.Key Features
- Async/Await Support: Built from the ground up with asyncio for efficient concurrent operations
- MCP Integration: Connect custom MCP (Model Context Protocol) tools to your agents
- AgentPress Tools: Access built-in tools for files, shell, browser, web search, and more
- Thread Management: Create and manage conversation threads
- Streaming Responses: Stream agent responses in real-time
- Type Safety: Fully typed with dataclasses and type hints
Installation
- pip
- uv
Install directly from the GitHub repository:
Requirements
- Python 3.11 or higher
- Dependencies:
asyncio>=3.4.3httpx>=0.28.1fastmcp>=2.10.6
Quick Start
Here’s a simple example to get you started:Authentication
Get your API key from the Kortix Settings. You can pass your API key directly when initializing the client:Core Concepts
Agents
Agents are AI workers that can use tools to accomplish tasks. Each agent has:- Name: A friendly identifier
- System Prompt: Instructions that define the agent’s behavior
- Tools: MCP tools and AgentPress tools the agent can use
- Model: The underlying AI model (defaults to Claude Sonnet 4)
Threads
Threads represent conversation contexts. They:- Store message history
- Track agent runs
- Can be reused across multiple agent interactions
- Maintain conversation state
Agent Runs
When you execute an agent on a thread, you create an agent run. Runs:- Execute the agent with the current thread context
- Can be streamed for real-time responses
- Track execution status and errors
- Return structured results
Tools
The SDK supports two types of tools:- MCPTools: Custom tools from MCP servers (HTTP or SSE)
- AgentPressTools: Built-in tools for common operations
Basic Workflow
- Initialize the client with your API key
- Create an agent with desired configuration
- Create a thread for the conversation
- Run the agent with a prompt
- Stream or retrieve the response
Error Handling
The SDK uses standard Python exceptions:Next Steps
Python SDK Reference
Complete reference for all SDK classes and methods
Examples
Real-world examples and use cases