Working with the Anthropic API client

The API client offers the direct connection to the Anthropic API. Before you can work with it, please first see about Adding an Anthropic API key.

If you stored your API in a file instantiate the client like this:

client := GtAnthropicClient withApiKeyFromFile
  

This is the default mechanism.

If you have the API in the clipboard, you can instead do this:

client := GtAnthropicClient withApiKeyFromClipboard
  

This client is your entry point for interacting with Anthropic. You can for instance use it to query the list of models.

client listModels
  

You can even use it to interact with the chat feature directly.

messages := {
	GtLlmUserMessage new content: 'Hello Anthropic! How are you today?'
}.

client completeChatWithModel: 'claude-3-5-sonnet-20241022' messages: messages andMaxTokens: 4096