Usage guide
Setup, environment variables, and Python/JavaScript/Go usage examples.
AnthropicLLM
Anthropic Claude LLM plugin. Wraps the Anthropic Messages API with optional extended thinking support, streaming-first generation, and tool/function calling.Constructor
Anthropic API key. Falls back to the
ANTHROPIC_API_KEY environment variable when omitted.Claude model ID to use. Defaults to
"claude-sonnet-4-20250514" (Claude Sonnet 4). Other options include "claude-opus-4-20250514" (most capable), "claude-haiku-3-5-20241022" (fastest/cheapest). Accepts any AnthropicLLMModel enum value or a raw string model ID.Sampling temperature in
[0.0, 1.0]. Lower values produce more deterministic output; higher values increase creativity. Defaults to 0.7.Maximum number of tokens the model may generate per response. Defaults to
1024. The legacy max_tokens kwarg is accepted for backward compatibility and overrides this value when it equals the default.Nucleus sampling probability mass in
(0.0, 1.0]. Mutually exclusive with temperature: set one or the other, not both. Defaults to None (disabled).Restrict sampling to the top-K most likely tokens at each step. Defaults to
None (disabled).One or more strings at which the model will stop generating. Accepts a single string or a list of strings. Defaults to
None.Token budget for Claude’s extended thinking (chain-of-thought reasoning).
None disables thinking; set to a positive integer (e.g. 1024) to enable. The legacy thinking={"budget_tokens": N} kwarg is also accepted.aclose
cancel_current_generation
chat
The conversation history to send to the model.
Optional tool definitions the model may call.
Optional conversational graph guiding the exchange.
LLMResponse: Response chunks produced as the model generates output.
emit
The event to emit.
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.