Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ node_modules
hs_err_pid*
samples/google-genai/generated_media/
.astro
.snapshots
.snapshots

samples/milvus/volumes
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ Genkit genkit = Genkit.builder()
.addRetriever(FirestoreRetrieverConfig.builder()
.name("my-docs")
.collection("documents")
.embedderName("googleai/text-embedding-004")
.embedderName("googleai/gemini-embedding-001")
.vectorField("embedding")
.contentField("content")
.distanceMeasure(FirestoreRetrieverConfig.DistanceMeasure.COSINE)
Expand Down Expand Up @@ -476,7 +476,7 @@ public class MyFunction implements HttpFunction {

genkit.defineFlow("generatePoem", String.class, String.class, (ctx, topic) -> {
return genkit.generate(GenerateOptions.builder()
.model("googleai/gemini-2.0-flash")
.model("googleai/gemini-2.5-flash")
.prompt("Write a poem about: " + topic)
.build()).getText();
});
Expand Down
4 changes: 4 additions & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export default defineConfig({
{ label: "Weaviate", slug: "plugins/weaviate" },
{ label: "PostgreSQL (pgvector)", slug: "plugins/postgresql" },
{ label: "Pinecone", slug: "plugins/pinecone" },
{ label: "Chroma", slug: "plugins/chroma" },
{ label: "Qdrant", slug: "plugins/qdrant" },
{ label: "Milvus", slug: "plugins/milvus" },
{ label: "MongoDB", slug: "plugins/mongodb" },
],
},
{
Expand Down
100 changes: 98 additions & 2 deletions docs/src/content/docs/agents/session-stores.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Session Stores
description: Persist agent session state with in-memory, file-based, Firestore, DynamoDB, or Cosmos DB session stores.
description: Persist agent session state with in-memory, file-based, Firestore, DynamoDB, Cosmos DB, PostgreSQL, or MongoDB session stores.
---

A `SessionStore<S>` is where a server-managed agent keeps its sessions. Pass one to `.store(...)` when you define an agent to persist snapshots; omit it to run the agent client-managed (stateless). Several implementations ship out of the box, and you can write your own.
Expand All @@ -12,8 +12,10 @@ A `SessionStore<S>` is where a server-managed agent keeps its sessions. Pass one
| `FirestoreSessionStore` | Google Cloud Firestore | Production on Google Cloud (Cloud Run, Firebase Functions) |
| `DynamoDbSessionStore` | Amazon DynamoDB | Production on AWS |
| `CosmosSessionStore` | Azure Cosmos DB | Production on Azure |
| `PostgresSessionStore` | PostgreSQL | Production on any SQL-first stack |
| `MongoSessionStore` | MongoDB | Production on any document-first stack |

If you plan to use `chat.abort()` or the `/abort` HTTP endpoint, pick a store that supports change notifications: `FileSessionStore`, `FirestoreSessionStore`, `DynamoDbSessionStore`, and `CosmosSessionStore` do; `InMemorySessionStore` does not, so `abort()` is a no-op there. See [Sessions](../sessions#aborting-a-turn).
If you plan to use `chat.abort()` or the `/abort` HTTP endpoint, pick a store that supports change notifications: `FileSessionStore`, `FirestoreSessionStore`, `DynamoDbSessionStore`, `CosmosSessionStore`, `PostgresSessionStore`, and `MongoSessionStore` do; `InMemorySessionStore` does not, so `abort()` is a no-op there. See [Sessions](../sessions#aborting-a-turn).

## InMemorySessionStore

Expand Down Expand Up @@ -199,6 +201,100 @@ CosmosSessionStore<Map<String, Object>> store =

The default shard size is 1 MiB, kept under Cosmos DB's 2 MB document-size limit. `CosmosSessionStore` supports `onSnapshotStateChange` (via polling), so `chat.abort()` works.

## PostgresSessionStore

Stores snapshots in PostgreSQL. It lives in the PostgreSQL plugin, so add the dependency:

```xml
<dependency>
<groupId>com.google.genkit</groupId>
<artifactId>genkit-plugin-postgresql</artifactId>
<version>${genkit.version}</version>
</dependency>
```

```java
import com.google.genkit.plugins.postgresql.session.PostgresSessionStore;
import com.google.genkit.plugins.postgresql.session.PostgresSessionStoreOptions;
import org.postgresql.ds.PGSimpleDataSource;

PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUrl("jdbc:postgresql://localhost:5432/genkit");
dataSource.setUser("postgres");
dataSource.setPassword("postgres");

PostgresSessionStore<Map<String, Object>> store =
new PostgresSessionStore<>(dataSource); // uses the default "genkit_sessions" table

Agent<Map<String, Object>> agent = genkit.beta().defineAgent(
AgentConfig.<Map<String, Object>>builder()
.name("myAgent")
.system("You are a helpful assistant.")
.store(store)
.build());
```

All records live in a single table keyed by `(pk, id)` with a JSONB `doc` payload and a `version` column for optimistic concurrency. Create the table ahead of time, or let the store create it on first use:

```java
PostgresSessionStore<Map<String, Object>> store =
new PostgresSessionStore<>(
dataSource,
PostgresSessionStoreOptions.builder()
.tableName("genkit_sessions") // table name (default "genkit_sessions")
.createTableIfNotExists(true) // auto-create the table on first use (default false)
.pollIntervalMs(500) // how often change subscribers are polled (default 2000)
.build());
```

The default shard size is 1 MiB. `PostgresSessionStore` supports `onSnapshotStateChange` (via polling), so `chat.abort()` works.

## MongoSessionStore

Stores snapshots in MongoDB. It lives in the MongoDB plugin, so add the dependency:

```xml
<dependency>
<groupId>com.google.genkit</groupId>
<artifactId>genkit-plugin-mongodb</artifactId>
<version>${genkit.version}</version>
</dependency>
```

```java
import com.google.genkit.plugins.mongodb.session.MongoSessionStore;
import com.google.genkit.plugins.mongodb.session.MongoSessionStoreOptions;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;

MongoClient client = MongoClients.create("mongodb://localhost:27017");

MongoSessionStore<Map<String, Object>> store =
new MongoSessionStore<>(client); // uses database "genkit", collection "genkit_sessions"

Agent<Map<String, Object>> agent = genkit.beta().defineAgent(
AgentConfig.<Map<String, Object>>builder()
.name("myAgent")
.system("You are a helpful assistant.")
.store(store)
.build());
```

All records live in a single collection whose `_id` is `<prefix>::<recordId>`; each document carries a `version` field for optimistic concurrency. The database and collection are created automatically on first write. Tune it with `MongoSessionStoreOptions`:

```java
MongoSessionStore<Map<String, Object>> store =
new MongoSessionStore<>(
client,
MongoSessionStoreOptions.builder()
.databaseName("genkit") // database name (default "genkit")
.collectionName("genkit_sessions") // collection name (default "genkit_sessions")
.pollIntervalMs(500) // how often change subscribers are polled (default 2000)
.build());
```

The default shard size is 1 MiB, kept under MongoDB's 16 MB document-size limit. `MongoSessionStore` supports `onSnapshotStateChange` (via polling), so `chat.abort()` works.

## Writing your own store

Implement `SessionStore<S>` to use any backend — a database, a cache, a cloud object store:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Genkit genkit = Genkit.builder()

ModelResponse response = genkit.generate(
GenerateOptions.builder()
.model("googleai/gemini-2.0-flash")
.model("googleai/gemini-2.5-flash")
.prompt("Tell me a fun fact!")
.build());
```
Expand Down
34 changes: 34 additions & 0 deletions docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,36 @@ The fastest way to build AI features into your Java apps.
</TabItem>
</Tabs>

## Build stateful agents

Define server-managed agents with memory, tools, and multi-agent delegation. Persist conversations in the store of your choice.

```java
import com.google.genkit.agent.AgentConfig;
import com.google.genkit.ai.agent.*;

Agent<Map<String, Object>> assistant = genkit.beta().defineAgent(
AgentConfig.<Map<String, Object>>builder()
.name("assistant")
.system("You are a helpful assistant. Remember what the user tells you.")
.model("googleai/gemini-3-flash")
.store(sessionStore) // persist sessions in Firestore, DynamoDB, Cosmos DB, PostgreSQL, MongoDB, ...
.build());

AgentChat<Map<String, Object>> chat = assistant.chat();
chat.send("My name is Ada Lovelace.");
String reply = chat.send("What is my name?").text(); // "Your name is Ada Lovelace."
```

<CardGrid>
<LinkCard title="Agents Overview" href="/genkit-java/agents/overview/" />
<LinkCard title="Define Agents" href="/genkit-java/agents/define-agents/" />
<LinkCard title="Sessions" href="/genkit-java/agents/sessions/" />
<LinkCard title="Session Stores" href="/genkit-java/agents/session-stores/" />
<LinkCard title="Multi-agent Delegation" href="/genkit-java/agents/multi-agent-delegation/" />
<LinkCard title="Serve over HTTP" href="/genkit-java/agents/serve-over-http/" />
</CardGrid>

## Supported Providers

<CardGrid>
Expand All @@ -238,6 +268,10 @@ The fastest way to build AI features into your Java apps.
<LinkCard title="Weaviate" href="/genkit-java/plugins/weaviate/" />
<LinkCard title="PostgreSQL (pgvector)" href="/genkit-java/plugins/postgresql/" />
<LinkCard title="Pinecone" href="/genkit-java/plugins/pinecone/" />
<LinkCard title="Chroma" href="/genkit-java/plugins/chroma/" />
<LinkCard title="Qdrant" href="/genkit-java/plugins/qdrant/" />
<LinkCard title="Milvus" href="/genkit-java/plugins/milvus/" />
<LinkCard title="MongoDB (Atlas Vector Search)" href="/genkit-java/plugins/mongodb/" />
<LinkCard title="Local Vector Store" href="/genkit-java/plugins/localvec/" />
</CardGrid>

Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ genkit.generate(GenerateOptions.builder()

// Use Gemini
genkit.generate(GenerateOptions.builder()
.model("googleai/gemini-2.0-flash")
.model("googleai/gemini-2.5-flash")
.prompt("Hello!").build());

// Use Claude
Expand Down
21 changes: 11 additions & 10 deletions docs/src/content/docs/plugins/anthropic.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,26 @@ Genkit genkit = Genkit.builder()

ModelResponse response = genkit.generate(
GenerateOptions.builder()
.model("anthropic/claude-sonnet-4-5-20250929")
.model("anthropic/claude-sonnet-5")
.prompt("Tell me about AI")
.build());
```

## Available models

### Claude 4.5 family
### Claude 5 family
- `anthropic/claude-fable-5`
- `anthropic/claude-sonnet-5`

### Claude 4 family
- `anthropic/claude-opus-4-8`
- `anthropic/claude-opus-4-7`
- `anthropic/claude-opus-4-6`
- `anthropic/claude-sonnet-4-6`
- `anthropic/claude-opus-4-5-20251101`
- `anthropic/claude-sonnet-4-5-20250929`
- `anthropic/claude-haiku-4-5-20251001`

### Claude 4 family
- `anthropic/claude-4-*`

### Claude 3 family
- `anthropic/claude-3-opus-*`
- `anthropic/claude-3-sonnet-*`
- `anthropic/claude-3-haiku-*`
- `anthropic/claude-opus-4-1-20250805`

## Features

Expand Down
13 changes: 13 additions & 0 deletions docs/src/content/docs/plugins/aws-bedrock.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ ModelResponse response = genkit.generate(
- **OpenAI** — Via Bedrock marketplace
- And many more...

## Embeddings

Bedrock embedding models (Amazon Titan and Cohere Embed) are available via the `InvokeModel` API:

- `aws-bedrock/amazon.titan-embed-text-v2:0`
- `aws-bedrock/cohere.embed-english-v3`
- `aws-bedrock/cohere.embed-multilingual-v3`

```java
EmbedResponse response =
genkit.embed("aws-bedrock/amazon.titan-embed-text-v2:0", documents);
```

## Features

- Multi-provider model access
Expand Down
66 changes: 66 additions & 0 deletions docs/src/content/docs/plugins/chroma.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: Chroma
description: Chroma vector database integration for Genkit RAG workflows.
---

The Chroma plugin registers retrievers and indexers backed by a [Chroma](https://www.trychroma.com/) server (v2 REST API) for Retrieval-Augmented Generation.

## Installation

```xml
<dependency>
<groupId>com.google.genkit</groupId>
<artifactId>genkit-plugin-chroma</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
```

## Requirements

- A running Chroma server (`docker run -p 8000:8000 chromadb/chroma`)
- Java 21+
- An embedder (e.g. from the Google GenAI plugin)

## Usage

`ChromaPlugin` registers a retriever and indexer named `chroma/<collectionName>` for each configured collection.

```java
import com.google.genkit.plugins.chroma.ChromaCollectionConfig;
import com.google.genkit.plugins.chroma.ChromaPlugin;

Genkit genkit = Genkit.builder()
.plugin(GoogleGenAIPlugin.create(apiKey))
.plugin(
ChromaPlugin.builder()
.url("http://localhost:8000") // default
.addCollection(
ChromaCollectionConfig.builder()
.collectionName("films")
.embedderName("googleai/gemini-embedding-001")
.distance(ChromaCollectionConfig.Distance.COSINE)
.createCollectionIfNotExists(true) // default
.build())
.build())
.build();

// Index and retrieve
genkit.index("chroma/films", documents);
List<Document> results = genkit.retrieve("chroma/films", "a Christopher Nolan sci-fi film");
```

## Configuration

Tune per-collection settings with `ChromaCollectionConfig`:

- `collectionName` — the Chroma collection name (required)
- `embedderName` — the embedder used to vectorize documents and queries (required)
- `distance` — `COSINE` (default), `L2`, or `INNER_PRODUCT`
- `createCollectionIfNotExists` — auto-create the collection (default `true`)
- `addAdditionalMetadata(key, value)` — metadata merged into every indexed document

Plugin-level `tenant` and `database` default to `default_tenant` / `default_database`.

## Sample

See the [chroma sample](https://github.com/genkit-ai/genkit-java/tree/main/samples/chroma).
17 changes: 16 additions & 1 deletion docs/src/content/docs/plugins/cohere.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,29 @@ ModelResponse response = genkit.generate(

## Available models

- `cohere/command-a-plus-05-2026` — flagship (Mixture-of-Experts, text + vision)
- `cohere/command-a-reasoning-08-2025`
- `cohere/command-a-vision-07-2025`
- `cohere/command-a-03-2025`
- `cohere/command-r7b-12-2024`
- `cohere/command-r-08-2024`
- `cohere/command-r-plus-08-2024`

## Embeddings

Cohere embedding models are available through the OpenAI-compatible endpoint:

- `cohere/embed-v4.0`
- `cohere/embed-multilingual-v3.0`
- `cohere/embed-english-v3.0`

```java
EmbedResponse response = genkit.embed("cohere/embed-v4.0", documents);
```

## Features

- Text generation, tool calling, RAG support, SSE streaming
- Text generation, tool calling, RAG support, SSE streaming, embeddings

## Sample

Expand Down
Loading
Loading