Skip to main content

Migrating from 2.x to 3.0.0

Thinking API Change

Thinking is also stored as ThinkingPart in the consolidated message for history.

Schema API Change

The JsonSchema class has been replaced with Schema:
Key changes:
  • JsonSchema.create({...}) becomes Schema.fromMap({...})
  • JsonSchema.object({...}) becomes S.object(properties: {...})
  • JsonSchema.string(...) becomes S.string(...)
  • JsonSchema.integer(...) becomes S.integer(...)
  • No need to import json_schema package; Schema is re-exported from dartantic_ai

Migrating from 1.x to 2.0.0

Exposing dartantic_interface directly from dartantic_ai

It’s no longer necessary to manually include the dartantic_interface package.

Provider Factory Registry

Provider lookup has been moved from the Providers class to Agent static methods. Providers are now created via factory functions not cached instances.

Moved OpenAI-compat providers to example (except OpenRouter)

Removed the following intrinsic providers from dartantic to the openai_compat.dart example:
  • google-openai
  • together
  • ollama-openai
The openrouter OpenAI-compatible provider remains as an intrinsic provider.

Simplified Thinking API

Extended thinking (chain-of-thought reasoning) is now a first-class feature in Dartantic with a simplified, unified API across all providers that support thinking:
  • Provider-specific fine-tuning options remain for advanced use cases:
    • GoogleChatModelOptions.thinkingBudgetTokens
    • AnthropicChatOptions.thinkingBudgetTokens
    • OpenAIResponsesChatModelOptions.reasoningSummary

Removed ProviderCaps

The ProviderCaps type was removed from the provider implementation and moved to a helper function in the tests.

Migrating from 0.9.7 to 1.0.0

This release went through a major refactoring to support many more providers for both chat and embeddings, as well as to support more features. The API is different in a lot of tiny ways, but the core concepts remain largely the same. This is a list of changes (some of them breaking) to help you migrate. And as long as this list is, I’m sure I’ve missed some. If you find something that’s not here, please let me know!

Dynamic => Static Provider factories

Provider access has moved to Agent static methods:
If you’d like to extend the list of providers dynamically at runtime, you can use the providerFactories map on the Agent class:

Agent.runXxx => Agent.sendXxx

The Agent.runXxx methods have been renamed for consistency with chat models and the new Chat class:
Also, when you’re sending a prompt to the agent, instead of passing a list of messages via the messages parameter, you can pass it via the history parameter:
The subtle difference is that the history is a list of previous messages before the prompt + optional attachments, which forms the new message. Love it or don’t, but it made sense to me at the time…

Agent.provider => Agent.forProvider

The Agent.provider constructor has been renamed to Agent.forProvider for clarity:

Message => ChatMessage

The Message type has been renamed to ChatMessage for consistency with chat models:

toSchema => JsonSchema.create

The toSchema method has been dropped in favor of the built-in JsonSchema.create method for simplicity:

systemPrompt + Message.system() => ChatMessage.system()

The systemPrompt parameter has been removed from Agent and model constructors. It was confusing to have both a system prompt and a system message, so I’ve simplified the implementation to use just an optional ChatMessage.system() instead. In practice, you’ll want to keep the system message in the history anyway, so think of this as a “pit of success” thing:

Agent chat and streaming

The agent now streams new messages as they’re created along with the output:
If you’d prefer not to collect and track the message history manually, you can use the Chat class to collect messages for you:

DataPart.file(File) => DataPart.fromFile(XFile)

The DataPart.file constructor has been replaced with DataPart.fromFile to support cross-platform file handling, i.e. the web:

Model String Format Enhanced

The model string format has been enhanced to support chat, embeddings and other model names using custom relative URI. This was important to be able to specify the model for chat and embeddings separately:

Agent.embedXxx

The agent gets new Agent.embedXxx methods for creating embeddings for documents and queries:
Also, the cosineSimilarity method has been moved to the EmbeddingsModel.

Automatic Retry

The agent now supports automatic retry for rate limits and failures:

Agent<TOutput>(outputSchema) => sendForXxx<TOutput>(outputSchema)

Instead of putting the output schema on the Agent class, it’s now on the sendForXxx method:
This allows you to be more flexible from message to message.

AgentResponse to ChatResult<MyType>

The AgentResponse type has been renamed to ChatResult.

DotPrompt Support Removed

The dependency on the dotprompt_dart package has been removed from dartantic_ai. However, you can still use the DotPrompt class to parse .prompt files:

Tool Calls with Typed Output

The Agent.sendForXxx method now supports specifying the output type of the tool call:
Unfortunately, not all providers support this feature. You can check the provider’s capabilities to see if it does.

ChatMessage Part Helpers

The ChatMessage class has been enhanced with helpers for extracting specific types of parts from a list:

Usage Tracking

The agent now supports usage tracking:

Logging

The agent now supports logging:

Migrating from 0.9.6 to 0.9.7

Breaking Change: DataPart.file → DataPart.stream

The DataPart.file constructor has been removed and replaced with DataPart.stream for file and image attachments. This change was made to enable compatibility with web and WASM platforms, where direct file access is not available.

What you need to do

  • Replace all usages of DataPart.file(File(...)) with await DataPart.stream(file.openRead(), name: file.path).
  • Always provide a name argument for best results (especially for web/WASM).

Before (0.9.6 and earlier)

After (0.9.7 and later)

Why?

  • This approach works on all Dart platforms, including web and WASM, by using streams instead of direct file APIs.
  • It also makes it easier to support file uploads from sources other than the local filesystem.