BaseAI Python SDK
Python SDK for the BaseAI platform.
Installation
pip install baseai-sdk
📦 Published on PyPI: https://pypi.org/project/baseai-sdk/
Or install directly from GitHub:
pip install git+https://github.com/A2ABaseAI/sdks.git#subdirectory=python
Requirements
- Python 3.8+
- See requirements.txt for dependencies
Quick Start
import asyncio
import os
from baseai import BaseAI
from baseai.tools import BaseAITool
async def main():
api_key = os.getenv("BASEAI_API_KEY")
if not api_key:
raise ValueError("Please set BASEAI_API_KEY environment variable")
client = BaseAI(api_key=api_key, api_url="https://a2abase.ai/api")
thread = await client.Thread.create()
agent = await client.Agent.create(
name="My Assistant",
system_prompt="You are a helpful AI assistant.",
mcp_tools=[BaseAITool.WEB_SEARCH_TOOL],
)
run = await agent.run("Hello, how are you?", thread)
stream = await run.get_stream()
async for chunk in stream:
print(chunk, end="")
asyncio.run(main())
Getting Your API Key
Get your API key from https://a2abase.ai/settings/api-keys
Set it as an environment variable:
export BASEAI_API_KEY="pk_xxx:sk_xxx"
Examples
Comprehensive examples are available in the example/ directory, demonstrating:
- Tool-Specific Examples: Each tool from
BaseAIToolenum with practical use cases - Common Use Cases: Real-world scenarios like research, content creation, automation, and more
See the examples README for a complete list of available examples.
Running Examples
# Set your API key
export BASEAI_API_KEY="pk_xxx:sk_xxx"
# Run an example
cd python
PYTHONPATH=. python3 example/customer_support_triage.py
Running All Examples
cd python
PYTHONPATH=. python3 example/run_all_examples.py
Running Examples in Google Colab
To run examples in Google Colab:
Option 1: Open from GitHub
- Go to Google Colab
- Click "File" → "Open notebook"
- Select the "GitHub" tab
- Enter:
A2ABaseAI/sdks - Navigate to
python/example/quick_start.ipynbor any.pyfile
Option 2: Manual Setup
- Open Google Colab
- Create a new notebook
- Copy the code from any example file
- Adapt it for notebook use (remove
if __name__ == "__main__"and useawaitdirectly)
Quick Start in Colab:
# Install the SDK
!pip install baseai-sdk
import os
from baseai import BaseAI
from baseai.tools import BaseAITool
# Set your API key (use Colab's secrets or environment variables)
os.environ['BASEAI_API_KEY'] = 'pk_xxx:sk_xxx'
# Create client
client = BaseAI(api_key=os.getenv("BASEAI_API_KEY"), api_url="https://a2abase.ai/api")
# Create thread and agent
thread = await client.Thread.create()
agent = await client.Agent.create(
name="My Assistant",
system_prompt="You are a helpful AI assistant.",
mcp_tools=[BaseAITool.WEB_SEARCH_TOOL],
)
# Run the agent
run = await agent.run("Hello, how are you?", thread)
stream = await run.get_stream()
# Stream and display results
async for chunk in stream:
print(chunk, end="")
Note: In Google Colab, you can use await directly in cells without asyncio.run().
Available Tools
The SDK provides access to various tools through the BaseAITool enum:
- File Management:
FILES_TOOL,UPLOAD_FILE_TOOL - Development:
SHELL_TOOL,WEB_DEV_TOOL,DEPLOY_TOOL,EXPOSE_TOOL - Image Tools:
VISION_TOOL,IMAGE_SEARCH_TOOL,IMAGE_EDIT_TOOL - Content Creation:
DOCS_TOOL,SHEETS_TOOL,PRESENTATION_TOOL,PRESENTATION_OUTLINE_TOOL,DESIGN_TOOL - Knowledge & Data:
KB_TOOL,DATA_PROVIDERS_TOOL - Search & Browser:
WEB_SEARCH_TOOL,BROWSER_TOOL
Usage
Creating an Agent
from baseai import BaseAI
from baseai.tools import BaseAITool
client = BaseAI(api_key="your-api-key", api_url="https://a2abase.ai/api")
# Create an agent with tools
agent = await client.Agent.create(
name="My Agent",
system_prompt="You are a helpful assistant.",
mcp_tools=[BaseAITool.WEB_SEARCH_TOOL, BaseAITool.FILES_TOOL],
)
Running an Agent
# Create a thread
thread = await client.Thread.create()
# Run the agent
run = await agent.run("Your task here", thread)
# Stream the response
stream = await run.get_stream()
async for chunk in stream:
print(chunk, end="")
Finding an Existing Agent
# Find agent by name
agent = await client.Agent.find_by_name("My Agent")
if agent:
# Use the existing agent
pass
Documentation
- PyPI Package: https://pypi.org/project/baseai-sdk/
- GitHub Repository: https://github.com/A2ABaseAI/sdks
- Full Documentation: See the repository for more examples and API reference.
💬 Support
Need help? Join our Discord community for support and discussions:
- Discord: https://discord.gg/qAncfHmYUm
License
MIT License - see LICENSE file for details.
Metadata
Release files for baseai-sdk 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| baseai_sdk-1.0.1.tar.gz | 14.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| baseai_sdk-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.7 kB
Release files / baseai_sdk-1.0.1.tar.gz
| Download URL | baseai_sdk-1.0.1.tar.gz |
|---|---|
| Size | 14.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61a34b60433ec2886acd9448676ed603691dc898084c551de6a9a6284ec8f9b9
|
|
BLAKE2b-256 checksum How to use checksums |
236d90c0ac464555e4b737e6296f08726d51d21e66d4e774b7821efa416bb0b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / baseai_sdk-1.0.1-py3-none-any.whl
| Download URL | baseai_sdk-1.0.1-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5329d1d1ce0b32c4adf33c29b87ce8c300c5512a1db48f4a064d6cb7e0febb5
|
|
BLAKE2b-256 checksum How to use checksums |
86cef2c0ccda766db3d0b95dbe702d37bfa3391870492e2c96045a1758e5336e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|