Skip to main content

AgentBlit Python SDK

Build LLM agents with:

  • AgentBlit remote tools
  • optional local Python tools
  • streaming output
  • approval-gated actions
  • short-term memory with automatic summarization

Install

cd agentblit-python
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -e .

Quick Start

import asyncio
from agentblit import Agent, tool

@tool(description="Add two integers.")
def add(a: int, b: int) -> int:
    return a + b

async def main() -> None:
    agent = Agent(
        model="openai/gpt-4o-mini",
        api_key="YOUR_LLM_KEY",
        agentblit_api_key="YOUR_AGENTBLIT_KEY",
        system_prompt="You are a helpful assistant.",
        custom_tools=[add],
    )

    async for chunk in agent.run("What is 200 + 30? Use tools if needed."):
        print(chunk, end="")
    print()

asyncio.run(main())

1) Agent Initialization Configs

Agent(...) accepts:

Key Type Required Default Values / Format Use Case
model str Yes - vendor/model (for example: openai/gpt-4o-mini, anthropic/claude-sonnet-4-0, gemini/gemini-2.0-flash, openrouter/openai/gpt-4o-mini) Select provider + model
api_key str Yes - LLM provider API key Send model requests
agentblit_api_key str Yes - AgentBlit API key (X-API-Key) Remote tools + analytics events
agentblit_url str No https://console.agentblit.com Valid base URL Self-hosted or staging AgentBlit
agent_id str No Auto-generated UUID Any non-empty string Reuse a stable agent identity across sessions/events
system_prompt str No "" Any instruction text Set assistant behavior
max_history int No 5 Integer >= 1 Keep recent messages before summarization
max_tool_rounds int No 25 Integer >= 1 Limit LLM-tool loop iterations
debug bool No False True or False Enable verbose SDK logs
timeout float (seconds) No 30.0 Positive number Control HTTP timeout for LLM + AgentBlit
approval_callback async (tool_name, args_dict) -> bool No - Async function Approve/reject needs_approval tools
custom_tools list No [] Local @tool callables Register app-specific local tools

2) All SDK Features

  • Vendor routing for openai, anthropic, gemini, and openrouter
  • Remote AgentBlit tools (/api/tools/list, /api/tools/call)
  • Local tools via @tool, custom_tools, and agent.register_tool(...)
  • Approval-gated tools (needs_approval) with callback support
  • Streaming responses with async for chunk in agent.run(...)
  • Multi-round tool calling in one run()
  • Memory summarization using max_history
  • Default system guidance to use tools and available long-term memory tools (retrieveRelevantMemory, updateMemory) when needed
  • Automatic analytics batching (agent_init, user_prompt, llm_call, tool_call, tools_updated, agent_loop_error)
  • Custom analytics via agent.track(event_type, properties)

3) Examples

Example 1: Basic Streaming Agent

agent = Agent(
    model="openai/gpt-4o-mini",
    api_key="YOUR_LLM_KEY",
    agentblit_api_key="YOUR_AGENTBLIT_KEY",
    system_prompt="Be concise and accurate.",
)

Example 2: Approval-Gated Tool

async def approval_callback(tool_name: str, args_dict: dict) -> bool:
    print("Approve tool call?", tool_name, args_dict)
    return tool_name != "delete_production_data"

agent = Agent(
    model="openai/gpt-4o-mini",
    api_key="YOUR_LLM_KEY",
    agentblit_api_key="YOUR_AGENTBLIT_KEY",
    approval_callback=approval_callback,
)

Repo Examples

Release files for agentblit 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentblit 0.1.2
File Size Uploaded
agentblit-0.1.2.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentblit 0.1.2
File Interpreter ABI Platform
agentblit-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.7 kB

Release files / agentblit-0.1.2.tar.gz

Download URL agentblit-0.1.2.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4e0aa20689c79ae909b3301f97f40f88da0eb729703d67539545d8e1f8b22919
BLAKE2b-256 checksum
How to use checksums
3050715cc8e17453d203b6bcbd99342e1ca0a16d6e376bdc42ce9d606e87777a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / agentblit-0.1.2-py3-none-any.whl

Download URL agentblit-0.1.2-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1e88eebe6ce5c9dcdb8aa1b1fa62801ecb034b00cff007b489b6037c5746952
BLAKE2b-256 checksum
How to use checksums
04b3bc5c84d0b1135c0c09e95a7f3a1aede8a7dd6bdf776d2a129f8b0ca35c3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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