Skip to content

LLM — API reference

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: str

system_prompt

Optional system prompt prepended with a marker.

TYPE: str | None DEFAULT: None

model

Model name passed to --model (default: haiku).

TYPE: str DEFAULT: 'haiku'

timeout

Subprocess timeout in seconds. None (the default) reads the llm-timeout setting.

TYPE: int | None DEFAULT: None

retries

Number of retries on transient failure (default: 0).

TYPE: int DEFAULT: 0

backoff_base

Base for exponential backoff in seconds (default: 2.0).

TYPE: float DEFAULT: 2.0

RETURNS DESCRIPTION
str | None

Stripped stdout on success, or None on failure.