Skip to main content

BaseAI SDK for Python

Project description

BaseAI Python SDK

Python SDK for the BaseAI platform.

Installation

pip install 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

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

See the full documentation for more examples and API reference.

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-0.1.0.tar.gz (13.0 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-0.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for baseai_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0ada05c08961c1552452aa9e25e57dffbdcf8d8cee564fd3d0ef7bd87152ccd0
MD5 62ac239e74dfef5508f22cc3a66d5832
BLAKE2b-256 afd59ec8e66ab1940732332feeda68240e109d025cc1e7f13a2d61c23273e1c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: baseai_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 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-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e50bc269a3631776a036d998ccbc4524e66cdc46fc356ec56bfb78a7c1a7573
MD5 b65f1fa9fb19467a211c322b0940eeaf
BLAKE2b-256 d6273bbd7ce8a2ca6c7a2ec93a515f56e96032ff3afe8910205b40a9fb1178c0

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