---
title: Java
description: 'Anyrow for Java: every endpoint, typed, on the JDK''s HTTP client, for Java 17 and later.'
url: https://anyrow.ai/docs/sdks/java
canonical_url: https://anyrow.ai/docs/sdks/java
last_updated: '2026-10-16'
---

# Java

The `ai.anyrow:anyrow` library has a typed method, request and response for every endpoint,
built on `java.net.http.HttpClient` and Jackson. Models are records. It needs Java 17 or later.

## Install

```kotlin title="Gradle"
implementation("ai.anyrow:anyrow:1.0.0")
```

```xml title="Maven"
<dependency>
  <groupId>ai.anyrow</groupId>
  <artifactId>anyrow</artifactId>
  <version>1.0.0</version>
</dependency>
```

## Create a client

```java
import ai.anyrow.AnyrowClient;
import java.time.Duration;

AnyrowClient anyrow = AnyrowClient.builder()
    .baseUrl("https://api.anyrow.ai")
    .apiKey(System.getenv("ANYROW_API_KEY"))
    .timeout(Duration.ofSeconds(30))
    .build();
```

The client sends the key as `Authorization: ApiKey <key>`. Create one client and reuse it.

## Make a call

An operation's id is its method in camel case, through one accessor per group
(`extract.table.once` is `anyrow.extract().table().once(...)`). Path parameters come first, then
the body, then a parameters object named after the method, built with a builder, which holds the
query parameters:

```java
import ai.anyrow.models.RowListParams;

var page = anyrow.row().list("proj_...", "tbl_...", RowListParams.builder().limit(50L).build());
System.out.println(page.rows().size() + " rows, more: " + page.hasMore());
```

Request bodies are records named after the operation's body (`CreateProjectsTableRequest` for
`table.create`).

## Errors

A failed call throws an unchecked `AnyrowException` with the status and the
[error body](/docs/errors); each status has its own subclass:

```java
import ai.anyrow.errors.AnyrowException;
import ai.anyrow.errors.ForbiddenException;

try {
    var table = anyrow.table().get("proj_...", "tbl_...");
} catch (ForbiddenException error) {
    System.out.println("The key lacks tables:read");
} catch (AnyrowException error) {
    System.out.println(error.status() + ": " + error.getMessage());
}
```

## Read every row

```java
var rows = new ArrayList<Map<String, Object>>();
String cursor = null;
do {
    var page = anyrow.row().list("proj_...", "tbl_...",
        RowListParams.builder().limit(100L).cursor(cursor).build());
    rows.addAll(page.rows());
    cursor = page.nextCursor();
} while (cursor != null);
```

## Extract a document

```java
var batch = anyrow.extract().table().once("proj_...", "tbl_...",
    Map.of("text", Files.readString(Path.of("./invoice.txt"))));
System.out.println(batch.status());
```

## Stream an extraction

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

```java
anyrow.extract().table()
    .stream("proj_...", "tbl_...", Map.of("text", "Invoice 42 from Acme"))
    .forEach(event -> System.out.println(event.event() + " " + event.data()));
```

## Verify webhooks

Deliveries follow Standard Webhooks; verify them with the
[`standardwebhooks`](https://github.com/standard-webhooks/standard-webhooks) Java library as the
[Webhooks guide](/docs/webhooks) describes.
