anthropic_sdk_dart 2.1.0 copy "anthropic_sdk_dart: ^2.1.0" to clipboard
anthropic_sdk_dart: ^2.1.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.

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.

  • FEAT: Add User Profiles beta API (#193). (c2d74a9f)
  • FEAT: Add Claude Opus 4.7 and refresh OpenAPI spec (#191). (b291f445)

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.

  • BREAKING FEAT: Fix verify gaps and add MCP content blocks (#184). (85177cc3)
  • FEAT: Add advisor tool support (#182). (f5268a38)
  • FEAT: Annotate llms.txt with token counts and tighten agent-facing docs (#181). (a1e82aca)
  • CHORE: Update OpenAPI spec and migrate deprecated model IDs (#183). (e5876e22)

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.

  • FEAT: Add managed agents API support (#180). (edb3d6df)
  • FEAT: Add stop_details, file scope, and refresh spec (#177). (e03084c5)

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.

  • FIX: Add extra field to InputSchema for additionalProperties (#168). (164cad60)

1.4.1 #

Adds README Usage sections for models, files, and skills resources, and adds a strict semver bullet to the package README.

  • DOCS: Add models, files, and skills Usage sections (#156). (d9b683cc)
  • DOCS: Overhaul root README and add semver bullet to all packages (#151). (e6af33dd)

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.

  • FEAT: Align with latest Anthropic OpenAPI spec (#129). (9160bb13)
  • REFACTOR: Standardize equality helpers location across packages (#123). (34086102)
  • DOCS: Overhaul READMEs and add llms.txt ecosystem (#149). (98f11483)

1.3.2 #

Complete McpToolset.toString() to include all fields (authorizationToken, cacheControl) that were previously missing.

  • FIX: Complete toString() and update spec metadata (#103). (7b316954)

1.3.1 #

Fixed verification warnings in generated model classes.

1.3.0 #

This release adds inline streaming error detection and top-level cache control support for request parameters.

  • FEAT: Detect inline streaming errors (#91). (9f0eaf37)
  • FEAT: Add top-level cache control to request params (#86). (e619516e)
  • DOCS: Improve READMEs with badges, sponsor section, and vertex_ai deprecation (#90). (5741f2f3)

1.2.1 #

Internal improvements to build tooling and package publishing configuration.

  • REFACTOR: Migrate API skills to the shared api-toolkit CLI (#74). (923cc83e)
  • CHORE: Add .pubignore to exclude .agents/ and specs/ from publishing (#78). (0ff199bf)

1.2.0 #

Added baseUrl and defaultHeaders parameters to withApiKey constructors, fixed WebSearchToolResultBlock.fromJson crash, and improved hashCode for list fields.

  • FEAT: Add baseUrl and defaultHeaders to withApiKey constructors (#57). (f0dd0caa)
  • FIX: Fix WebSearchToolResultBlock.fromJson crash (#63). (227b44f3)
  • FIX: Use Object.hashAll() for list fields in hashCode (#65). (4b19abd9)
  • REFACTOR: Unify equality_helpers.dart across packages (#67). (ec2897f8)

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.

  • FEAT: Add withApiKey convenience constructors (#56). (b06e3df3)
  • FEAT: Add convenience methods for common API patterns (#55). (68cb17d3)
  • CHORE: Bump googleapis from 15.0.0 to 16.0.0 and Dart SDK to 3.9.0 (#52). (eae130b7)

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 counting
    • client.messages.batches — Batch message processing
    • client.models — Model listing and retrieval
    • client.files — File upload/management
    • client.skills — Custom skills management
  • Architecture:
    • Interceptor chain (Auth → Logging → Error → Transport with Retry wrapper).
    • Authentication: API key or custom via AuthProvider interface.
    • Retry with exponential backoff + jitter (only for idempotent methods on 429, 5xx, timeouts).
    • Abortable requests via abortTrigger parameter.
    • 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, meta only).
    • Immutable models with copyWith using sentinel pattern.
    • Full type safety with sealed exception hierarchy.
  • Improved DX:
    • Simplified message creation (e.g., InputMessage.user(), InputMessage.assistant()).
    • Explicit streaming methods (createStream() vs create()).
    • Response helpers (.text, .hasToolUse, .toolUseBlocks, .thinkingBlocks).
    • Rich logging with field redaction for sensitive data.
  • 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:
    • CreateMessageRequestMessageCreateRequest
    • MessageInputMessage
    • MessageContent.text()InputMessage.user() / InputMessage.assistant()
    • Block.text()TextInputBlock
    • Block.image()ImageInputBlock
    • Block.toolResult()InputContentBlock.toolResult()
    • Model.model(Models.xxx) → String model ID (e.g., 'claude-sonnet-4-20250514')
  • Configuration: New AnthropicConfig with AuthProvider pattern:
    • AnthropicClient(apiKey: 'KEY')AnthropicClient(config: AnthropicConfig(authProvider: ApiKeyProvider('KEY')))
    • Or use AnthropicClient.fromEnvironment() to read ANTHROPIC_API_KEY.
  • Exceptions: Replaced AnthropicClientException with 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: StringSkillSource enum (SkillSource.custom, SkillSource.anthropic)
    • Message.role: StringMessageRole enum (MessageRole.assistant)
    • SkillsResource.list() source parameter: String?SkillSource?
  • Tooling API changes for improved type safety:
    • tools parameter: List<Map<String, dynamic>>List<ToolDefinition>
    • toolChoice parameter: 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 #

0.3.0+1 #

0.3.0 #

Caution

This release has breaking changes. See the Migration Guide for upgrade instructions.

0.2.3 #

0.2.2 #

0.2.1 #

  • FEAT: Update dependencies (requires Dart 3.6.0) (#709). (9e3467f7)
  • REFACTOR: Remove fetch_client dependency in favor of http v1.3.0 (#659). (0e0a685c)
  • FIX: Fix linter issues (#656). (88a79c65)

0.2.0+1 #

  • REFACTOR: Add new lint rules and fix issues (#621). (60b10e00)
  • REFACTOR: Upgrade api clients generator version (#610). (0c8750e8)

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 #

  • FEAT: Implement anthropic_sdk_dart, a Dart client for Anthropic API (#433). (e5412b)

0.0.1-dev.1 #

  • Bootstrap package.
13
likes
160
points
11.8k
downloads

Documentation

Documentation
API reference

Publisher

verified publisherdavidmiguel.com

Weekly Downloads

Dart client for the Anthropic API. Provides type-safe access to Claude models with streaming, tool use, and batch processing support.

Homepage
Repository (GitHub)
View/report issues

Topics

#nlp #gen-ai #llms #anthropic #claude

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

http, logging, meta

More

Packages that depend on anthropic_sdk_dart