Small starter project for claude-agent-sdk, the Python packaging of Claude Code as a library.
test_query.py— minimal smoke test for the SDK'squery()function: sends a one-off prompt and prints the reply.multi_agent_starter.py— a two-step pipeline example.call_researcher()calls the Anthropic API directly with structured outputs (client.messages.parse(..., output_format=ResearcherOutput)) to gather evidence for the question, then the result is handed to asynthesizerstep run throughclaude-agent-sdkto compose the final answer.
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install claude-agent-sdk anthropicThe SDK shells out to the claude CLI (@anthropic-ai/claude-code on npm) as its transport, so that must be installed and on PATH (npm install -g @anthropic-ai/claude-code).
Either of the following works — the SDK/CLI picks up whichever is available:
- Interactive / local dev:
claude login(orclaude auth statusto check) authenticates via your claude.ai account. NoANTHROPIC_API_KEYneeded. - Scripted / non-interactive: set
ANTHROPIC_API_KEYin the environment before running.
Note: call_researcher() in multi_agent_starter.py uses the raw anthropic SDK client directly, which does not share claude login's credential store. It needs ANTHROPIC_API_KEY set, or ant auth login run separately, even if claude login is already configured for the Agent SDK's synthesizer step.
.\.venv\Scripts\Activate.ps1
python test_query.py
python multi_agent_starter.pyThis project is a local starter, not a deployed service — there's no server, container, or CI config here. If you take it further:
- Credentials: don't rely on
claude login's stored session in a deployed environment. SetANTHROPIC_API_KEYas a secret/environment variable on whatever runs the code (CI job, container, scheduled task). - Runtime dependency: the
claudeCLI must be present in that environment too (it's what the SDK actually invokes) — install it via npm as part of your build/image step, not just locally. - Don't commit
.venv— it's excluded via.gitignore; rebuild it frompip install claude-agent-sdkon the target machine instead. - Cost: every
query()call is a billed API call (see the--- done in ...ms, cost $...line each script prints) — factor that into any scheduled or automated deployment.