Skip to main content
Boole AI works with the official OpenAI Python SDK. Install it once, point it at Boole, and every pattern you already use — synchronous calls, async coroutines, streaming, tool calls — works without any further changes. There is no Boole-specific library to learn.

Installation

Store your API key in an environment variable — never hardcode it in source files. Set BOOLE_API_KEY in your shell profile or a .env file and load it with os.environ or a library like python-dotenv.

Basic Chat Completion

Create a client pointing at the Boole Cloud API and call chat.completions.create exactly as you would with OpenAI.
example.py

Streaming

Set stream=True to receive tokens as they are generated. Use the context-manager form to ensure the connection closes cleanly when you’re done reading.
streaming.py

Async Usage

Use AsyncOpenAI in async applications — FastAPI handlers, async pipelines, or any asyncio-based code. The interface is identical to the sync client; just await the call.
async_example.py

Local Deployment

When you’re running the Boole local binary, change base_url to point at localhost and pass any non-empty string as the API key — the local server does not perform key validation.
local.py
The local binary starts in under 400 ms and exposes the same /v1 interface as the cloud API. You can switch between local and cloud by changing one line — everything else in your code stays the same.