docs/guides/python-ai-agent-sdk.md
This guide shows when to use the Nanobot Python SDK instead of calling a model directly. The SDK runs the same agent runtime used by the CLI: model routing, tools, workspace access, session history, memory, streaming events, and runtime helpers.
NanobotUse the Python SDK for notebooks, evals, product backends, local scripts, workflow runners, and integrations that need direct access to agent sessions, memory, hooks, runtime state, or structured run results.
Use the OpenAI-compatible API instead when another language or process should call nanobot over HTTP.
python -m pip install nanobot-ai
nanobot onboard --wizard
nanobot agent -m "Hello!"
import asyncio
from nanobot import Nanobot
async def main() -> None:
async with Nanobot.from_config() as bot:
result = await bot.run("List the top-level files in this workspace.")
print(result.content)
asyncio.run(main())
Nanobot instance for related work.session_key when a user, job, or eval case needs persistent history.bot.stream(...) when the caller needs live text, tool, or failure
events.nanobot agent -m "Hello!" in the same
environment.bot.runtime.workspace and bot.runtime.model to confirm the expected
config loaded.config_path and workspace when scripts run from services.