Bitfab client for provider-based API calls with local BAML execution
Actively maintained. Last release 3 days ago. A safe choice.
pip install bitfab-pyBitfab
Bitfab client for provider-based API calls.
Monorepo Structure
This package is part of the Harvest monorepo. While the TypeScript/JavaScript packages use a pnpm workspace for shared dependencies, this Python package uses Poetry for its dependency management.
Note: The pnpm workspace includes:
bitfab-web- Next.js web applicationbitfab-typescript-sdk- TypeScript SDKbitfab-vscode- VS Code extensionfrontend- Legacy frontend
From the root directory, you can run TypeScript tests and validation across all packages with pnpm test or pnpm validate.
Installation
Python 3.10 or newer is required.
Basic Installation
pip install bitfab-py
With OpenAI Tracing Support
If you want to use the OpenAI Agents SDK tracing integration:
pip install bitfab-py[openai-tracing]
Local Development
For local development:
cd bitfab-python-sdk
poetry install --with dev
After installation, you can use developer tasks. For the best experience, add Poetry's venv to your PATH:
# Add to your ~/.zshrc or ~/.bashrc
export PATH="$(poetry env info --path)/bin:$PATH"
# Then you can use 'dev' directly (no ./run or poetry run needed!)
dev list
dev test
See Development Tasks below for all available commands.
Or install as an editable package from the parent directory:
poetry add --editable ../bitfab-python-sdk
Usage
Basic Usage
from bitfab import Bitfab
client = Bitfab(
api_key="bf_your_api_key_here",
service_url="https://bitfab.ai", # Optional, defaults to production
env_vars={"OPENAI_API_KEY": "sk-your-openai-key"}, # Optional, for local BAML execution
)
result = client.call("method_name", arg1="value1", arg2="value2")
OpenAI Agents SDK Tracing
If you have the openai-agents package installed (via pip install bitfab-py[openai-tracing]), you can use the tracing processor:
from bitfab import Bitfab
from agents import Agent, add_trace_processor
bitfab = Bitfab(api_key="bf_your_api_key_here")
# Register the processor once: it captures agent internals (LLM/tool/handoff spans).
add_trace_processor(bitfab.get_openai_tracing_processor())
agent = Agent(name="my-agent", instructions="...")
# The run wrapper records a replayable root carrying the run input.
handler = bitfab.get_openai_agent_handler("my-agent")
# Swap Runner.run(agent, input) -> handler.wrap_run(agent, input)
result = await handler.wrap_run(agent, "user input here")