Skip to main content

Kortix Client

The main entry point for the SDK.

Kortix

string
required
Your Kortix API key from settings/api-keys
string
default:"https://api.kortix.com/v1"
The API base URL. Override for local development or custom deployments.
Properties:
  • client.Agent: Agent management interface
  • client.Thread: Thread management interface

Agent Management

Create and manage AI agents.

Agent.create()

Create a new agent with specified configuration.
string
required
A friendly name for the agent
string
required
Instructions that define the agent’s behavior and personality
list[KortixTools]
default:"[]"
List of tools (MCPTools or AgentPressTools) the agent can use
list[str] | None
default:"None"
Specific tool names to enable. If None, all tools are enabled.
Returns: Agent instance Example:

Agent.get()

Retrieve an existing agent by ID.
string
required
The unique identifier of the agent
Returns: Agent instance Example:

Agent Instance

An Agent instance provides methods to interact with a specific agent.

agent.run()

Execute the agent with a prompt on a thread.
string
required
The user message/prompt to send to the agent
Thread
required
The thread context for the conversation
string
default:"anthropic/claude-sonnet-4-20250514"
Override the model for this specific run
Returns: AgentRun instance Example:

agent.update()

Update agent configuration.
string
New name for the agent
string
New system prompt
list[KortixTools]
New list of tools
list[str]
New list of allowed tool names
Example:

agent.details()

Get detailed information about the agent.
Returns: AgentResponse with complete agent configuration

Thread Management

Create and manage conversation threads.

Thread.create()

Create a new conversation thread.
string
Optional name for the thread/project
Returns: Thread instance Example:

Thread.get()

Retrieve an existing thread by ID.
string
required
The unique identifier of the thread
Returns: Thread instance

Thread.delete()

Delete a thread.
string
required
The unique identifier of the thread to delete

Thread Instance

A Thread instance provides methods to interact with a specific thread.

thread.add_message()

Add a message to the thread.
string
required
The message content to add
Returns: Message ID (string) Example:

thread.del_message()

Delete a message from the thread.
string
required
The ID of the message to delete

thread.get_messages()

Retrieve all messages in the thread.
Returns: List of Message objects Example:

thread.get_agent_runs()

Get all agent runs for this thread.
Returns: List of AgentRun objects or None if no runs exist

Agent Run

Represents an execution of an agent.

run.get_stream()

Get a stream of the agent’s response.
Returns: Async generator yielding response chunks Example:

Tools

MCPTools

Connect to custom MCP (Model Context Protocol) servers.
string
required
The HTTP URL of the MCP server (e.g., “http://localhost:4000/mcp/”)
string
required
A friendly name for this MCP server
list[str]
Specific tool names to enable from this server
Properties:
  • url: The MCP server endpoint
  • name: The server name
  • type: Always “http”
  • enabled_tools: List of enabled tool names
Example:

AgentPressTools

Built-in tools provided by Kortix.
Example:

Data Models

Message

Represents a message in a thread. Properties:
  • message_id (str): Unique message identifier
  • thread_id (str): Parent thread ID
  • type (MessageType): Type of message (user, assistant, tool, status)
  • is_llm_message (bool): Whether this is an LLM-generated message
  • content (Any): Message content (varies by type)
  • created_at (str): Creation timestamp
  • updated_at (str): Last update timestamp
  • metadata (Any): Additional metadata
Methods:
  • message.is_user_message (bool): Check if user message
  • message.is_assistant_message (bool): Check if assistant message
  • message.get_content_as_string() (str): Get content as string

MessageType

Enum of message types:
  • MessageType.USER: User message
  • MessageType.ASSISTANT: Assistant message
  • MessageType.TOOL: Tool result
  • MessageType.STATUS: Status update
  • MessageType.ASSISTANT_RESPONSE_END: End of assistant response

Role

Enum of message roles:
  • Role.USER: User role
  • Role.ASSISTANT: Assistant role
  • Role.SYSTEM: System role

Utilities

Utility function to print agent response streams with formatting.
This utility provides:
  • Colored output for different event types
  • Tool usage detection and display
  • XML formatting for structured content
  • Progress indicators

Type Hints

The SDK uses Union types for flexibility:
This allows passing either built-in AgentPress tools or custom MCP tools to agent creation methods.

Async Context Managers

For proper resource cleanup, you can use async context managers: