Skip to main content

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

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 BaseAITool enum 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

  1. Go to Google Colab
  2. Click "File" → "Open notebook"
  3. Select the "GitHub" tab
  4. Enter: A2ABaseAI/sdks
  5. Navigate to python/example/quick_start.ipynb or any .py file

Option 2: Manual Setup

  1. Open Google Colab
  2. Create a new notebook
  3. Copy the code from any example file
  4. Adapt it for notebook use (remove if __name__ == "__main__" and use await directly)

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

💬 Support

Need help? Join our Discord community for support and discussions:

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)

Source distribution for baseai-sdk 1.0.1
File Size Uploaded
baseai_sdk-1.0.1.tar.gz 14.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for baseai-sdk 1.0.1
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page