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

# Quickstart

> Install anyagent and run one turn against a real agent.

## Requirements

* Rust 1.88 or newer (edition 2024)
* A [supported agent](/agents) installed and logged in
* A Tokio runtime

## Install

```bash theme={"theme":"vesper"}
cargo add anyagent futures tokio --features tokio/rt-multi-thread,tokio/macros
```

That adds these to `Cargo.toml`:

```toml Cargo.toml theme={"theme":"vesper"}
[dependencies]
anyagent = "0.0.1"
futures = "0.3"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
```

## One turn

```rust src/main.rs theme={"theme":"vesper"}
use anyagent::{EventKind, Runtime, SessionOptions};
use futures::StreamExt;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let runtime = Runtime::new();

    // 1. Find what's on this machine, then insist on one of them.
    let report = runtime.discover().await;
    let agent = report.require("claude")?;

    // 2. Open a session: a command handle and an event stream.
    let (session, mut events) = runtime.open(agent, SessionOptions::in_dir(".")).await?;

    // 3. Prompt, then drain events until the turn ends.
    session.prompt("explain this repo").await?;
    while let Some(event) = events.next().await {
        match event?.kind {
            EventKind::TextDelta { text, .. } => print!("{text}"),
            EventKind::TurnEnded { .. } => break,
            _ => {}
        }
    }

    session.close().await?;
    Ok(())
}
```

What just happened:

```text theme={"theme":"vesper"}
discover()  →  report.agents (installed)  +  report.missing (with install hints)
open()      →  spawns the agent, handshakes, returns (Session, Events)
prompt()    →  starts a turn
Events      →  TurnStarted, TextDelta…, TurnEnded
close()     →  ends the process
```

<Note>
  `Session` is cheap to clone and every clone talks to the same engine task, so
  you can prompt from one task while another drains `Events`.
</Note>

## Run the examples

The repo's [`examples/`](https://github.com/spotta85/anyagent-rs/tree/main/examples)
folder has three small programs that run against the agents on your machine:

```bash theme={"theme":"vesper"}
cargo run --example chat -- claude      # prompt, stream, answer, steer
cargo run --example sessions -- claude  # several sessions at once, then resume
cargo run --example probe               # what's installed, logged in, and capable
```

## Next

<CardGroup cols={2}>
  <Card title="Core API" icon="code" href="/core-api">
    The full public interface on one page.
  </Card>

  <Card title="Building an app" icon="window" href="/building-an-app">
    Threads, streaming, permissions, model picker, persistence.
  </Card>
</CardGroup>
