ai_sdk_dart 1.2.0
ai_sdk_dart: ^1.2.0 copied to clipboard
Core AI SDK for Dart with provider-agnostic model APIs.
1.2.0 #
Errors #
- Provider HTTP failures now surface as a typed
AiApiCallErrorcarrying the provider'smessage/type/code/statusCode(and the raw response body), instead of a rawDioException. TheAiSdkErrorhierarchy was relocated intoai_sdk_providerso all provider packages can throw it;ai_sdk_dart's public surface is unchanged via a re-export shim, and existingimports keep working.
Bug Fixes #
onAbortnow interrupts streaming. Cancelling theCancellationTokenduring astreamTextrun stops the read loop immediately, instead of firing the callback while the underlying stream kept draining to completion.stopWhencan extend the tool loop pastmaxSteps. Custom stop conditions are now the authoritative loop terminator: a higherstepCountIs(...)(or any custom condition) is honored even whenmaxStepsalone would have stopped earlier, matching Vercel AI SDK v6 semantics. A 1000-step safety cap still backstops runaway loops.
Removed (breaking for the unused video API) #
generateVideo,AiNoVideoGeneratedError, the provider registry's video model category, and themockVideoModelV1test helper. No provider ever implementedVideoModelV1(also removed fromai_sdk_provider), so this API could not be exercised. If you referenced any of these symbols, delete the reference — there was no working code path behind them.
Internal #
- Extracted a shared tool-loop run policy (
resolveStopConditions,resolveStepBudget,shouldStopAfterStep) and acompleteIfPendingfan-out helper, de-duplicatinggenerateTextandstreamText. No public API change.
Coverage #
ai_sdk_dartnow has 100% line coverage oflib/.
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.