Anthropic
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
- Anthropic::APIError
- Anthropic::AuthenticationError
- Anthropic::AutoPaginator(T)
- Anthropic::BatchResultMessage
- Anthropic::BatchResultsNotReadyError
- Anthropic::Beta
- Anthropic::Client
- Anthropic::Completions
- Anthropic::Configuration
- Anthropic::ConflictError
- Anthropic::ConnectionError
- Anthropic::Content
- Anthropic::ContentBlock
- Anthropic::Converters
- Anthropic::CreateMessageBatchRequest
- Anthropic::Error
- Anthropic::EventSource
- Anthropic::File
- Anthropic::FileDeleted
- Anthropic::Files
- Anthropic::InvalidRequestError
- Anthropic::ListParams
- Anthropic::MalformedResultsURLError
- Anthropic::Message
- Anthropic::MessageBatch
- Anthropic::MessageBatchDeleted
- Anthropic::MessageBatchResult
- Anthropic::Messages
- Anthropic::Metadata
- Anthropic::Model
- Anthropic::ModelInfo
- Anthropic::Models
- Anthropic::NotFoundError
- Anthropic::OverloadedError
- Anthropic::Page(T)
- Anthropic::PaginationError
- Anthropic::PermissionError
- Anthropic::RateLimitError
- Anthropic::RequestOptions
- Anthropic::RequestTimeoutError
- Anthropic::ResponseContentBlock
- Anthropic::ResponseTextBlock
- Anthropic::ResponseThinkingBlock
- Anthropic::ResponseToolUseBlock
- Anthropic::ResponseUnknownBlock
- Anthropic::RetryPolicy
- Anthropic::Skill
- Anthropic::SkillDeleted
- Anthropic::SkillSource
- Anthropic::SkillVersion
- Anthropic::SkillVersionDeleted
- Anthropic::SkillVersionsListParams
- Anthropic::SkillVersionsListResponse
- Anthropic::Skills
- Anthropic::SkillsListParams
- Anthropic::SkillsListResponse
- Anthropic::StreamEvent
- Anthropic::StructuredOutput
- Anthropic::ThinkingConfig
- Anthropic::TimeoutError
- Anthropic::ToolChoice
- Anthropic::ToolDefinition
- Anthropic::ToolRunner
- Anthropic::ToolUse
- Anthropic::ToolUseError
- Anthropic::URLAuthorityMismatchError
- Anthropic::URLHostMismatchError
- Anthropic::UnknownStreamEvent
- Anthropic::UnprocessableEntityError
- Anthropic::UploadFileRequest
- Anthropic::UploadSkillRequest
- Anthropic::Usage