Client SDK for the PydanticAI Multi-Agent Platform
Project description
PydanticAI Platform Client
A lightweight Python client for the PydanticAI Multi-Agent Platform API.
Installation
pip install pydanticai-platform-client
Or install from source:
pip install -e sdk/
Quick Start
from pydanticai_platform_client import PlatformClient
async def main():
async with PlatformClient(
base_url="https://your-platform.fly.dev",
api_key="pk_your_tenant_key",
) as client:
# Chat with the default agent
response = await client.chat("What's the weather like?")
print(response.text)
# Use a specific agent
response = await client.chat(
"Analyze this data: [1, 2, 3, 4, 5]",
agent="analyst",
)
print(response.text)
# Continue a conversation
response = await client.chat(
"Tell me more",
conversation_id=response.conversation_id,
)
Streaming Responses
async with PlatformClient(base_url, api_key) as client:
async for chunk in client.chat_stream("Write a poem about Python"):
print(chunk, end="", flush=True)
print() # newline at the end
Available Methods
| Method | Description |
|---|---|
chat(prompt, agent?, conversation_id?) |
Send a message, get complete response |
chat_stream(prompt, agent?, conversation_id?) |
Stream response chunks |
list_agents() |
List available agents |
get_usage(days=30) |
Get usage statistics |
list_conversations(limit=20) |
List recent conversations |
get_conversation(id) |
Get full conversation history |
clear_conversation(id) |
Delete a conversation |
Error Handling
from pydanticai_platform_client import (
PlatformClient,
AuthenticationError,
RateLimitError,
TokenLimitError,
AgentNotFoundError,
)
async with PlatformClient(base_url, api_key) as client:
try:
response = await client.chat("Hello")
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited, retry after {e.retry_after}s")
except TokenLimitError as e:
print(f"Token limit exceeded: {e.tokens_used}/{e.limit}")
except AgentNotFoundError as e:
print(f"Agent not found: {e.agent_name}")
Response Models
ChatResponse
@dataclass
class ChatResponse:
text: str # The agent's response
conversation_id: str # ID for continuing the conversation
agent: str # Agent that handled the request
model: str # Model used
UsageStats
@dataclass
class UsageStats:
tenant_id: str
period_days: int
total_requests: int
total_tokens: int
estimated_cost_usd: float
by_model: dict[str, int]
by_agent: dict[str, int]
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydanticai_platform_client-0.1.0.tar.gz.
File metadata
- Download URL: pydanticai_platform_client-0.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7201ae3115d8a21d3d2229b705000c356e55060c1af037bc60386cdc753a13c7
|
|
| MD5 |
bd4eefdbab13599c30c8def57b26f1ae
|
|
| BLAKE2b-256 |
318c5356da233b1e7c7b1a507d998696a64320561e04c5dea8c6dca8d022d5dd
|
File details
Details for the file pydanticai_platform_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pydanticai_platform_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2865f8153bce1edff581dc54b1b3ee91dccf7fe51b380606525b419463ce1540
|
|
| MD5 |
f78a0a0f5b1f7760dfdd201989f9aa45
|
|
| BLAKE2b-256 |
14202a8b03d3d0b13c63dc0097407e9bc2e79f300757d64115f89e9a6a33d80a
|