class

Anthropic

Inherits Reference < Object

Anthropic API client for Crystal

A Crystal client for the Anthropic Messages API.

Quick Start

require "anthropic"

client = Anthropic::Client.new
response = client.messages.create(
  model: Anthropic::Model.sonnet,
  messages: [Anthropic::Message.user("Hello!")],
  max_tokens: 1024
)
puts response.text

Configuration

By default, the client reads ANTHROPIC_API_KEY from environment. You can also pass it explicitly:

client = Anthropic::Client.new(api_key: "sk-ant-...")

Constants

VERSION = {{ (`shards version`).chomp.stringify }}

Full version string from shard.yml

VERSION_MAJOR = 0
VERSION_MINOR = 0
VERSION_PATCH = 1
VERSION_STATE = nil

Nested types