Documentation Index
Fetch the complete documentation index at: https://www.getmaxim.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
View module source on GitHub
class MaximAnthropicMessages(Messages)
Maxim-enhanced Anthropic Messages client.
This class extends the Anthropic Messages resource to integrate with Maxim’s
logging and monitoring capabilities. It automatically tracks message creation,
both streaming and non-streaming, and logs them through the Maxim platform.
The class handles trace management, generation logging, and error handling
while maintaining compatibility with the original Anthropic Messages API.
Attributes:
| Name | Type | Description |
|---|
_logger | Logger | The Maxim logger instance for tracking interactions. |
__init__
def __init__(client: Anthropic, logger: Logger)
Initialize the Maxim Anthropic Messages client.
Arguments:
| Name | Type | Description |
|---|
client | Anthropic | The Anthropic client instance. |
logger | Logger | The Maxim logger instance for tracking and |
logging message interactions.
create_non_stream
def create_non_stream(*args, **kwargs) -> Any
Create a non-streaming message with Maxim logging.
This method handles non-streaming message creation while automatically
logging the interaction through Maxim. It manages trace creation,
generation tracking, and error handling.
Arguments:
| Name | Description |
|---|
*args | Variable length argument list passed to the parent create method. |
**kwargs | Arbitrary keyword arguments passed to the parent create method. |
Special headers:
- x-maxim-trace-id: Optional trace ID for associating with existing trace.
- x-maxim-generation-name: Optional name for the generation.
Returns:
| Name | Description |
|---|
Any | The response from the Anthropic API create method. |
Notes:
If logging fails, the method will still return the API response
but will log a warning message.
create_stream
def create_stream(*args, **kwargs) -> Any
Create a streaming message with Maxim logging.
This method handles streaming message creation while automatically
logging the interaction through Maxim. It manages trace creation,
generation tracking, and processes streaming events.
Arguments:
| Name | Description |
|---|
*args | Variable length argument list passed to the parent stream method. |
**kwargs | Arbitrary keyword arguments passed to the parent stream method. |
Special headers:
- x-maxim-trace-id: Optional trace ID for associating with existing trace.
- x-maxim-generation-name: Optional name for the generation.
Returns:
| Name | Description |
|---|
[StreamWrapper](/sdk/python/references/logger/anthropic/stream_manager) | A wrapped stream manager that processes chunks and |
handles logging of streaming events.
Notes:
The method returns a StreamWrapper that automatically processes
stream chunks and logs the final result when the stream ends.
create
def create(*args,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
metadata: MetadataParam | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
tool_choice: dict | NotGiven = NOT_GIVEN,
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
top_k: int | NotGiven = NOT_GIVEN,
top_p: float | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
**kwargs) -> Any
Create a message with automatic streaming detection and Maxim logging.
This is the main entry point for message creation. It automatically
detects whether streaming is requested and routes to the appropriate
handler while ensuring all interactions are logged through Maxim.
Arguments:
| Name | Type | Description | | | |
|---|
max_tokens | int | The maximum number of tokens to generate. | | | |
messages | Iterable[MessageParam] | The conversation messages. | | | |
model | str | The model to use for generation. | | | |
metadata | _MetadataParam | NotGiven_ | Additional metadata for the request. | | |
stop_sequences | _List[str] | NotGiven_ | Sequences that will stop generation. | | |
system | _Union[str, Iterable[TextBlockParam]] | NotGiven_ | System message. | | |
temperature | _float | NotGiven_ | Sampling temperature (0-1). | | |
tool_choice | _dict | NotGiven_ | How the model should use tools. | | |
tools | _Iterable[ToolParam] | NotGiven_ | Available tools for the model. | | |
top_k | _int | NotGiven_ | Top-k sampling parameter. | | |
top_p | _float | NotGiven_ | Top-p (nucleus) sampling parameter. | | |
extra_headers | _Headers | None_ | Additional HTTP headers. | | |
extra_query | _Query | None_ | Additional query parameters. | | |
extra_body | _Body | None_ | Additional request body data. | | |
timeout | _float | httpx.Timeout | None | NotGiven_ | Request timeout. |
**kwargs | | Additional arguments, including ‘stream’ for streaming mode. | | | |
Returns:
| Name | Description |
|---|
Any | Either a direct message response or a StreamWrapper for streaming. |
Notes:
The method automatically detects streaming mode via the ‘stream’ parameter
in kwargs and routes accordingly.
stream
def stream(*args, **kwargs) -> Any
Create a streaming message with Maxim logging.
This method is a direct alias for create_stream, providing compatibility
with the standard Anthropic Messages API while adding Maxim logging.
Arguments:
| Name | Description |
|---|
*args | Variable length argument list passed to create_stream. |
**kwargs | Arbitrary keyword arguments passed to create_stream. |
Returns:
| Name | Description |
|---|
[StreamWrapper](/sdk/python/references/logger/anthropic/stream_manager) | A wrapped stream manager with logging capabilities. |