Skip to main content

AnthropicClient

Initialize the Anthropic API client.
Parameters:

Instance Attributes

api_key



aws_access_key



aws_region



aws_secret_key



aws_session_token



gcp_auth_token



gcp_project_id



gcp_region



Instance Methods

convert_tools_to_functions

Convert tool definitions into Anthropic-compatible functions, updating nested $ref paths in property schemas.
Parameters: Returns:

cost

Calculate the cost of the completion using the Anthropic pricing. Parameters:

create

Creates a completion using the Anthropic API. Parameters:

get_usage

Get the usage of tokens and their cost information. Parameters:

load_config

Load the configuration for the Anthropic API client. Parameters:

message_retrieval

Retrieve and return a list of strings or a list of Choice.Message from the response.
NOTE: if a list of Choice.Message is returned, it currently needs to contain the fields of OpenAI’s ChatCompletion Message object, since that is expected for function or tool calling in the rest of the codebase at the moment, unless a custom agent is being used.
Parameters:

openai_func_to_anthropic

Parameters: