LLM — API reference¶
Invocation¶
call_claude
¶
call_claude(
prompt: str,
*,
system_prompt: str | None = None,
model: str = "haiku",
timeout: int | None = None,
retries: int = 0,
backoff_base: float = 2.0,
) -> str | None
Invoke claude -p --model <model> with the prompt via stdin.
| PARAMETER | DESCRIPTION |
|---|---|
prompt
|
The user prompt to send.
TYPE:
|
system_prompt
|
Optional system prompt prepended with a marker.
TYPE:
|
model
|
Model name passed to
TYPE:
|
timeout
|
Subprocess timeout in seconds.
TYPE:
|
retries
|
Number of retries on transient failure (default: 0). A refused command line is never retried.
TYPE:
|
backoff_base
|
Base for exponential backoff in seconds (default: 2.0).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
Stripped stdout on success, or |
Diagnostics¶
ProbeResult
dataclass
¶
ProbeResult(
returncode: int | None,
tools: list[str],
mcp_servers: list[str],
stderr: str,
saw_init: bool = False,
)
What one real nested call saw, read from its stream-json init event.
| ATTRIBUTE | DESCRIPTION |
|---|---|
returncode |
The nested claude's exit code (
TYPE:
|
tools |
Tool names offered to the model.
TYPE:
|
mcp_servers |
MCP server names the call started, whatever their status.
TYPE:
|
stderr |
The call's stderr, stripped, or why it could not run.
TYPE:
|
saw_init |
Whether an init event was found at all. Without one, the
empty
TYPE:
|
probe_claude
¶
probe_claude(
*, model: str = "haiku", timeout: int | None = None
) -> ProbeResult
Make one tiny real nested call and report what it ran with.
Uses exactly the command line :func:call_claude uses, plus
--output-format stream-json --verbose for the init event, so a
diagnostic can confirm the call succeeds and runs with no tools and no
MCP servers on this host.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Model name passed to
TYPE:
|
timeout
|
Subprocess timeout in seconds.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ProbeResult
|
The call's :class: |