The official Python SDK for the Amigo API, providing a simple and intuitive interface to interact with Amigo's AI services.
This SDK requires Python 3.13 or newer.
Install the SDK using pip:
pip install amigo_sdkOr add it to your requirements.txt:
amigo_sdkThis SDK auto-generates its types from the latest Amigo OpenAPI schema. As a result, only the latest published SDK version is guaranteed to match the current API. If you pin to an older version, it may not include the newest endpoints or fields.
from amigo_sdk import AmigoClient
from amigo_sdk.models import GetConversationsParametersQuery
# Initialize and use the client synchronously
with AmigoClient(
api_key="your-api-key",
api_key_id="your-api-key-id",
user_id="user-id",
organization_id="your-organization-id",
) as client:
conversations = client.conversation.get_conversations(
GetConversationsParametersQuery(limit=10, sort_by=["-created_at"])
)
print("Conversations:", conversations)import asyncio
from amigo_sdk import AsyncAmigoClient
from amigo_sdk.models import GetConversationsParametersQuery
async def main():
async with AsyncAmigoClient(
api_key="your-api-key",
api_key_id="your-api-key-id",
user_id="user-id",
organization_id="your-organization-id",
) as client:
conversations = await client.conversation.get_conversations(
GetConversationsParametersQuery(limit=10, sort_by=["-created_at"])
)
print("Conversations:", conversations)
asyncio.run(main())For more SDK usage examples see the examples overview. Direct links:
- Conversation (sync): examples/conversation/conversation.py
- Conversation (async): examples/conversation/conversation_async.py
- User management (sync): examples/user/user-management.py
The SDK requires the following configuration parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
api_key |
str | ✅ | API key from Amigo dashboard |
api_key_id |
str | ✅ | API key ID from Amigo dashboard |
user_id |
str | ✅ | User ID on whose behalf the request is made |
organization_id |
str | ✅ | Your organization ID |
base_url |
str | ❌ | Base URL of the Amigo API (defaults to https://api.amigo.ai) |
You can also configure the SDK using environment variables:
export AMIGO_API_KEY="your-api-key"
export AMIGO_API_KEY_ID="your-api-key-id"
export AMIGO_USER_ID="user-id"
export AMIGO_ORGANIZATION_ID="your-organization-id"
export AMIGO_BASE_URL="https://api.amigo.ai" # optionalThen initialize the client without parameters:
from amigo_sdk import AmigoClient
# Automatically loads from environment variables
with AmigoClient() as client:
...Create a .env file in your project root:
AMIGO_API_KEY=your-api-key
AMIGO_API_KEY_ID=your-api-key-id
AMIGO_USER_ID=user-id
AMIGO_ORG_ID=your-organization-idThe SDK will automatically load these variables.
- API Key & API Key ID: Generate these from your Amigo admin dashboard or programmatically using the API
- Organization ID: Found in your Amigo dashboard URL or organization settings
- User ID: The ID of the user you want to impersonate for API calls
For detailed instructions on generating API keys, see the Authentication Guide.
The SDK provides access to the following resources:
- Organizations: Get Organization info
- Services: Get available services
- Conversation: Manage conversations
- User: Manage users
The SDK ships with Pydantic models generated from the latest OpenAPI schema.
-
Importing types: Import directly from
amigo_sdk.modelsfrom amigo_sdk.models import ( GetConversationsParametersQuery, ConversationCreateConversationRequest, GetUsersParametersQuery, )
-
Using types when calling SDK functions: Pass request/query models to resource methods.
from amigo_sdk import AmigoClient from amigo_sdk.models import GetConversationsParametersQuery with AmigoClient() as client: conversations = client.conversation.get_conversations( GetConversationsParametersQuery(limit=20, sort_by=["-created_at"]) )
-
Parsing returned objects: Responses are Pydantic models. Access fields directly or convert to dict/JSON.
# Access fields first = conversations.conversations[0] print(first.id, first.created_at) # Convert to plain dict for logging/serialization print(first.model_dump(mode="json"))
The SDK provides typed error handling:
from amigo_sdk import AmigoClient
from amigo_sdk.errors import (
AuthenticationError,
NotFoundError,
BadRequestError,
ValidationError,
)
try:
with AmigoClient() as client:
org = client.organization.get()
print("Organization:", org)
except AuthenticationError as error:
print("Authentication failed:", error)
except NotFoundError as error:
print("Resource not found:", error)
except BadRequestError as error:
print("Bad request:", error)
except ValidationError as error:
print("Validation error:", error)
except Exception as error:
print("Unexpected error:", error)The HTTP client includes sensible, configurable retries:
-
Defaults:
- max attempts: 3
- backoff base: 0.25s (exponential with full jitter)
- max delay per attempt: 30s
- retry on status: {408, 429, 500, 502, 503, 504}
- retry on methods: {"GET"}
- special-case: POST is retried on 429 when
Retry-Afteris present - 401 triggers a one-time token refresh and immediate retry
For detailed development setup, testing, and contribution guidelines, see CONTRIBUTING.md.
- Developer Guide: https://docs.amigo.ai/developer-guide
- API Reference: https://docs.amigo.ai/api-reference
This project is licensed under the MIT License - see the LICENSE file for details.
For questions, issues, or feature requests, please visit our GitHub repository or contact support through the Amigo dashboard.