Skip to main content

API for interacting with the GoodMem service, providing vector-based memory storage and retrieval with multiple embedder support.

Project description

goodmem-client

PyPI version Python client for GoodMem - a vector-based memory storage and retrieval service. Provides APIs for creating memory spaces, storing memories with vector embeddings, and performing semantic search with streaming retrieval. Supports multiple embedding providers and advanced metadata handling.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: v1
  • Package version: 1.5.0
  • Generator version: 7.13.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://goodmem.io/support

Requirements.

Python 3.9+

Installation & Usage

pip install

You can install the package directly from PyPI:

pip install goodmem-client

If you prefer uv:

uv pip install goodmem-client

Then import the package:

import goodmem_client

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import goodmem_client

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

# Import required modules
from goodmem_client.api import APIKeysApi, SpacesApi
from goodmem_client.configuration import Configuration
from goodmem_client.api_client import ApiClient
from goodmem_client.models import CreateApiKeyRequest
from goodmem_client.streaming import MemoryStreamClient
from goodmem_client.rest import ApiException
from pprint import pprint

# Configure the API client
configuration = Configuration()
configuration.host = "http://localhost:8080"  # Use your server URL

# Create API client
api_client = ApiClient(configuration=configuration)

# Set authentication
api_client.default_headers["x-api-key"] = "your-api-key"  # Your API key here

# Create an instance of the API class
api_instance = APIKeysApi(api_client=api_client)

# Prepare a create request with labels
create_request = CreateApiKeyRequest(
    labels={
        "environment": "development",
        "service": "chat-ui"
    }
)

try:
    # Create a new API key
    api_response = api_instance.create_api_key(create_api_key_request=create_request)
    print("API Key created successfully:")
    print(f"API Key ID: {api_response.api_key_metadata.api_key_id}")
    print(f"Raw API Key: {api_response.raw_api_key}")
except ApiException as e:
    print(f"Exception when calling APIKeysApi->create_api_key: {e}")

Streaming Memory Retrieval

For memory retrieval operations, use the streaming client which is the primary way to search and retrieve memories:

from goodmem_client.api import SpacesApi
from goodmem_client.streaming import MemoryStreamClient
from goodmem_client.configuration import Configuration
from goodmem_client.api_client import ApiClient

# Configure client
configuration = Configuration()
configuration.host = "http://localhost:8080"
api_client = ApiClient(configuration=configuration)
api_client.default_headers["x-api-key"] = "your-api-key"

# Create streaming client
spaces_api = SpacesApi(api_client=api_client)
stream_client = MemoryStreamClient(api_client)

# Get space ID (first available space)
spaces = spaces_api.list_spaces()
space_id = spaces.spaces[0].space_id if spaces.spaces else None

# Stream memory retrieval
for event in stream_client.retrieve_memory_stream(
    message="your search query",
    space_ids=[space_id] if space_id else None,
    requested_size=5,
    fetch_memory=True,
    generate_abstract=True,
    format="ndjson"
):
    if event.abstract_reply:
        print(f"Abstract: {event.abstract_reply.text}")
    elif event.retrieved_item and event.retrieved_item.memory:
        memory = event.retrieved_item.memory
        print(f"Memory: {memory.get('memoryId')}")
        if 'metadata' in memory:
            print(f"Metadata: {memory['metadata']}")

For comprehensive examples, see the samples directory:

  • apikey_sample.py - API key CRUD operations
  • streaming_sample.py - Memory retrieval with streaming
  • reproduce_issue_71.py - Memory creation with metadata

Documentation for API Endpoints

All URIs are relative to http://localhost:8080

Class Method HTTP request Description
APIKeysApi create_api_key POST /v1/apikeys Create a new API key
APIKeysApi delete_api_key DELETE /v1/apikeys/{id} Delete an API key
APIKeysApi list_api_keys GET /v1/apikeys List API keys
APIKeysApi update_api_key PUT /v1/apikeys/{id} Update an API key
EmbeddersApi create_embedder POST /v1/embedders Create a new embedder
EmbeddersApi delete_embedder DELETE /v1/embedders/{id} Delete an embedder
EmbeddersApi get_embedder GET /v1/embedders/{id} Get an embedder by ID
EmbeddersApi list_embedders GET /v1/embedders List embedders
EmbeddersApi update_embedder PUT /v1/embedders/{id} Update an embedder
MemoriesApi batch_create_memory POST /v1/memories/batch Create multiple memories in a batch
MemoriesApi batch_delete_memory POST /v1/memories/batch/delete Delete multiple memories by ID
MemoriesApi batch_get_memory POST /v1/memories/batch/get Get multiple memories by ID
MemoriesApi create_memory POST /v1/memories Create a new memory
MemoriesApi delete_memory DELETE /v1/memories/{id} Delete a memory
MemoriesApi get_memory GET /v1/memories/{id} Get a memory by ID
MemoriesApi list_memories GET /v1/spaces/{spaceId}/memories List memories in a space
MemoriesApi retrieve_memory GET /v1/memories/retrieve Stream semantic memory retrieval
MemoriesApi retrieve_memory_advanced POST /v1/memories/retrieve Advanced semantic memory retrieval with JSON
RerankersApi create_reranker POST /v1/rerankers Create a new reranker
RerankersApi delete_reranker DELETE /v1/rerankers/{id} Delete a reranker
RerankersApi get_reranker GET /v1/rerankers/{id} Get a reranker by ID
RerankersApi list_rerankers GET /v1/rerankers List rerankers
RerankersApi update_reranker PUT /v1/rerankers/{id} Update a reranker
SpacesApi create_space POST /v1/spaces Create a new Space
SpacesApi delete_space DELETE /v1/spaces/{id} Delete a space
SpacesApi get_space GET /v1/spaces/{id} Get a space by ID
SpacesApi list_spaces GET /v1/spaces List spaces
SpacesApi update_space PUT /v1/spaces/{id} Update a space
SystemApi initialize_system POST /v1/system/init Initialize the system
UsersApi get_user GET /v1/users/{id} Get a user by ID

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

BearerAuth

  • Type: Bearer authentication

ApiKeyAuth

  • Type: API key
  • API key parameter name: x-api-key
  • Location: HTTP header

Contact & Support

For questions or issues with the Python client, please visit:

Author

support@goodmem.io

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goodmem_client-1.5.0.tar.gz (73.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

goodmem_client-1.5.0-py3-none-any.whl (131.0 kB view details)

Uploaded Python 3

File details

Details for the file goodmem_client-1.5.0.tar.gz.

File metadata

  • Download URL: goodmem_client-1.5.0.tar.gz
  • Upload date:
  • Size: 73.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for goodmem_client-1.5.0.tar.gz
Algorithm Hash digest
SHA256 b343be7772b8361806344d6fd293050c89c12c090c626ded5d5ff2cddea1f52a
MD5 98d85a5a40f00c96b0ffa1ae6c143771
BLAKE2b-256 18cb9e1a6984030617395c0e64b1ab31229a12032b536aa2bad105b191b2b65c

See more details on using hashes here.

File details

Details for the file goodmem_client-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: goodmem_client-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 131.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for goodmem_client-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f542d9985f3a27728bd13f8cda1ad1860ef6d326e4dfb8d5b87973ceb9d2f6c
MD5 387d4c24fc174a479924057b8a1a8064
BLAKE2b-256 1979326fa194d650ce3bf5f3566c686f19cdd2587c257e09f2211b2569f92a90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page