API Reference

Providers

Prebuilt clients for LLM providers

Anthropic

AnthropicClient

Client interface for interacting with Anthropic API

AsyncAnthropicClient

Async client interface for interacting with Anthropic API

OpenAI

OpenAIClient

Client interface for interacting with OpenAI API

AsyncOpenAIClient

Async client interface for interacting with OpenAI API

Ollama

OllamaClient

Interface for using Ollama API

AsyncOllamaClient

Async interface for using Ollama API

InvalidOllamaServerError

Failed to connect to Ollama server

Core

Core components for creating client interfaces and model chats

Conversation

Building blocks for creating prompts to LLMs

ConversationBuilder

Conversation builder to ensure messages are in a valid order

Conversation

Immutable conversation for LLM

Message

DTO for LLM messages

Role

Roles for LLM conversation

Base Clients

Base clients for LLM clients

ModelClient

Abstract base class for synchronous model clients

AsyncModelClient

Abstract base class for asynchronous model clients

load_api_key

Load API key from env variable

InvalidAPIKeyError

Failed to validate LLM API key

ModelNotFoundError

Requested model not found

Retry Handlers

Automatic response validation and reprompting

RetryHandler

Retry handler to validate LLM responses

AsyncRetryHandler

Async retry handler to validate LLM responses

JSONRetryHandler

Handler for parsing JSON from LLM responses

AsyncJSONRetryHandler

Async handler for parsing JSON from LLM responses

ExceededRetriesError

Exceed the number of retries