Skip to main content

baalebos-ai

Official Python client and terminal CLI for the Baalebos AI Gateway — a single endpoint that routes across 9 free-tier LLM providers with automatic failover.

Install

cd clients/python
pip install -e .

This installs the baalebos-ai package and registers the ai terminal command.

Configuration

The client needs two values: the gateway URL and your API key. Set them as environment variables so you never have to hardcode secrets in code:

export BAALEBOS_API_URL="https://gateway.baalebo.xyz/webhook/baalebos-ai"
export BAALEBOS_API_KEY="your-gateway-key"

Add those two lines to ~/.bashrc (or ~/.zshrc) and run source ~/.bashrc so they persist across terminal sessions.

Alternatively, pass them directly when creating a client — useful for scripts that manage multiple keys or don't want to rely on the environment:

client = BaalebosAI(api_url="...", api_key="...")

Terminal CLI

Once installed, call the gateway directly from any terminal:

ai "Explain Kubernetes architecture in 2 simple sentences"

Optional flags:

ai "Summarize this" --mode fast

Python usage — synchronous

from baalebos_ai import BaalebosAI

client = BaalebosAI()  # reads BAALEBOS_API_URL / BAALEBOS_API_KEY from the environment
response = client.chat("What is the capital of Nigeria?")
print(response)

Python usage — asynchronous

For async codebases (FastAPI, asyncio scripts), use AsyncBaalebosAI instead — same methods, same behavior, just non-blocking:

import asyncio
from baalebos_ai import AsyncBaalebosAI

async def main():
    client = AsyncBaalebosAI()
    response = await client.chat("What is the capital of Nigeria?")
    print(response)

asyncio.run(main())

Error handling

The SDK raises specific, catchable exception types instead of generic errors, so calling code can handle each failure differently:

Exception Raised when
BaalebosConfigError BAALEBOS_API_URL or BAALEBOS_API_KEY is missing
BaalebosAuthError the gateway rejected the API key (401)
BaalebosConnectionError the request timed out or couldn't reach the gateway
BaalebosAPIError the gateway returned any other error status

All of them inherit from BaalebosError, so you can catch that alone if you just want to handle "something went wrong" generically:

from baalebos_ai import BaalebosAI, BaalebosAuthError, BaalebosError

client = BaalebosAI()
try:
    print(client.chat("Hello"))
except BaalebosAuthError:
    print("Your API key looks wrong — check BAALEBOS_API_KEY.")
except BaalebosError as e:
    print(f"Something else went wrong: {e}")

chat() parameters

Parameter Default Description
prompt — the text to send to the gateway
mode "auto" routing mode: "auto", "fast", or "smart"
temperature 0.7 sampling temperature passed through to the underlying model

Package structure

clients/python/
├── setup.py
└── baalebos_ai/
    ├── __init__.py
    ├── client.py       # BaalebosAI (sync) and AsyncBaalebosAI
    ├── cli.py           # `ai` command entrypoint
    └── exceptions.py    # custom error types

Metadata

Release files for baalebos-ai 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 baalebos-ai 1.0.1
File Size Uploaded Provenance
baalebos_ai-1.0.1.tar.gz 4.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for baalebos-ai 1.0.1
File Interpreter ABI Platform
baalebos_ai-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.8 kB

Release files / baalebos_ai-1.0.1.tar.gz

Download URL baalebos_ai-1.0.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ee178a789cd7ba0f9bff986e75a2a345824367ae3a8bcbe59d8135ccefc5eff1
BLAKE2b-256 checksum
How to use checksums
b20f0816d91faae5a3964d01f61b973a788078acde01bc87859c3dfb6b0cce50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / baalebos_ai-1.0.1-py3-none-any.whl

Download URL baalebos_ai-1.0.1-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7bad8806db65a41ca263d43cd096fb9364b97646f89d236ce271a258ec7b36b
BLAKE2b-256 checksum
How to use checksums
dd88efdae20a9ab0c020ff57b239acfad4c4bd4c78ac43978bf0d1f87703f876
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for baalebos-ai 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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