ai_sdk_dart 1.1.0
ai_sdk_dart: ^1.1.0 copied to clipboard
Core AI SDK for Dart with provider-agnostic model APIs.
1.1.0 #
New APIs #
embedMany()— batch embedding that fans out to the provider'sdoEmbedin configurable chunks, with merged usage stats.wrapEmbeddingModel()— middleware pipeline for embedding models, mirroringwrapLanguageModelfor language models.customProvider()— on-the-fly provider construction from plain model-factory maps without a fullcreateProviderRegistrysetup.onAbortcallback instreamText— fires synchronously when the caller'sCancellationTokenis cancelled, enabling graceful cleanup.timeoutparameter —Duration?timeout added togenerateText,streamText,generateObject,streamObject,embed,embedMany,generateImage,generateSpeech,transcribe,rerank. Wraps each underlying model call withFuture.timeout.smoothStreamdelayInMsoption —smoothStream(delayInMs: 20)adds per-chunk delay;experimentalTransformtype is nowStream<String> Function(Stream<String>)(async), enabling arbitrary async transforms.generateObject/streamObjectpassoutputSchema—LanguageModelV3CallOptions.outputSchemais now set toschema.jsonSchemaso providers that support native structured output (e.g. OpenAIresponse_format: json_schema) use it automatically.
New Error Types #
AiToolCallRepairError— thrown when a tool-call repair attempt fails.AiNoImageGeneratedError— thrown whengenerateImagereceives no image content.AiNoVideoGeneratedError— thrown whengenerateVideoreceives no video content.AiNoSpeechGeneratedError— thrown whengenerateSpeechreceives no speech content.AiNoTranscriptGeneratedError— thrown whentranscribereceives no transcript.AiRetryError— wraps the list of errors from all exhausted retry attempts.AiDownloadError— thrown when an attachment download fails.
Registry Expansion #
createProviderRegistrynow supports 6 model categories: language, embedding, image, speech, transcription, and rerank models (previously language + embedding only).RegistrableProviderexposesimageModelFactory,speechModelFactory,transcriptionModelFactory, andrerankModelFactoryfactories.
Testing Utilities #
MockEmbeddingModelV3— fake embedding model for conformance tests, mirroringMockLanguageModelV2.
Bug Fixes #
pruneMessages— removed duplicate messages that were incorrectly appended in multi-step loops whenmessageswas pre-populated; semantics now match Vercel AI SDK v6.
New Provider Packages #
ai_sdk_azure— Azure OpenAI provider (AzureOpenAIProvider). Language models and embeddings via Azure-hosted deployments; configurableendpoint,apiKey, andapiVersion.ai_sdk_cohere— Cohere provider (cohere). Language models, text embeddings, and reranking (Command R, Command R+, embed-english-v3.0, rerank-english-v3.0).ai_sdk_groq— Groq provider (groq). Ultra-low latency inference for Llama, Mixtral, Gemma, and other Groq-hosted models.ai_sdk_mistral— Mistral AI provider (mistral). Language models and embeddings (Mistral Large, Mistral Small, Codestral, mistral-embed).ai_sdk_ollama— Ollama provider (ollama). Local inference for any model pulled via Ollama; no API key required.
Test Count #
- 562+ tests covering all public APIs, conformance cases, and new features.
1.0.0+1 #
- Improved pubspec descriptions for better pub.dev discoverability.
- Added
example/example.mdwith usage examples and links to runnable apps.
1.0.0 #
First stable release. Package renamed from ai → ai_sdk_dart to avoid conflicts with existing pub.dev packages.
Core APIs #
generateText/streamTextwith full v6 result parity — text, finishReason, usage, steps, toolCalls, toolResults, reasoning, sources, files, providerMetadata, request/response envelopes.generateObject/streamObjectwithOutput.text/object/array/choice/jsonAPI.embed/embedManywithcosineSimilarity.generateImage,generateSpeech,transcribe,rerank.
Agentic Tools #
- Multi-step tool loop with
maxSteps,stopConditions, andprepareStep. - Typed tool definitions (
tool<INPUT, OUTPUT>,dynamicTool,Schema<T>). - Tool choice controls (
ToolChoiceAuto,ToolChoiceRequired,ToolChoiceNone,ToolChoiceSpecific). - Tool approval flow (
needsApproval) andToolLoopAgentfor autonomous agentic loops.
Middleware & Registry #
- Middleware system:
wrapLanguageModel,extractReasoningMiddleware,extractJsonMiddleware,simulateStreamingMiddleware,defaultSettingsMiddleware,addToolInputExamplesMiddleware. createProviderRegistry— resolve models by'provider:modelId'string at runtime.
Streaming #
smoothStream/experimentalTransformstream transform hooks.- Full
fullStreamevent taxonomy — 22 typedStreamTextEventsubtypes. - Lifecycle callbacks:
onFinish,onStepFinish,onChunk,onError,experimentalOnStart,experimentalOnStepStart.
Other #
- Complete
AiSdkErrorsealed class hierarchy. - Utilities:
generateId,createIdGenerator,simulateReadableStream. - 230-test conformance suite covering all public APIs and provider wire formats.
0.2.0 #
- Initial release.
generateText/streamTextwith full v6 result parity (text, finishReason, usage, steps, toolCalls, toolResults, reasoning, sources, files, providerMetadata, request/response envelopes).generateObject/streamObjectwithOutput.text/object/array/choice/jsonAPI.- Multi-step tool loop with
maxSteps,stopWhen, andprepareStep. - Typed tool definitions (
tool<INPUT, OUTPUT>,dynamicTool,Schema<T>). - Tool choice controls (
ToolChoiceAuto,ToolChoiceRequired,ToolChoiceNone,ToolChoiceSpecific). - Tool approval flow (
needsApproval). ToolLoopAgentfor autonomous agentic loops.- Middleware system (
wrapLanguageModel,extractReasoningMiddleware,extractJsonMiddleware,simulateStreamingMiddleware,defaultSettingsMiddleware,addToolInputExamplesMiddleware). embed/embedManywithcosineSimilarity.generateImage,generateSpeech,transcribe,rerankinterfaces.createProviderRegistryfor multi-provider model lookup.smoothStream/experimentalTransformstream transform hooks.- Full
fullStreamevent taxonomy (StreamTextEventhierarchy). - Lifecycle callbacks:
onFinish,onStepFinish,onChunk,onError,experimentalOnStart,experimentalOnStepStart,experimentalOnToolCallStart,experimentalOnToolCallFinish. - Complete error type hierarchy (
AiSdkErrorsubclasses). - Utility functions:
generateId,createIdGenerator,simulateReadableStream.