yera.models.interfaces.llms.anthropic
Module containing the interface to Anthropic LLMs.
Symbols
AnthropicLLM
BaseLLMInterfaceInterface to Anthropic LLMs via the Anthropic SDK.
This class provides a wrapper around the Anthropic API client, handling configuration, model selection, and streaming interactions with Claude models. It supports both standard chat completions and structured output generation for models that support it (Claude 4.5+).
Attributes
The identifier of the Claude model to use.
Connection configuration for the Anthropic API.
Lazy-initialised Anthropic API client instance.
object defining the capabilities of the LLM.
object defining the inference params of the LLM.
Methods
AnthropicLLM.start
start() → NoneInitialize the Anthropic API client.
Creates and stores an Anthropic client instance using the configured connection settings. This method must be called before making any API requests via the client property.
AnthropicLLM.stop
stop() → NoneShut down and clear the Anthropic API client.
Releases the Anthropic client instance by setting it to None. After calling this method, start() must be called again before further API requests can be made.
AnthropicLLM.chat
chat(
messages: list[Message],
reasoning_level: ReasoningLevel | None = None,
**anthropic_kw,
) → Iterator[LLMToken]Stream a chat completion response from Anthropic.
Thinking content is streamed only when the model thinks and
display is "summarized". Under adaptive thinking the model
may skip thinking entirely.
Parameters
The workspace conversation history.
Set the reasoning effort level overriding the default (medium)
Per-call overrides passed to the Messages API, taking precedence over configured inference parameters.
AnthropicLLM.make_struct
make_struct(
messages: list[Message],
reasoning_level: ReasoningLevel | None = None,
**anthropic_kw,
) → Iterator[LLMToken]Stream a structured output response conforming to a schema.
The response is constrained by the schema through the API's structured outputs support. Thinking, when the model thinks, is unconstrained and arrives as thinking tokens ahead of the JSON.
Parameters
The workspace conversation history.
A pydantic model class defining the output structure.
Set the reasoning effort level overriding the default (off)
Per-call overrides passed to the Messages API, taking precedence over configured inference parameters.
Raises
If the model does not support structured outputs.
AnthropicLLM.with_instruction
with_instruction(
messages: list[Message],
instruction: str | None,
) → list[Message]Prepend or insert an instruction into the conversation history.
Parameters
The existing conversation history.
The extra instruction to inject.
Returns
A new list of messages with the instruction incorporated.