Spring AI
Expose the GoodMem RAG memory API as Spring AI tools that a ChatClient-driven LLM can call to store and retrieve memories.
Overview
GoodMem is a retrieval-augmented generation (RAG) memory layer that chunks, embeds, and indexes
documents server-side so an agent can pull back the most relevant passages on any question. The
Spring AI integration wraps the GoodMem API as Spring AI tools: register them with a ChatClient
and the model can create spaces, store text or files, and run semantic retrieval — with optional
reranking and an LLM-generated summary — against a running GoodMem server.
Installation
<dependency>
<groupId>io.github.bashareid</groupId>
<artifactId>goodmem-spring-ai</artifactId>
<version>0.1.0</version>
</dependency>Spring AI 1.0 or later is required and must be on the classpath. The artifact is published on
Maven Central under
a personal groupId (io.github.bashareid), which may change.
Configuration
| Variable | Description |
|---|---|
GOODMEM_BASE_URL | Base URL of the GoodMem API server (default https://your-goodmem-server.example.com). |
GOODMEM_API_KEY | API key sent as the X-API-Key header. |
GOODMEM_VERIFY_SSL | Set to false to skip TLS verification for self-signed dev certs (default: true). |
The same values can be passed in code through GoodMemClient.builder() (baseUrl, apiKey,
verifySsl) if you prefer not to rely on the environment.
Quick start
import ai.pairsys.goodmem.springai.GoodMemClient;
import ai.pairsys.goodmem.springai.GoodMemTools;
import org.springframework.ai.chat.client.ChatClient;
GoodMemClient client = GoodMemClient.builder()
.baseUrl(System.getenv("GOODMEM_BASE_URL"))
.apiKey(System.getenv("GOODMEM_API_KEY"))
.build();
GoodMemTools tools = new GoodMemTools(client);
String reply = ChatClient.builder(chatModel)
.defaultSystem("You have access to a GoodMem semantic memory store. "
+ "Use the goodmem tools to store facts the user shares and to "
+ "retrieve them when answering questions.")
.build()
.prompt()
.user("What was our Q2 launch deadline again?")
.tools(tools)
.call()
.content();Every tool returns a Map<String, Object> with success: true and operation-specific fields on
success, or success: false and an error field on failure.
Local development. The example above uses a TLS-verified production URL. If you are running
GoodMem locally with a self-signed certificate, use https://localhost:8080 and disable TLS
verification with the client's verify-SSL option (see the Configuration table above). Keep TLS
verification enabled for any deployed server.
Retrieval post-processing
GoodMem's retrieval call accepts these optional post-processing parameters (each framework exposes them under its own naming convention):
| Parameter | Range | Description |
|---|---|---|
reranker_id | UUID | Reranker model that reorders matched chunks by relevance. |
llm_id | UUID | LLM that generates a contextual answer (abstractReply) alongside the chunks. |
relevance_threshold | 0–1 | Minimum relevance score for a result to be included. |
llm_temperature | 0–2 | Sampling temperature for the LLM post-processor. |
max_results | integer | Maximum number of results to return. |
chronological_resort | boolean | Re-sort the final results by creation time instead of relevance. |
Learn more
The full README, examples, and API reference live in the upstream repository: PAIR-Systems-Inc/goodmem-spring-ai.