Module ai.anthropic

ballerinax/ai.anthropic Ballerina library

1.3.2

Overview

Anthropic provides high-performance, safe, and reliable large language models (LLMs).

The Anthropic connector offers APIs for connecting with Anthropic LLMs, enabling the integration of advanced conversational AI and language processing capabilities into applications.

Key Features

  • Connect and interact with Anthropic Large Language Models (LLMs)
  • Support for Claude 3.5 Sonnet, Claude 3 Opus, and other Claude models
  • Efficient handling of conversational prompts and responses
  • Secure communication with API key authentication

Prerequisites

Before using this module in your Ballerina application, first you must obtain the nessary configuration to engage the LLM.

Quickstart

To use the ai.anthropic module in your Ballerina application, update the .bal file as follows:

Step 1: Import the module

Import the ai.anthropic; module.

Copy
import ballerinax/ai.anthropic;

Step 2: Intialize the Model Provider

Here's how to initialize the Model Provider:

Copy
import ballerina/ai;
import ballerinax/ai.anthropic;

final ai:ModelProvider anthropicModel = check new anthropic:ModelProvider("anthropicAiApiKey", anthropic:CLAUDE_3_7_SONNET_20250219, "2023-06-01");

Step 4: Invoke chat completion

Copy
ai:ChatMessage[] chatMessages = [{role: "user", content: "hi"}];
ai:ChatAssistantMessage response = check anthropicModel->chat(chatMessages, tools = []);

chatMessages.push(response);

Import

import ballerinax/ai.anthropic;Copy

Other versions

See more...

Metadata

Released date: 7 days ago

Version: 1.3.2

License: Apache-2.0


Compatibility

Platform: java21

Ballerina version: 2201.12.0

GraalVM compatible: Yes


Pull count

Total: 10120

Current verison: 85


Weekly downloads


Source repository


Keywords

Agent

Anthropic

Model

Provider

Vendor/Anthropic

Area/AI & Machine Learning

Type/Connector


Contributors