aix.claude_cli¶
A chat backend that runs prompts through the Claude Code CLI (claude -p).
With a Claude subscription and the CLI installed, claude -p answers prompts without
an API key, billed to the subscription. Use a model id with the claude-cli/ prefix
and aix.chat() / aix.complete() route it here instead of to LiteLLM:
>>> from aix import chat
>>> chat("Say hi in one word.", model="claude-cli/haiku")
'Hi!'
The CLI exposes no sampling controls, so temperature, max_tokens, seed,
stream and the like raise ValueError instead of being ignored in silence. The
cost the CLI reports is on Completion.raw["total_cost_usd"] (see
claude_cli_cost()).
Notes
ANTHROPIC_API_KEY is removed from the child environment (the CLI would
otherwise bill that key, not the subscription); --bare is never used, since it skips
the keychain read that finds the subscription login; the call runs in a neutral cwd with
no tools, MCP servers, slash commands or session persistence.
Module Attributes
refused, not dropped. |
Functions
Raise |
|
|
Run |
|
The cost in USD the CLI reported for |
|
Whether |
|
Raise |
- aix.claude_cli.UNSUPPORTED_PARAMS = ('temperature', 'max_tokens', 'seed', 'response_format', 'response_schema')¶
refused, not dropped.
- Type:
chat/completearguments the CLI cannot honour
- aix.claude_cli.check_claude_cli()[source]¶
Raise
RuntimeErrorwith an install hint whenclaudeis not on PATH.- Return type:
- aix.claude_cli.claude_cli_complete(messages, *, model, timeout=600, cwd=None, extra_args=(), runner=None)[source]¶
Run
messagesthroughclaude -pand return anaix.chat.Completion.modelis"claude-cli/<name>"(haiku,sonnet,opusor a full id).runneris thesubprocess.runseam (default: looked up at call time). A CLI error (is_error, or aterminal_reasonother thancompleted) raisesRuntimeError.
- aix.claude_cli.claude_cli_cost(completion)[source]¶
The cost in USD the CLI reported for
completion(notional on a subscription).- Return type: