claude-chat-client-py (0.1.0)
Installation
pip install --index-url claude-chat-client-pyAbout this package
Shared Python Anthropic client: per-app API key/model config + a streaming tool-use loop, extracted from careboard/HomeManagement
claude-chat-client-py
Shared Python Anthropic client for careboard, HomeManagement, and medsync's
backends. HomeManagement already streams via
anthropic.AsyncAnthropic().messages.stream(...) — this package is that
same pattern, with the tool-use round-trip loop factored out so it's
written once instead of per app. careboard currently calls the Messages
API directly via httpx; migrating it to this package also gets it onto
the official SDK.
Usage
from claude_chat_client import ClaudeClient, ClaudeClientConfig
claude = ClaudeClient(ClaudeClientConfig(
api_key=settings.anthropic_api_key, # this app's own key, unchanged
model=settings.anthropic_model, # this app's own model, unchanged
))
async def execute_tool(call):
if call.name == "log_medication_dose":
return await log_dose(call.input)
raise ValueError(f"unknown tool {call.name}")
result = await claude.chat(
system="You are ...",
messages=conversation_so_far,
tools=MY_APP_TOOLS,
on_text_delta=lambda delta: response_writer.write(delta),
execute_tool=execute_tool,
)
# result.messages -> persist as the new conversation history
# result.final_text -> full assistant text across all tool-loop rounds
Requires anthropic>=0.69 (verified against 0.117.0). Tool execution
stays app-specific by design — this package only owns the stream/detect
tool_use/await execute_tool/loop plumbing, capped by max_tool_rounds
(default 8).
Install
Not published to PyPI. Add as a path or git dependency, e.g. in
pyproject.toml:
dependencies = [
"claude-chat-client @ file:///path/to/claudechatwindow/packages/client-python",
]