dartantic_ai 0.9.3
dartantic_ai: ^0.9.3 copied to clipboard
A Dart library for easily interacting with LLMs in a typed manner.
Welcome to Dartantic! #
The dartantic_ai package provides an agent framework inspired by pydantic-ai and designed to make building client and server-side apps in Dart with generative AI easier and more fun!
π― Goals #
- π€ Agentic behavior with multi-step tool calling: Let your AI agents autonomously chain tool calls together to solve complex problems without human intervention.
- Multi-Provider Support: Work seamlessly with OpenAI, Google Gemini, OpenRouter, and more
- Type Safety: Leverage Dart's strong typing with automatic JSON schema generation
- Developer Experience: Simple, intuitive APIs that feel natural in Dart
- Production Ready: Built-in logging, error handling, and provider capabilities detection
- Extensible: Easy to add custom providers and tools
π Quick Start #
import 'package:dartantic_ai/dartantic_ai.dart';
void main() async {
// Create an agent with your preferred provider
final agent = Agent(
'openai', // or 'gemini', 'openrouter', etc.
systemPrompt: 'You are a helpful assistant.',
);
// Generate text
final result = await agent.run('Explain quantum computing in simple terms');
print(result.output);
// Use typed outputs
final location = await agent.runFor<TownAndCountry>(
'The windy city in the US',
outputSchema: TownAndCountry.schemaMap.toSchema(),
outputFromJson: TownAndCountry.fromJson,
);
print('${location.output.town}, ${location.output.country}');
}
β¨ Key Features #
- π Streaming Output - Real-time response generation
- π οΈ Typed Tool Calling - Type-safe function definitions and execution
- π Multi-media Input - Process text, images, and files
- π§ Embeddings - Vector generation and semantic search
- π MCP Support - Model Context Protocol server integration
- ποΈ Provider Switching - Seamlessly switch between AI providers mid-conversation
π Documentation #
π Read the full documentation
The documentation includes:
- Getting Started Guide - Installation and basic usage
- Core Features - JSON output, typed responses, and DotPrompt support
- Advanced Features - Tool calling, agentic behavior, streaming, and embeddings
- Integration - Logging, model discovery, MCP servers, and custom providers
π¦ Installation #
Add to your pubspec.yaml
:
dependencies:
dartantic_ai: ^latest_version
Then run:
dart pub get
π€ Contributing & Community #
We welcome contributions! Feature requests, bug reports and PRs are welcome on the dartantic_ai github site.
Want to chat about Dartantic? Then drop by the Discussions forum.
π License #
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ for the Dart & Flutter community