AIgents Python Client
Official Python client library for the AIgents AI platform.
Installation
pip install aigents-sdk
Quick Start
from aigents import AIgentsClient
# Initialize the client with your API key
client = AIgentsClient(
api_key="aig_your_api_key_here",
base_url="http://localhost:8000" # or your AIgents server URL
)
# List your applications
apps = client.applications.list()
print(f"Found {len(apps)} applications")
# Get a specific application
app = client.applications.get("app_id")
print(f"Application: {app.name}")
# List agents in an application
agents = client.applications.agents.list("app_id")
print(f"Found {len(agents)} agents")
# Start a chat session
session = client.chat.create_session("app_id", agent_id="agent_id")
print(f"Created session: {session.id}")
# Send a message
response = client.chat.send_message(
session_id=session.id,
content="Hello, how can you help me today?"
)
print(f"Assistant: {response.content}")
Advanced Usage
Tool Calls and MCP Approval
# Send a message that might trigger tool calls
response = client.chat.send_message(
session_id=session.id,
content="What's the weather like in San Francisco?",
tools=[{"type": "weather_api"}]
)
# Handle tool calls
if response.tool_calls:
for tool_call in response.tool_calls:
print(f"Tool call: {tool_call.name}")
print(f"Arguments: {tool_call.arguments}")
# Handle MCP approval requests
if response.requires_mcp_approval:
print(f"MCP approval required: {response.mcp_approval_request_id}")
# Approve the MCP request
approved_response = client.chat.approve_mcp_request(
request_id=response.mcp_approval_request_id,
approved=True
)
Working with Datasets
# List datasets
datasets = client.applications.datasets.list("app_id")
# Add data to a dataset
client.applications.datasets.add_data(
app_id="app_id",
dataset_id="dataset_id",
data=[
{
"input": "What is machine learning?",
"output": "Machine learning is a subset of AI...",
"metadata": {"category": "education"}
}
]
)
Error Handling
from aigents.exceptions import AIgentsError, AuthenticationError, RateLimitError
try:
response = client.chat.send_message(session_id, "Hello")
except AuthenticationError:
print("Invalid API key")
except RateLimitError:
print("Rate limit exceeded")
except AIgentsError as e:
print(f"API error: {e}")
Configuration
The client can be configured with environment variables:
export AIGENTS_API_KEY="aig_your_api_key_here"
export AIGENTS_BASE_URL="https://api.aigents.co"
# Client will automatically use environment variables
client = AIgentsClient()
API Reference
Client
AIgentsClient(api_key, base_url, timeout)
Applications
client.applications.list()- List all applicationsclient.applications.get(app_id)- Get application detailsclient.applications.create(name, description)- Create new applicationclient.applications.update(app_id, **kwargs)- Update applicationclient.applications.delete(app_id)- Delete application
Agents
client.applications.agents.list(app_id)- List agentsclient.applications.agents.get(app_id, agent_id)- Get agent detailsclient.applications.agents.create(app_id, **kwargs)- Create agentclient.applications.agents.update(app_id, agent_id, **kwargs)- Update agentclient.applications.agents.delete(app_id, agent_id)- Delete agent
Chat
client.chat.create_session(app_id, **kwargs)- Create chat sessionclient.chat.send_message(session_id, content, **kwargs)- Send messageclient.chat.get_history(session_id)- Get chat historyclient.chat.approve_mcp_request(request_id, approved)- Approve MCP request
Tools & MCPs
client.applications.tools.list(app_id)- List toolsclient.applications.mcps.list(app_id)- List MCPs
Datasets
client.applications.datasets.list(app_id)- List datasetsclient.applications.datasets.get(app_id, dataset_id)- Get datasetclient.applications.datasets.add_data(app_id, dataset_id, data)- Add data
Contributing
- Clone the repository
- Install development dependencies:
pip install -e .[dev] - Run tests:
pytest - Format code:
black aigents/ - Type check:
mypy aigents/
License
MIT License - see LICENSE file for details.
Metadata
Release files for aigents-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aigents_sdk-0.1.0.tar.gz | 11.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aigents_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.9 kB
Release files / aigents_sdk-0.1.0.tar.gz
| Download URL | aigents_sdk-0.1.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
920646981978ff0a6f65b3cebf95d91846c8742464da04efe7f2e984fc896a82
|
|
BLAKE2b-256 checksum How to use checksums |
de2ace59b73d9e9a6a40d54bca8ada26ae566c3dc1d966884cd31b412fc45908
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Release files / aigents_sdk-0.1.0-py3-none-any.whl
| Download URL | aigents_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
99d53e662bd8ecc8c4fbbe463389a3c1ca73c5e7fe5f0707be61222064f43c89
|
|
BLAKE2b-256 checksum How to use checksums |
c34a951aa9c55b709b6c9dbe3bc544b72c5df1e190b17ac2ce7e34e12b300c98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Security for aigents-sdk 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.