Anthropic
Constants
Advisor tool (secondary-model advisor) beta header.
Agent persistent memory beta header (Memory Stores API).
Beta header constants
1M context window beta header.
Extended / interleaved thinking betas.
Dreams (memory consolidation) beta header.
Research-preview API: request/response shapes may change without a
deprecation period. Required by client.beta.dreams.* together with
MANAGED_AGENTS_BETA (both auto-attached). Access is separately gated.
Primary fallback-credit beta. Tracks the latest official default (July 2026).
Fallback-credit beta header (June 2026). Kept for callers that pin the older bare-string credit-token behavior.
Fallback-credit beta header (July 2026) — required for object-form
fallback_credit_token ({token, mode}) and used by default by
BetaRefusalFallbackMiddleware.
Only valid string form of fallbacks (server-defined default chain).
Fast mode beta header.
MCP Tunnels beta header (research preview).
Required by client.beta.tunnels.* and client.beta.tunnels.certificates.*.
Supersedes Admin API /v1/organizations/tunnels during a migration window.
Management calls need WIF with workspace:manage_tunnels — not API keys.
Surfaces model_context_window_exceeded as a recoverable stop_reason.
Shorthand helper for accessing model IDs via symbols
Anthropic::Model::CLAUDE_SONNET # => "claude-sonnet-5"
Anthropic::Model::CLAUDE_FABLE # => "claude-fable-5"
Anthropic::Model::CLAUDE_OPUS # => "claude-opus-5"
Anthropic::Model::CLAUDE_HAIKU # => "claude-haiku-4-5"
Anthropic.model_name(:sonnet) # => "claude-sonnet-5"
Anthropic.model_name(:fable) # => "claude-fable-5"
Anthropic.model_name(:mythos) # => "claude-mythos-5"
Anthropic.model_name(:opus) # => "claude-opus-5"
Anthropic.model_name(:opus_5) # => "claude-opus-5"
Anthropic.model_name(:haiku) # => "claude-haiku-4-5-20251001"
Output token cap betas.
PDF document support beta header.
Primary server-side fallbacks beta. Tracks the latest official default
(July 2026). Auto-attached when fallbacks: is set.
Server-side fallbacks beta header (June 2026).
Prefer SERVER_SIDE_FALLBACK_BETA / SERVER_SIDE_FALLBACK_BETA_2026_07_01
for new code; this constant is kept for callers that pin the older header.
Server-side fallbacks beta header (July 2026) — supports fallbacks: "default"
and aligns with the official Python/Ruby/TS SDKs.
Thinking token count in streaming deltas (optional display).
User profiles beta header.
Class methods
Collect the beta header strings required by a set of server tools.
This is the single source of truth for server-tool-to-beta mappings so that resource classes don't have to duplicate the case logic.
Returns true when fallbacks is a non-empty chain or the string "default".
Any other string (including empty) is treated as absent so we do not
auto-attach the server-side fallback beta for typos like "defaults".
Serialization via FallbacksParamConverter also rejects non-"default"
strings with ArgumentError.
Convenience method to create an output schema
output = Anthropic.output_schema(
name: "weather_report",
schema: {
"temperature" => Schema.number("Current temperature"),
"conditions" => Schema.string("Weather conditions"),
},
required: ["temperature", "conditions"]
)
Resolve and compile the complete "anthropic-beta" headers mapping
Helper method for creating inline tools with Schema DSL
weather_tool = Anthropic.tool(
name: "get_weather",
description: "Get current weather for a location",
schema: {
"location" => Schema.string("City name, e.g. San Francisco, CA"),
"unit" => Schema.enum("celsius", "fahrenheit", description: "Temperature unit"),
},
required: ["location"]
) do |input|
location = input["location"].as_s
unit = input["unit"]?.try(&.as_s) || "fahrenheit"
"The weather in #{location} is sunny and 72°#{unit == "celsius" ? "C" : "F"}."
end
Macros
Macro to create a typed output schema from a struct
struct MyOutput
include JSON::Serializable
getter result : String
getter confidence : Float64
end
schema = Anthropic.output_schema(type: MyOutput, name: "my_output")
Macro to create typed tools with struct input
This provides Ruby BaseTool-like functionality where:
- Input schema is derived from a Crystal struct
- Handler receives typed struct instead of JSON::Any
- Field descriptions come from @[JSON::Field(description: "...")]
struct SearchInput
include JSON::Serializable
getter query : String
getter category : Category?
end
tool = Anthropic.tool(
name: "search",
description: "Search products",
input: SearchInput
) do |input|
"Found results for #{input.query}"
end
Nested types
- Anthropic::APIConnectionError
- Anthropic::APIError
- Anthropic::APIRequest
- Anthropic::APIResponse
- Anthropic::APITimeoutError
- Anthropic::AdvisorRedactedResultContent
- Anthropic::AdvisorResultContent
- Anthropic::AdvisorTool
- Anthropic::AdvisorToolResultContent
- Anthropic::AdvisorToolResultErrorContent
- Anthropic::AdvisorToolResultValue
- Anthropic::AdvisorToolResultValueConverter
- Anthropic::AnyServerTool
- Anthropic::AnyStreamEvent
- Anthropic::AnyTool
- Anthropic::AuthenticationError
- Anthropic::BadRequestError
- Anthropic::Base64ImageSource
- Anthropic::Base64PDFSource
- Anthropic::BaseOutputSchema
- Anthropic::BashCodeExecutionOutputContent
- Anthropic::BashCodeExecutionResultValueContent
- Anthropic::BashCodeExecutionToolResultContent
- Anthropic::BashCodeExecutionToolResultErrorContent
- Anthropic::BashCodeExecutionToolResultValue
- Anthropic::BashCodeExecutionToolResultValueConverter
- Anthropic::BashTool
- Anthropic::BashToolLegacy
- Anthropic::BatchError
- Anthropic::BatchListResponse
- Anthropic::BatchRequest
- Anthropic::BatchRequestCounts
- Anthropic::BatchRequestParams
- Anthropic::BatchResponse
- Anthropic::BatchResult
- Anthropic::BatchResultData
- Anthropic::Batches
- Anthropic::Bedrock
- Anthropic::Beta
- Anthropic::BetaAgent
- Anthropic::BetaAgentListResponse
- Anthropic::BetaAgents
- Anthropic::BetaBatchListResponse
- Anthropic::BetaBatchRequest
- Anthropic::BetaBatchRequestParams
- Anthropic::BetaBatches
- Anthropic::BetaCloudConfig
- Anthropic::BetaCloudConfigParams
- Anthropic::BetaCredential
- Anthropic::BetaCredentialDeleteResponse
- Anthropic::BetaCredentialListResponse
- Anthropic::BetaCredentialValidation
- Anthropic::BetaDeploymentRuns
- Anthropic::BetaDeployments
- Anthropic::BetaDream
- Anthropic::BetaDreamError
- Anthropic::BetaDreamInput
- Anthropic::BetaDreamInputArrayConverter
- Anthropic::BetaDreamInputConverter
- Anthropic::BetaDreamListResponse
- Anthropic::BetaDreamMemoryStoreInput
- Anthropic::BetaDreamMemoryStoreOutput
- Anthropic::BetaDreamModelConfig
- Anthropic::BetaDreamOutput
- Anthropic::BetaDreamSessionsInput
- Anthropic::BetaDreamUsage
- Anthropic::BetaDreams
- Anthropic::BetaEnvironment
- Anthropic::BetaEnvironmentConfig
- Anthropic::BetaEnvironmentConfigParam
- Anthropic::BetaEnvironmentDeleteResponse
- Anthropic::BetaEnvironmentListResponse
- Anthropic::BetaEnvironments
- Anthropic::BetaFiles
- Anthropic::BetaLimitedNetwork
- Anthropic::BetaLimitedNetworkParams
- Anthropic::BetaManagedAgentsActor
- Anthropic::BetaManagedAgentsAgentParam
- Anthropic::BetaManagedAgentsAgentParamLike
- Anthropic::BetaManagedAgentsBranchCheckoutParam
- Anthropic::BetaManagedAgentsCheckoutParam
- Anthropic::BetaManagedAgentsCommitCheckoutParam
- Anthropic::BetaManagedAgentsDeletedMemory
- Anthropic::BetaManagedAgentsDeletedMemoryStore
- Anthropic::BetaManagedAgentsDeletedSession
- Anthropic::BetaManagedAgentsDeployment
- Anthropic::BetaManagedAgentsDeploymentListResponse
- Anthropic::BetaManagedAgentsDeploymentRun
- Anthropic::BetaManagedAgentsDeploymentRunListResponse
- Anthropic::BetaManagedAgentsEffort
- Anthropic::BetaManagedAgentsFileResourceParam
- Anthropic::BetaManagedAgentsGitHubRepositoryResourceParam
- Anthropic::BetaManagedAgentsMemory
- Anthropic::BetaManagedAgentsMemoryStore
- Anthropic::BetaManagedAgentsMemoryStoreResourceParam
- Anthropic::BetaManagedAgentsMemoryVersion
- Anthropic::BetaManagedAgentsModelConfig
- Anthropic::BetaManagedAgentsModelParamLike
- Anthropic::BetaManagedAgentsSession
- Anthropic::BetaManagedAgentsSessionResourceParam
- Anthropic::BetaManagedAgentsSessionThread
- Anthropic::BetaMemories
- Anthropic::BetaMemoryListResponse
- Anthropic::BetaMemoryStoreListResponse
- Anthropic::BetaMemoryStores
- Anthropic::BetaMemoryVersionListResponse
- Anthropic::BetaMemoryVersions
- Anthropic::BetaMessageCreateParams
- Anthropic::BetaMessages
- Anthropic::BetaModelListResponse
- Anthropic::BetaModels
- Anthropic::BetaNetworkingConfig
- Anthropic::BetaNetworkingConfigParam
- Anthropic::BetaPackages
- Anthropic::BetaRefusalFallbackMiddleware
- Anthropic::BetaSelfHostedConfig
- Anthropic::BetaSessionEvents
- Anthropic::BetaSessionListResponse
- Anthropic::BetaSessionResources
- Anthropic::BetaSessionThreadEvents
- Anthropic::BetaSessionThreadListResponse
- Anthropic::BetaSessionThreads
- Anthropic::BetaSessions
- Anthropic::BetaSkillVersions
- Anthropic::BetaSkills
- Anthropic::BetaTokenCountParams
- Anthropic::BetaTokenTaskBudget
- Anthropic::BetaTunnel
- Anthropic::BetaTunnelCertificate
- Anthropic::BetaTunnelCertificateListResponse
- Anthropic::BetaTunnelCertificates
- Anthropic::BetaTunnelListResponse
- Anthropic::BetaTunnelToken
- Anthropic::BetaTunnels
- Anthropic::BetaUnrestrictedNetwork
- Anthropic::BetaUserProfile
- Anthropic::BetaUserProfileEnrollmentURL
- Anthropic::BetaUserProfileListResponse
- Anthropic::BetaUserProfileTrustGrant
- Anthropic::BetaUserProfiles
- Anthropic::BetaVault
- Anthropic::BetaVaultDeleteResponse
- Anthropic::BetaVaultListResponse
- Anthropic::BetaVaults
- Anthropic::BetaVaultsCredentials
- Anthropic::BetaWebhookEvent
- Anthropic::BetaWebhooks
- Anthropic::CacheControl
- Anthropic::CacheCreation
- Anthropic::CacheMissReason
- Anthropic::CapabilitySupport
- Anthropic::Citation
- Anthropic::CitationArrayConverter
- Anthropic::CitationConfig
- Anthropic::CitationContentBlockLocation
- Anthropic::CitationConverter
- Anthropic::CitationPageLocation
- Anthropic::CitationRef
- Anthropic::CitationSearchResultLocation
- Anthropic::CitationWebSearchResultLocation
- Anthropic::CitationsDelta
- Anthropic::ClearThinkingEdit
- Anthropic::ClearToolUsesEdit
- Anthropic::Client
- Anthropic::CodeExecutionOutputContent
- Anthropic::CodeExecutionResultValueContent
- Anthropic::CodeExecutionTool
- Anthropic::CodeExecutionTool20250522
- Anthropic::CodeExecutionTool20260120
- Anthropic::CodeExecutionTool20260521
- Anthropic::CodeExecutionToolResultContent
- Anthropic::CodeExecutionToolResultErrorContent
- Anthropic::CodeExecutionToolResultValue
- Anthropic::CodeExecutionToolResultValueConverter
- Anthropic::CompactEdit
- Anthropic::CompactionConfig
- Anthropic::CompactionContent
- Anthropic::CompactionDelta
- Anthropic::ComputerUseTool
- Anthropic::ComputerUseTool20251124
- Anthropic::ComputerUseToolLegacy
- Anthropic::ConflictError
- Anthropic::ContainerConfig
- Anthropic::ContainerInfo
- Anthropic::ContainerSkill
- Anthropic::ContainerUploadContent
- Anthropic::ContentBlock
- Anthropic::ContentBlockArrayConverter
- Anthropic::ContentBlockConverter
- Anthropic::ContentBlockDeltaEvent
- Anthropic::ContentBlockStartEvent
- Anthropic::ContentBlockStopEvent
- Anthropic::ContextManagementCapability
- Anthropic::ContextManagementConfig
- Anthropic::ContextManagementEdit
- Anthropic::CredentialNetworking
- Anthropic::DeletedFile
- Anthropic::DeletedResponse
- Anthropic::DeltaUsage
- Anthropic::Diagnostics
- Anthropic::DiagnosticsParam
- Anthropic::DocumentContent
- Anthropic::DocumentSource
- Anthropic::EffortCapability
- Anthropic::EncryptedCodeExecutionResultValueContent
- Anthropic::ErrorEvent
- Anthropic::FallbackContent
- Anthropic::FallbackCreditNotApplied
- Anthropic::FallbackCreditRedeemed
- Anthropic::FallbackCreditStatus
- Anthropic::FallbackCreditStatusConverter
- Anthropic::FallbackCreditToken
- Anthropic::FallbackCreditTokenConverter
- Anthropic::FallbackCreditTokenParam
- Anthropic::FallbackCreditUsage
- Anthropic::FallbackInfo
- Anthropic::FallbackMessageIterationUsage
- Anthropic::FallbackParam
- Anthropic::FallbackRefusalTrigger
- Anthropic::FallbacksParam
- Anthropic::FallbacksParamConverter
- Anthropic::FileListResponse
- Anthropic::FileMetadata
- Anthropic::FileSource
- Anthropic::FileUpload
- Anthropic::GatewayTimeoutError
- Anthropic::GenericStopDetails
- Anthropic::ImageContent
- Anthropic::ImageSource
- Anthropic::InjectionLocation
- Anthropic::InlineTool
- Anthropic::InputJsonDelta
- Anthropic::InputSchema
- Anthropic::InternalServerError
- Anthropic::MCPServerDefinition
- Anthropic::MCPTool
- Anthropic::MCPToolConfiguration
- Anthropic::MCPToolResultContent
- Anthropic::MCPToolUseContent
- Anthropic::MCPToolset
- Anthropic::MCPToolsetConfig
- Anthropic::MemoryTool
- Anthropic::Message
- Anthropic::MessageCreateParams
- Anthropic::MessageDeltaEvent
- Anthropic::MessageParam
- Anthropic::MessageStartEvent
- Anthropic::MessageStopEvent
- Anthropic::MessageStream
- Anthropic::Messages
- Anthropic::Metadata
- Anthropic::MidConversationSystemBlock
- Anthropic::MidConversationSystemBlockArrayConverter
- Anthropic::MidConversationSystemBlockConverter
- Anthropic::MidConversationSystemContent
- Anthropic::Middleware
- Anthropic::MiddlewareNext
- Anthropic::Model
- Anthropic::ModelCapabilities
- Anthropic::ModelInfo
- Anthropic::ModelListResponse
- Anthropic::Models
- Anthropic::NotFoundError
- Anthropic::OutputConfig
- Anthropic::OutputFormat
- Anthropic::OutputSchema
- Anthropic::OutputTokensDetails
- Anthropic::OverloadedError
- Anthropic::ParsedMessage(T)
- Anthropic::PayloadTooLargeError
- Anthropic::PermissionDeniedError
- Anthropic::PingEvent
- Anthropic::PlainTextSource
- Anthropic::RateLimitError
- Anthropic::RedactedThinkingContent
- Anthropic::RefusalStopDetails
- Anthropic::Role
- Anthropic::Schema
- Anthropic::SchemaTransform
- Anthropic::SearchResultContent
- Anthropic::ServerTool
- Anthropic::ServerToolUsage
- Anthropic::ServerToolUseContent
- Anthropic::SessionEventStream
- Anthropic::Sessions
- Anthropic::SignatureDelta
- Anthropic::SkillDeleteResponse
- Anthropic::SkillListResponse
- Anthropic::SkillResponse
- Anthropic::SkillVersionDeleteResponse
- Anthropic::SkillVersionListResponse
- Anthropic::SkillVersionResponse
- Anthropic::StainlessHelper
- Anthropic::StopDetails
- Anthropic::StopDetailsConverter
- Anthropic::StreamDelta
- Anthropic::StreamDeltaConverter
- Anthropic::StreamEvent
- Anthropic::StructuredOutputParseError
- Anthropic::SystemPrompt
- Anthropic::TextContent
- Anthropic::TextContentWithCitations
- Anthropic::TextDelta
- Anthropic::TextEditorCodeExecutionCreateResultContent
- Anthropic::TextEditorCodeExecutionStrReplaceResultContent
- Anthropic::TextEditorCodeExecutionToolResultContent
- Anthropic::TextEditorCodeExecutionToolResultErrorContent
- Anthropic::TextEditorCodeExecutionToolResultValue
- Anthropic::TextEditorCodeExecutionToolResultValueConverter
- Anthropic::TextEditorCodeExecutionViewResultContent
- Anthropic::TextEditorTool
- Anthropic::TextEditorTool20250124
- Anthropic::TextEditorTool20250429
- Anthropic::TextEditorToolLegacy
- Anthropic::ThinkingCapability
- Anthropic::ThinkingConfig
- Anthropic::ThinkingContent
- Anthropic::ThinkingDelta
- Anthropic::ThinkingTypes
- Anthropic::TokenCountParams
- Anthropic::TokenCountResponse
- Anthropic::Tool
- Anthropic::ToolAdditionContent
- Anthropic::ToolCaller
- Anthropic::ToolCallerConverter
- Anthropic::ToolChangeMCPToolReference
- Anthropic::ToolChangeMCPToolsetReference
- Anthropic::ToolChangeReference
- Anthropic::ToolChangeReferenceConverter
- Anthropic::ToolChangeToolReference
- Anthropic::ToolChoice
- Anthropic::ToolChoiceAny
- Anthropic::ToolChoiceAuto
- Anthropic::ToolChoiceNone
- Anthropic::ToolChoiceTool
- Anthropic::ToolDefinition
- Anthropic::ToolDispatch
- Anthropic::ToolReferenceContent
- Anthropic::ToolRemovalContent
- Anthropic::ToolResultBlockContent
- Anthropic::ToolResultBlockContentArrayConverter
- Anthropic::ToolResultBlockContentConverter
- Anthropic::ToolResultContent
- Anthropic::ToolResultValueConverter
- Anthropic::ToolRunner
- Anthropic::ToolSearchBM25Tool
- Anthropic::ToolSearchRegexTool
- Anthropic::ToolSearchToolResultContent
- Anthropic::ToolSearchToolResultErrorContent
- Anthropic::ToolSearchToolResultValue
- Anthropic::ToolSearchToolResultValueConverter
- Anthropic::ToolSearchToolSearchResultContent
- Anthropic::ToolUseContent
- Anthropic::TypedOutputSchema(T)
- Anthropic::TypedTool(T)
- Anthropic::URLImageSource
- Anthropic::URLPDFSource
- Anthropic::UnprocessableEntityError
- Anthropic::UnwrapWebhookEvent
- Anthropic::Usage
- Anthropic::UserLocation
- Anthropic::WebFetchTool
- Anthropic::WebFetchTool20260209
- Anthropic::WebFetchTool20260309
- Anthropic::WebFetchTool20260318
- Anthropic::WebFetchToolResultContent
- Anthropic::WebSearchResult
- Anthropic::WebSearchTool
- Anthropic::WebSearchTool20260209
- Anthropic::WebSearchTool20260318
- Anthropic::WebSearchToolResultContent