> ## 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.

# Cognis

> Build LLM agents in Rust without the duct tape. Typed Runnables, an agent loop, a stateful graph engine, and production-grade RAG — all in one workspace.

<div className="flex flex-wrap gap-2 my-6">
  <a href="https://github.com/0xvasanth/cognis">
    <img src="https://img.shields.io/github/stars/0xvasanth/cognis?style=social" alt="GitHub stars" />
  </a>

  <a href="https://crates.io/crates/cognis">
    <img src="https://img.shields.io/crates/v/cognis?label=cognis&color=D97706" alt="crates.io" />
  </a>

  <a href="https://docs.rs/cognis">
    <img src="https://img.shields.io/docsrs/cognis" alt="docs.rs" />
  </a>

  <img src="https://img.shields.io/badge/rust-1.75%2B-orange" alt="Rust 1.75+" />

  <img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license" />

  <a href="https://github.com/0xvasanth/cognis/actions">
    <img src="https://img.shields.io/github/actions/workflow/status/0xvasanth/cognis/ci.yml?branch=main" alt="CI" />
  </a>
</div>

# Build LLM agents in Rust without the duct tape.

Typed `Runnable<I, O>` flows from your prompt to your parsed struct. Tool schemas are checked at compile time. Memory, retries, fallbacks, rate limits, prompt caching, evals — all in the box. **Six providers behind one client. Six vector stores behind one trait. One umbrella crate.**

```rust theme={null}
use std::sync::Arc;
use cognis::prelude::*;
use cognis::{AgentBuilder, Calculator, Client};

#[tokio::main]
async fn main() -> Result<()> {
    let mut agent = AgentBuilder::new()
        .with_llm(Client::from_env()?)
        .with_tool(Arc::new(Calculator::new()))
        .with_system_prompt("Use the calculator for arithmetic.")
        .build()?;

    let resp = agent.run(Message::human("What is 23 * 17 + 4?")).await?;
    println!("{}", resp.content);
    Ok(())
}
```

A real, working tool-calling agent in 11 lines. Swap `COGNIS_PROVIDER` between `openai`, `anthropic`, `google`, `ollama`, `azure`, or `openrouter` — same code.

## Real apps you can ship today

<CardGroup cols={3}>
  <Card title="Research assistant" icon="magnifying-glass" href="/patterns/research-assistant">
    Planner → researcher (with web search) → writer. Sequential multi-agent in 80 lines.
  </Card>

  <Card title="Code Q&A over a repo" icon="code" href="/patterns/code-qa">
    Walk a Rust repo, embed code chunks, answer questions with file:line citations.
  </Card>

  <Card title="Streaming UI backend" icon="signal" href="/patterns/streaming-ui">
    `axum` SSE endpoint streaming agent tokens, tool starts, and tool results to the browser.
  </Card>
</CardGroup>

Five more in the [Patterns gallery](/patterns/research-assistant) — multi-agent debate, long-context summarization, HITL approval, stateful chat with memory, and a fully local Ollama setup.

## What you can build

<CardGroup cols={2}>
  <Card title="Tool-calling agents" icon="robot">
    A model with tools, memory, and a loop that knows when to stop. Add middleware for retry, fallback, rate limits, PII redaction, and human approval.
  </Card>

  <Card title="Multi-agent systems" icon="people-arrows">
    Sequential pipelines, supervisor routers, parallel-vote ensembles, round-robin load balancing, hierarchical trees. Or wire your own `HandoffStrategy`.
  </Card>

  <Card title="RAG pipelines" icon="database">
    Documents → splitters → embeddings → vector store → retriever → prompt. Six vector store backends. An indexing pipeline that only re-embeds what changed.
  </Card>

  <Card title="Stateful graphs" icon="diagram-project">
    `Graph<S>` with typed state and per-field reducers. Time-travel through checkpoints, pause for human approval, fan out in parallel — all type-checked at compile time.
  </Card>

  <Card title="Production observability" icon="chart-line">
    LLM-aware tracing into Langfuse out of the box. Token counts, USD cost per run, prompt versioning, evaluation scores — one feature flag.
  </Card>

  <Card title="Local-first apps" icon="laptop">
    Run entirely against Ollama with no API keys. Swap to a hosted provider later — the agent code doesn't change.
  </Card>
</CardGroup>

## Why Rust

* **Compile-time guarantees.** Tool schemas, message types, and graph state transitions are checked before your code runs. No "unknown variant at runtime" surprises.
* **Pay only for what you use.** Every external integration is feature-gated. Your binary doesn't include OpenAI code if you only use Anthropic.
* **Async-native.** Built on `tokio` and `futures::Stream`. Streaming tokens, events, and graph state updates uses one consistent API.
* **One umbrella, full stack.** `cognis` re-exports the foundation, LLM, RAG, and graph layers. Most apps need a single `use cognis::prelude::*;`.

## What's not here yet

Honest about the gaps so you can decide whether to wait or contribute:

* **LangSmith and OpenTelemetry exporters** — Langfuse is the supported production backend; OTel + others are on the roadmap. The `TraceExporter` trait is one async method, so building your own is fast.
* **A hosted gateway / managed deployment** — bring your own infra. Production patterns are documented; managed runtime isn't shipping today.
* **A wider provider matrix** — six are battle-tested; others (Groq, Together, Bedrock direct, Cohere) are open issues looking for owners.

[See the full roadmap →](https://github.com/0xvasanth/cognis/issues)

## Where to next

<CardGroup cols={2}>
  <Card title="Quickstart" icon="bolt" href="/get-started/quickstart">
    From zero to a running agent in five minutes.
  </Card>

  <Card title="Installation" icon="download" href="/get-started/installation">
    Workspace setup, feature flags, secrets handling.
  </Card>

  <Card title="Core ideas" icon="lightbulb" href="/core-ideas/runnables">
    Mental models for `Runnable`, graphs, and the agent loop.
  </Card>

  <Card title="Patterns" icon="grid" href="/patterns/research-assistant">
    Real applications you can copy: research assistants, code Q\&A, multi-agent debate, more.
  </Card>

  <Card title="API reference" icon="book" href="/reference/api/cognis">
    Per-crate rustdoc-friendly summaries. Cross-linked to docs.rs.
  </Card>

  <Card title="Contribute" icon="code-merge" href="/contribute/ways-to-contribute">
    Bugs, features, integrations, docs — every contribution lane.
  </Card>
</CardGroup>

<Card title="Like what you see? Star the repo." icon="star" href="https://github.com/0xvasanth/cognis">
  Cognis is open source under MIT. Stars help other Rust devs find it.
</Card>
