anthropic_sdk_dart 5.0.0
anthropic_sdk_dart: ^5.0.0 copied to clipboard
Dart client for the Anthropic API. Provides type-safe access to Claude models with streaming, tool use, and batch processing support.
5.0.0 #
Caution
This release has breaking changes. See the Migration Guide for upgrade instructions.
Syncs to the latest Anthropic OpenAPI spec (cross-checked field-for-field against anthropic-sdk-python). Adds the new code_execution_20260521 code-execution tool version — now the default for both the GA BuiltInTool.codeExecution(...) and the beta CodeExecutionTool — plus the fallback refusal trigger (FallbackBlock.trigger, a new FallbackRefusalTrigger that explains why a model handed over at a fallback hop) and the session.updated webhook event (WebhookSessionUpdatedEventData). The breaking surface is small and won't affect most users: FallbackBlock/FallbackInputBlock are normally consumed via fromJson, so pure-deserialization callers are unaffected; the only behavioral change is the code-execution default version, which you can pin by passing type explicitly. See the Migration Guide for details.
4.2.0 #
Adds scheduled deployments for Managed Agents — run an agent session on a cron schedule (or on demand) through the new client.deployments and client.deploymentRuns beta resources, with each firing producing a deployment run. Also introduces the beta Fallback API for Messages — supply a fallbacks chain to automatically re-run a refused request on another model (e.g. Fable 5) or retry manually with a refusal credit token — plus environment-variable vault credentials for Managed Agents. Also fixes a latent runtime crash where passing an untyped empty literal (e.g. UpdateSessionParams(vaultIds: [])) to the Update*Params family threw a TypeError.
4.1.0 #
Completes field-level parity for the advisor and computer-use built-in beta tools, whose parameters were previously dropped on the Dart side and silently lost on serialization. AdvisorTool now carries allowedCallers, deferLoading, and strict; ComputerUseTool adds those plus inputExamples (all versions) and enableZoom (only on the computer_20251124 tool version). See the Anthropic API release notes for the underlying tool updates.
4.0.0 #
Caution
This release has breaking changes. See the Migration Guide for upgrade instructions.
Refreshes the package to the latest Anthropic OpenAPI spec for the Claude Opus 4.8 release. Adds mid-conversation system messages — the new mid_conv_system content block (via InputContentBlock.midConversationSystem) updates system instructions inside the messages array without a separate user turn or disrupting prompt caching — plus the spec's new system message role (MessageRole.system, InputMessage.system(...) / systemBlocks(...)), an outputTokensDetails reasoning-token breakdown on Usage/MessageDeltaUsage, and a nullable stopReason on advisor results. The breaking surface is very small and won't affect most users: the only breaks are one new variant on the exported sealed union InputContentBlock and one new value (system) on the MessageRole enum, which affect only code that switches over those types exhaustively without a wildcard or Unknown*/default branch. Pure-deserialization consumers are unaffected.
3.0.0 #
Caution
This release has breaking changes. See the Migration Guide for upgrade instructions.
Completes the four-part Anthropic spec refresh and layers on several beta capabilities: prompt-cache diagnostics (pass DiagnosticsParam.previousMessageId and read Message.diagnostics?.cacheMissReason to learn why a cache prefix diverged), full request- and response-side search-result citations for grounding answers in your own RAG content, multiagent orchestration with outcome evaluations and rubrics, Session Threads (CRUD + streaming), inbound webhook event parsing, and MCP-OAuth credential validation. Also tolerates missing/null signature on streamed ThinkingBlocks from Anthropic-compatible servers (e.g. MiniMax). Breaking: the surface is small and mostly forward-compatibility hardening — new variants were added to the exported sealed unions Citation, InputContentBlock, SessionEvent, and EventParams, so only code with exhaustive switch statements that lack a wildcard/Unknown* branch needs updating; additionally UserProfile.relationship is now a required constructor parameter. Pure-deserialization consumers are unaffected.
- BREAKING FEAT: Cache diagnostics, session & skill updates (#236). (6d1d488f)
- BREAKING FEAT: Request-side search_result blocks & per-citation locations (#235). (1f10a79f)
- BREAKING FEAT: Support search_result_location citations and add Unknown fallback (#233). (68e0f797)
- BREAKING FEAT: Add multiagent orchestration, outcome evaluations & rubrics (#230). (d7ac4376)
- BREAKING FEAT: Spec refresh, relationship + thread IDs (#223). (3c6a4bdc)
- FEAT: Add webhook events & credential validation (#231). (075005a6)
- FEAT: Add Session Threads (CRUD + streaming) (#224). (5367e35b)
- FIX: Tolerate missing/null signature on ThinkingBlock.fromJson (#226). (9e17743a)
- CHORE: Fix use_null_aware_elements lint flagged by Dart 3.12 (#232). (31ac5efc)
2.2.0 #
Adds the Memory Stores beta API — 14 new endpoints exposed under client.memoryStores with child accessors for memories and memory versions. Memory Stores let you persist named memories that can be mounted into agent sessions, with append-only versioning, content-SHA preconditions, view modes (basic/full), and per-version redaction. Surfaces the full data model (MemoryStore, Memory, MemoryVersion, sealed MemoryListItem/MemoryPrecondition, ManagedAgentActor), three new enums, patch-style update params with null-as-delete metadata semantics, and three memory-specific error classes. SessionResource is extended with a new memory_store variant for mounting stores into agent sessions.
2.1.0 #
Adds support for Claude Opus 4.7 and refreshes the package to the latest Anthropic OpenAPI spec. Introduces the User Profiles beta API — 5 endpoints exposed as client.userProfiles for registering end-user profiles with metadata, per-feature trust grants, and short-lived enrollment URLs. Also extends EffortLevel with xhigh, adds TokenTaskBudget and OutputConfig.taskBudget for client-side compaction budgets, wires optional encrypted_content through compaction blocks, and adds MessageCreateRequest.userProfileId for end-user profile routing.
2.0.0 #
Caution
This release has breaking changes. See the Migration Guide for upgrade instructions.
Adds the beta advisor tool for pairing a faster executor model with a stronger advisor model in a single request, plus MCPToolUseBlock/MCPToolResultBlock content types for mid-generation MCP tool calls. All examples migrate from deprecated claude-sonnet-4-20250514 to claude-sonnet-4-6 ahead of the June 15, 2026 end-of-life. Breaking: six Session fields moved from nullable to required non-nullable in the constructor — direct instantiation requires updates.
1.5.0 #
Adds full support for the Managed Agents API (beta) with 33 endpoints across agents, sessions, vaults, and credentials — including SSE streaming for session events. Also adds structured refusal details (RefusalStopDetails, RefusalCategory) to messages and deltas when stopReason is refusal, and session-scoped file filtering via FileScope and scopeId.
1.4.2 #
Adds an extra overflow field to InputSchema for passing additional JSON Schema keywords (like additionalProperties: false) that the Anthropic API now requires on object-type tool input schemas. All examples and integration tests have been updated accordingly.
1.4.1 #
1.4.0 #
Aligns with the latest Anthropic OpenAPI spec, adding model capabilities (ModelCapabilities, CapabilitySupport), thinking display modes (ThinkingDisplayMode), and WebFetchTool v20260309 with cache bypass control. Also standardizes equality helper locations and overhauls documentation with llms.txt ecosystem files.
1.3.2 #
1.3.1 #
1.3.0 #
This release adds inline streaming error detection and top-level cache control support for request parameters.
1.2.1 #
1.2.0 #
Added baseUrl and defaultHeaders parameters to withApiKey constructors, fixed WebSearchToolResultBlock.fromJson crash, and improved hashCode for list fields.
1.1.0 #
Added withApiKey convenience constructors for simplified client initialization and convenience methods for common API patterns like single-message responses and streaming text.
1.0.0 #
Caution
This release has breaking changes. See the Migration Guide for upgrade instructions.
TL;DR: Complete reimplementation with a new architecture, minimal dependencies, resource-based API, and improved developer experience. Hand-crafted models (no code generation), interceptor-driven architecture, comprehensive error handling, full Anthropic API coverage, and alignment with the latest Anthropic OpenAPI (2026-02-19).
What's new #
- Resource-based API organization:
client.messages— Message creation, streaming, token countingclient.messages.batches— Batch message processingclient.models— Model listing and retrievalclient.files— File upload/managementclient.skills— Custom skills management
- Architecture:
- Interceptor chain (Auth → Logging → Error → Transport with Retry wrapper).
- Authentication: API key or custom via
AuthProviderinterface. - Retry with exponential backoff + jitter (only for idempotent methods on 429, 5xx, timeouts).
- Abortable requests via
abortTriggerparameter. - SSE streaming parser for real-time responses.
- Central
AnthropicConfig(timeouts, retry policy, log level, baseUrl, auth).
- Hand-crafted models:
- No code generation dependencies (no freezed, json_serializable).
- Minimal runtime dependencies (
http,logging,metaonly). - Immutable models with
copyWithusing sentinel pattern. - Full type safety with sealed exception hierarchy.
- Improved DX:
- Simplified message creation (e.g.,
InputMessage.user(),InputMessage.assistant()). - Explicit streaming methods (
createStream()vscreate()). - Response helpers (
.text,.hasToolUse,.toolUseBlocks,.thinkingBlocks). - Rich logging with field redaction for sensitive data.
- Simplified message creation (e.g.,
- Full API coverage:
- Messages with tool calling, vision, documents, and citations.
- Extended thinking with budget control.
- Built-in tools (web search, bash, text editor, computer use, code execution, MCP).
- Message batches with JSONL results streaming.
- Files and Skills APIs (Beta).
Breaking Changes #
- Resource-based API: Methods reorganized under strongly-typed resources:
client.createMessage()→client.messages.create()client.createMessageStream()→client.messages.createStream()client.countMessageTokens()→client.messages.countTokens()client.createMessageBatch()→client.messages.batches.create()client.listMessageBatches()→client.messages.batches.list()client.listModels()→client.models.list()client.retrieveModel()→client.models.retrieve()
- Model class renames:
CreateMessageRequest→MessageCreateRequestMessage→InputMessageMessageContent.text()→InputMessage.user()/InputMessage.assistant()Block.text()→TextInputBlockBlock.image()→ImageInputBlockBlock.toolResult()→InputContentBlock.toolResult()Model.model(Models.xxx)→ String model ID (e.g.,'claude-sonnet-4-20250514')
- Configuration: New
AnthropicConfigwithAuthProviderpattern:AnthropicClient(apiKey: 'KEY')→AnthropicClient(config: AnthropicConfig(authProvider: ApiKeyProvider('KEY')))- Or use
AnthropicClient.fromEnvironment()to readANTHROPIC_API_KEY.
- Exceptions: Replaced
AnthropicClientExceptionwith typed hierarchy:ApiException,AuthenticationException,RateLimitException,ValidationException,TimeoutException,AbortedException.
- Streaming: Pattern matching replaces
.map()callbacks:event.map(contentBlockDelta: (e) => ...)→if (event is ContentBlockDeltaEvent) ...
- Enum type changes for better type safety:
Skill.source:String→SkillSourceenum (SkillSource.custom,SkillSource.anthropic)Message.role:String→MessageRoleenum (MessageRole.assistant)SkillsResource.list()sourceparameter:String?→SkillSource?
- Tooling API changes for improved type safety:
toolsparameter:List<Map<String, dynamic>>→List<ToolDefinition>toolChoiceparameter:Map<String, dynamic>→ToolChoice
- Session cleanup:
endSession()→close(). - Dependencies: Removed
freezed,json_serializable; now minimal (http,logging,meta).
See MIGRATION.md for step-by-step examples and mapping tables.
Commits #
- BREAKING FEAT: Complete v1.0.0 reimplementation (#5). (a0623960)
- BREAKING FEAT: Add typed ToolDefinition and SkillSource for improved type safety (#19). (48311502)
- FEAT: Add speed controls, new built-in tools, tool governance, and ToolCaller type (#35). (ad3c34c6)
- FEAT: Enhance models with documentation and add examples (#13). (bfd99bc6)
- FIX: Pre-release documentation and test fixes (#42). (2fb37b06)
- REFACTOR: Align client package architecture across SDK packages (#37). (cf741ee1)
- REFACTOR: Align API surface across all SDK packages (#36). (ed969cc7)
- DOCS: Refactors repository URLs to new location. (76835268)
0.3.1 #
- FIX: Add signature_delta support to BlockDelta (fixes #811) (#878). (1d281837)
- FIX: Update tool types and fix analyzer warnings (#876). (17613b1e)
- FEAT: Add citations_delta support to BlockDelta (#880). (4da916bf)
- FEAT: Add beta features support (#874). (28e4a23a)
- FEAT: Add schema enhancements (#873). (424d3225)
- FEAT: Add Models API (#872). (7962a867)
- FEAT: Add get message batch results endpoint (#871). (46fb2a5d)
- FEAT: Add delete message batch endpoint (#870). (6611e175)
- FEAT: Add cancel message batch endpoint (#869). (b7aa8602)
- FEAT: Add list message batches endpoint (#868). (745e369d)
- FEAT: Add token counting API (#858). (b0d61c92)
0.3.0 #
Caution
This release has breaking changes. See the Migration Guide for upgrade instructions.
0.2.1 #
0.2.0+1 #
0.2.0 #
Caution
This release has breaking changes. See the Migration Guide for upgrade instructions.
- FEAT: Add support for Message Batches (#585). (a41270a0)
- FEAT: Add claude-3-5-sonnet-20241022 to model catalog (#583). (0cc59e13)
- BREAKING FEAT: Add support for prompt caching (#587). (79dabaa5)
- BREAKING FEAT: Add computer use support (#586). (36c4a3e3)
- DOCS: Update anthropic_sdk_dart readme. (78b7bccf)
0.1.0 #
0.0.1-dev.1 #
- Bootstrap package.