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

# Quickstart V2 examples

> Eight numbered demos that walk the V2 surface — Runnable, agents, graphs, streaming, checkpoints, multi-agent.

The numbered V2 demos are the fastest way to learn the shape of Cognis end-to-end. Each is a self-contained `.rs` file under [`examples/v2/`](https://github.com/0xvasanth/cognis/tree/main/examples/v2). The LLM-backed demos (02, 03, 04, 06, 07, 08) read `COGNIS_PROVIDER` from the env — set it to `ollama` for local, or any of the other providers. Demos 01 and 05 are pure-Rust offline (no provider needed).

## How to run

```bash theme={null}
COGNIS_PROVIDER=ollama COGNIS_OLLAMA_MODEL=llama3.1 \
  cargo run -p cognis-examples --example 02_five_line_agent
```

## The set

| #  | Name                          | What it shows                                                                        | Source                                                                                          |
| -- | ----------------------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
| 01 | `01_hello_runnable`           | The smallest possible `Runnable<I, O>` impl — what your own chain step looks like.   | [src](https://github.com/0xvasanth/cognis/blob/main/examples/v2/01_hello_runnable.rs)           |
| 02 | `02_five_line_agent`          | An agent in 5 lines: `Client::from_env` → `AgentBuilder::new` → `agent.run`.         | [src](https://github.com/0xvasanth/cognis/blob/main/examples/v2/02_five_line_agent.rs)          |
| 03 | `03_custom_graph`             | Bypass `AgentBuilder` and hand-build the graph yourself, then wrap it as an `Agent`. | [src](https://github.com/0xvasanth/cognis/blob/main/examples/v2/03_custom_graph.rs)             |
| 04 | `04_streaming_chat`           | Token-by-token streaming via `Client::stream` — what wires into a chat UI.           | [src](https://github.com/0xvasanth/cognis/blob/main/examples/v2/04_streaming_chat.rs)           |
| 05 | `05_checkpoint_resume`        | Attach a `Checkpointer`, then time-travel through saved supersteps.                  | [src](https://github.com/0xvasanth/cognis/blob/main/examples/v2/05_checkpoint_resume.rs)        |
| 06 | `06_ollama_tool_calling`      | Calculator tool + arithmetic question — the canonical tool-calling agent loop.       | [src](https://github.com/0xvasanth/cognis/blob/main/examples/v2/06_ollama_tool_calling.rs)      |
| 07 | `07_ollama_structured_output` | `StructuredOutputParser<T>` recovering a typed `Recipe` from free-form LLM text.     | [src](https://github.com/0xvasanth/cognis/blob/main/examples/v2/07_ollama_structured_output.rs) |
| 08 | `08_ollama_multi_agent`       | Sequential planner → executor handoff for a real task.                               | [src](https://github.com/0xvasanth/cognis/blob/main/examples/v2/08_ollama_multi_agent.rs)       |

## Recommended order

Read in number order for the full guided tour. If you're impatient, jump to whichever maps to your use case:

* **Building a chat agent?** → 02, then 06 for tools, then 07 for structured output.
* **Building a graph workflow?** → 01, then 03, then 05 for checkpoints.
* **Building multi-agent?** → 02, then 08.
* **Building a streaming UI?** → 04, then [Patterns → Streaming UI](/patterns/streaming-ui).

## See also

<CardGroup cols={2}>
  <Card title="Quickstart guide" icon="bolt" href="/get-started/quickstart">
    The narrative walkthrough of demo 02.
  </Card>

  <Card title="Examples → Agents" icon="robot" href="/examples/agents">
    More agent patterns beyond the V2 set.
  </Card>

  <Card title="Examples → Graphs" icon="diagram-project" href="/examples/graphs">
    More graph patterns beyond demo 03.
  </Card>

  <Card title="Patterns" icon="grid" href="/patterns/research-assistant">
    Larger applications that combine multiple V2 demos.
  </Card>
</CardGroup>
