---
title: Rust
description: 'The anyrow crate: every endpoint, typed, async on Tokio, with a blocking client too.'
url: https://anyrow.ai/docs/sdks/rust
canonical_url: https://anyrow.ai/docs/sdks/rust
last_updated: '2026-10-16'
---

# Rust

The `anyrow` crate has a typed method, request and response for every endpoint. `Client` is
async on Tokio; `SyncClient` blocks, for code without a runtime. It needs Rust 1.75 or later.

## Install

```bash
cargo add anyrow futures-util serde_json tokio --features tokio/full
```

`serde_json` builds request bodies from JSON and `futures-util` reads streams; the crate itself
needs only `anyrow` and Tokio.

## Create a client

```rust
use std::time::Duration;

use anyrow::{Client, ClientConfig};

let anyrow = Client::new(ClientConfig {
    base_url: "https://api.anyrow.ai".to_string(),
    bearer_token: std::env::var("ANYROW_API_KEY").ok(),
    timeout: Duration::from_secs(30),
    ..Default::default()
});
```

The client sends the key as `Authorization: ApiKey <key>`.

## Make a call

An operation's id is its method in snake case, through one accessor per group
(`extract.table.once` is `anyrow.extract().table().once(...)`). Path parameters come first, then
the body, then the options, which hold the query parameters and derive `Default`:

```rust
use anyrow::resources::row::RowListOpts;

let page = anyrow
    .row()
    .list("proj_...", "tbl_...", &RowListOpts { limit: Some(50), ..Default::default() })
    .await?;
println!("{} rows, more: {}", page.rows.len(), page.has_more);
```

Request bodies are types in `anyrow::types`, named after the operation's body
(`CreateProjectsTableRequest` for `table.create`). Build one as a struct, or from JSON:

```rust
let table = anyrow
    .table()
    .create(
        "proj_...",
        &serde_json::from_value(serde_json::json!({
            "name": "Invoices",
            "columns_json": [{ "id": "vendor", "name": "Vendor" }]
        }))?,
        &Default::default(),
    )
    .await?;
```

## Errors

Every call returns `Result<T, anyrow::Error>`. An error from the API is `Error::Api`, with the
status and the raw [error body](/docs/errors); the other variants cover the transport, timeouts
and cancellation:

```rust
use anyrow::Error;

match anyrow.table().get("proj_...", "tbl_...", &Default::default()).await {
    Ok(table) => println!("{}", table.name),
    Err(Error::Api(error)) if error.status() == 403 => println!("the key lacks tables:read"),
    Err(Error::Api(error)) => println!("{}: {}", error.status(), String::from_utf8_lossy(error.body())),
    Err(other) => println!("{other}"),
}
```

## Read every row

```rust
use anyrow::resources::row::RowListOpts;

let mut rows = Vec::new();
let mut opts = RowListOpts { limit: Some(100), ..Default::default() };
loop {
    let page = anyrow.row().list("proj_...", "tbl_...", &opts).await?;
    rows.extend(page.rows);
    match page.next_cursor {
        Some(cursor) => opts.cursor = Some(cursor),
        None => break,
    }
}
```

## Extract a document

```rust
use std::collections::HashMap;

let invoice = std::fs::read_to_string("./invoice.txt")?;
let batch = anyrow
    .extract()
    .table()
    .once(
        "proj_...",
        "tbl_...",
        &HashMap::from([("text".to_string(), invoice)]),
        &Default::default(),
    )
    .await?;
```

## Stream an extraction

The `stream` methods return a `Stream` of server-sent events:

```rust
use std::collections::HashMap;

use futures_util::StreamExt;

let form = HashMap::from([("text".to_string(), "Invoice 42 from Acme".to_string())]);
let mut events = Box::pin(anyrow.extract().table().stream("proj_...", "tbl_...", &form, &Default::default()));
while let Some(event) = events.next().await {
    let event = event?;
    println!("{} {}", event.event, event.data);
}
```

## Verify webhooks

Deliveries follow Standard Webhooks; verify them with the
[`standardwebhooks`](https://crates.io/crates/standardwebhooks) crate as the
[Webhooks guide](/docs/webhooks) describes.
