Skip to main content

BaseAI SDK for Python

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baseai_sdk-1.0.1.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

baseai_sdk-1.0.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file baseai_sdk-1.0.1.tar.gz.

File metadata

  • Download URL: baseai_sdk-1.0.1.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for baseai_sdk-1.0.1.tar.gz
Algorithm Hash digest
SHA256 61a34b60433ec2886acd9448676ed603691dc898084c551de6a9a6284ec8f9b9
MD5 c82c7a0b23c87b0f0ffb781e51f57ba0
BLAKE2b-256 236d90c0ac464555e4b737e6296f08726d51d21e66d4e774b7821efa416bb0b1

See more details on using hashes here.

File details

Details for the file baseai_sdk-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: baseai_sdk-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for baseai_sdk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5329d1d1ce0b32c4adf33c29b87ce8c300c5512a1db48f4a064d6cb7e0febb5
MD5 9cc3fbc7305b06862ede604f7c0c9b03
BLAKE2b-256 86cef2c0ccda766db3d0b95dbe702d37bfa3391870492e2c96045a1758e5336e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page