> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dartantic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Start

> Zero to hero; no PhD required.

## Install

```yaml theme={null}
dependencies:
  dartantic_ai: ^VERSION
```

For **Flutter** apps using **Firebase AI Logic** (Gemini through Firebase), also
add [`dartantic_firebase_ai`](https://pub.dev/packages/dartantic_firebase_ai) and
register `firebase-google` / `firebase-vertex` on `Agent.providerFactories` (see
[Providers](/providers#firebase-ai-flutter-add-on)).

## API Keys

Set environment variables for the providers you'll use:

```bash theme={null}
# Native providers
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GEMINI_API_KEY="..."
export MISTRAL_API_KEY="..."

# OpenAI-compatible
export OPENROUTER_API_KEY="..."
export TOGETHER_API_KEY="..."
export COHERE_API_KEY="..."
export XAI_API_KEY="..."

# Ollama runs locally - no key needed
# OpenAI Responses reuses OPENAI_API_KEY
```

Prefer to handle API keys server-side. Take special care to not expose them in
your client code.

See [Providers](/providers) for the complete list.

## Your First Chat

The following shows simple agent usage using the `Agent()` constructor, which
takes a model string.

```dart theme={null}
void main() async {
  // Create an agent with a model string
  final agent = Agent(
    'openai',  // Try 'openai:gpt-4o' or 'gemini:gemini-2.0-flash'
  );

  // Run the agent with a prompt and system message
  final result = await agent.send(
    'Where does "hello world" come from?',
    history: [
      const ChatMessage.system('Be concise, reply with one sentence.'),
    ],
  );
  print(result.output); // Output: one sentence on the origin of "hello world"
}
```

Alternatively, you can use the `Agent.forProvider()` constructor which takes a
provider directly:

```dart theme={null}
void main() async {
  // Create an agent with a provider
  final agent = Agent.forProvider(
    Agent.createProvider('openai'),
  );

  // Run the agent with a prompt and system message
  final result = await agent.send(
    'Where does "hello world" come from?',
    history: [
      const ChatMessage.system('Be concise, reply with one sentence.'),
    ],
  );
  print(result.output); // Output: one sentence on the origin of "hello world"
}
```

## Model Strings

The model string used by `Agent` can be specified in several ways:

* Just the `providerName`, e.g. `openai` → specifies whatever the default chat
  and embeddings models are for that provider
* `providerName:chatModelName`, e.g. `google:gemini-2.0-flash` → specifies a
  provider and model, separated by a **colon**
* `providerName/chatModelName`, e.g. `google/gemini-2.0-flash` → specifies a
  provider and model, separated by a **slash**
* `providerName?chat=chatModelName&embeddings=embeddingsModelName` →
  `openai?chat=gpt-4&embeddings=text-embedding-ada-002` → uses query format

## Providers

A provider is a Dart type like `GoogleProvider` that knows how to expose model
objects. When you pass in a model string, you're really looking up a provider
object and one or more types of model objects for the agent to do its work. All
the providers support a chat model (e.g. `GoogleChatModel`) and several of them
also support an embeddings model (e.g. `GoogleEmbeddingsModel`).

You can see the list of [Supported Providers](/providers) that Dartantic
exposes. And you can build your own [Custom Providers](/custom-providers) if you
like.

## Provider Aliases

Some providers support multiple provider prefixes. The alias can be used where
the provider name is specified, e.g. `gemini:gemini-2.0-flash` →
`google:gemini-2.0-flash`. Here's where you can see the list of aliases for each
of the [Supported Providers](/providers).

## What's Next?

Now that you've tasted power, dive deeper:

* [Examples](https://github.com/csells/dartantic_ai/tree/main/packages/dartantic_ai/example/bin) - Pretty much all the things
* [Providers](/providers) - Pick your AI overlord
* [Tools](/tool-calling) - Give your AI superpowers
