Skip to main content

AnthropicEndpoint

Namespace: Wisej.AI.Endpoints

Assembly: Wisej.AI

Represents an endpoint for connecting to Anthropic services.

public class AnthropicEndpoint : SmartHttpEndpoint

This class is used to configure and manage connections to Anthropic endpoints, providing methods to send messages and handle responses. It inherits from SmartHttpEndpoint.

Constructors​

AnthropicEndpoint()​

Initializes a new instance of the AnthropicEndpoint class.

Sets default values for authentication, model, URL, and headers.

Properties​

Authentication​

String: Gets or sets the authentication method for the endpoint. (Default: "x-api-key")

Model​

String: Gets or sets the model used by the Anthropic endpoint. (Default: "claude-3-5-sonnet-20241022")

URL​

String: Gets or sets the URL for the Anthropic API endpoint. (Default: "https://api.anthropic.com/v1/messages")

Methods​

AddMessages(payload, session, messages)​

Adds messages to the payload for the Anthropic API request.

ParameterTypeDescription
payloadObjectThe payload to be sent.
sessionSmartSessionThe current session.
messagesIList<Message>The list of messages to include.

Prepares the system message and other messages for the API request. Throws:

AddOptions(message, session)​

Adds options to the message before sending it to the Anthropic endpoint.

ParameterTypeDescription
messageObjectThe message to be sent.
sessionSmartSessionThe current session.

Sets default values for temperature and max tokens in the message.

BuildMessage(message)​

Builds a message object for the Anthropic API.

ParameterTypeDescription
messageMessageThe message to be converted.

Returns: Object. An object representing the message for the API.

Handles different input types, including text and images. Throws:

ReadAssistantMessage(response, message)​

Reads the assistant's message from the response.

ParameterTypeDescription
responseResponseThe response from the API.
messageMessageThe message object to populate.

Parses the response content and updates the message text. Throws:

ReadUsage(message, reply)​

Reads the usage information from the API reply.

ParameterTypeDescription
messageMessageThe message object to update.
replyObjectThe dynamic reply object from the API.