Supported Providers
Supported Providers
Dartantic currently supports the following AI model providers, but more are coming!
Drop me a line if you'd like to see a provider added or even better, if you'd like to contribute one!
Provider Capabilities
Provider | Default Model | Default Embedding Model | Capabilities | Notes |
---|---|---|---|---|
OpenAI | gpt-4o | text-embedding-3-small | Text Generation, Embeddings, Chat, File Uploads, Tools | Full feature support |
OpenRouter | gpt-4o | N/A | Text Generation, Chat, File Uploads, Tools | No embedding support |
Google Gemini | gemini-2.0-flash | text-embedding-004 | Text Generation, Embeddings, Chat, File Uploads, Tools | Uses native Gemini API |
Gemini (OpenAI-compat) | gemini-2.0-flash | text-embedding-004 | Text Generation, Embeddings, Chat, File Uploads, Tools | Uses OpenAI-compatible Gemini endpoint |
Provider Configuration
Provider | Provider Prefix | Aliases | API Key | Provider Type |
---|---|---|---|---|
OpenAI | openai | - | OPENAI_API_KEY | OpenAiProvider |
OpenRouter | openrouter | - | OPENROUTER_API_KEY | OpenAiProvider |
Google Gemini | google | gemini , googleai , google-gla | GEMINI_API_KEY | GeminiProvider |
Gemini (OpenAI-compatible) | gemini-compat | - | GEMINI_API_KEY | OpenAiProvider |
API Key Environment Variables
If you don't provide an API key when creating an agent, dartantic_ai will look for API keys in the appropriate environment.
Example using Agent.environment
The Agent
class provides an environment
property that you can use to pass
API keys along to the provider. This method is particularly suitable for setting
API keys for multiple providers at once and for platforms that don't
have their own environments, like Flutter Web.
void main() async {
// Set API keys for both OpenAI and Gemini using environment variables
Agent.environment.addAll({
'OPENAI_API_KEY': 'your-openai-api-key-here',
'GEMINI_API_KEY': 'your-gemini-api-key-here',
});
// Create and test OpenAI agent without explicitly passing an apiKey
final openAiAgent = Agent('openai', systemPrompt: 'Be concise.');
final openAiResult = await openAiAgent.run('Why is the sky blue?');
print('# OpenAI Agent');
print(openAiResult.output);
// Create and test Gemini agent without explicitly passing an apiKey
final geminiAgent = Agent('gemini', systemPrompt: 'Be concise.');
final geminiResult = await geminiAgent.run('Why is the sea salty?');
print('# Gemini Agent');
print(geminiResult.output);
}
For a runnable example, take a look at agent_env.dart.