Skip to main content

GoodMem's Convenient SDK for Python

Project description

GoodMem Python SDK

An OpenAI-style API for Goodmem with auto-inference of model parameters, streaming retrieval, async support, and auto-pagination. The SDK stays in sync with the server's OpenAPI spec — except for hand-written convenience methods (model registry auto-inference, flat post-processor kwargs, etc.) that wrap the generated layer. Please see ../notes/client_gen.md for the SDK generation details and ../notes/doc_gen.md for the doc generation details.

Installation

pip install goodmem

Usage

The programmatic way

from goodmem import Goodmem

client = Goodmem(
    base_url="http://localhost:8080",
    api_key="gm_..."
)

embedder = client.embedders.create(
    display_name="OpenAI Embedder",
    model_identifier="text-embedding-3-large",
    api_key="sk-your-openai-key",
)

print(f"Created: {embedder.embedder_id}")

The Skill way

# One-time setup — copy the skill into your Claude Code skills directory
cp -r $(python -c "import goodmem; print(goodmem.__path__[0])")/skills ~/.claude/skills/goodmem

Once installed, Claude Code automatically loads the GoodMem SDK reference when you ask it to create embedders, store memories, run retrieval, etc.

Project structure

clients/v2/python/
├── goodmem/                        # Installable package
│   ├── client.py                   # Goodmem / AsyncGoodmem entry points
│   ├── errors.py                   # Typed exception hierarchy (APIError, NotFoundError, …)
│   ├── pagination.py               # Paginator / AsyncPaginator (auto next_token)
│   ├── streaming.py                # RetrieveMemoryStream (SSE → typed events)
│   ├── _base.py                    # CRUDNamespace / AsyncCRUDNamespace base classes
│   ├── _transforms.py              # Loads convenience.json, implements 7 transform primitives
│   ├── _overrides.py               # Complex domain logic (file upload, post-processor bypass)
│   ├── _schema_bridge.py           # [AUTO-GENERATED] Credential helpers, enum values
│   ├── _registries.py              # Model-registry loader
│   ├── convenience.json            # [edit] Declarative transforms — source of truth
│   ├── api/                        # Tier-3: convenience overrides
│   │   ├── embedders.py            #   5 override classes call apply_convenience_transforms
│   │   ├── llms.py                 #     then super()
│   │   ├── rerankers.py
│   │   ├── spaces.py               #   5 thin pass-throughs (apikeys, users, ocr,
│   │   ├── memories.py             #     system, admin) — just `pass`
│   │   └── ...
│   ├── registries/                 # Model data (no code generation)
│   │   ├── embedders.json          #   29 embedder models (provider, dims, modalities)
│   │   ├── llms.json               #   34 LLM models
│   │   └── rerankers.json          #   16 reranker models
│   ├── skills/                     # Claude Code skill (also distributed via PyPI)
│   ├── models/                     # [Tier 1] [AUTO-GENERATED] ~99 pydantic v2 models
│   ├── _api_base/                  # [Tier 2] [AUTO-GENERATED] Structural API base classes
│   └── api_ir.json                 # [AUTO-GENERATED] Universal API IR
├── tests/                          # Unit + validation tests (run without server)
│   ├── test_validate.py            #   Wraps _client_gen/validate.py checks as pytest
│   ├── test_*.py
│   └── integration/                # Live server tests (auto-skip without env vars)
├── examples/
│   └── basic_rag.py                # End-to-end RAG example
├── vibe/                           # Claude Code non-interactive prompts
│   ├── audit_ref_doc.sh            #   Audit generated MDX docs for accuracy
│   └── sdk2rest.sh                 #   Generate REST equivalents from SDK test snippets
├── release.sh                      # Build + publish to PyPI
├── goodmem-reset.sh                # Delete all resources on a GoodMem server (test cleanup)
└── pyproject.toml

Shared infrastructure lives at clients/v2/ level (not inside python/):

  • _client_gen/ — code generation (spec parsing, emitters, MCP emitter, validation)
  • _doc_gen/ — doc generation (ref pages, skills, snippet sync)
  • agents/ — Claude Code plugin (git subtree → public repo)
  • notes/ — internal dev notes

Development commands

# Generation (run from clients/v2/, not python/)
cd ..
./client_gen.sh                # compile server → IR → Python SDK → MCP → test
./doc_gen.sh                   # ref pages + skills + snippets

# Publishing (run from python/)
cd python
./release.sh build             # Build wheel + sdist
./release.sh publish           # Publish to PyPI

# Vibe auditing (Claude Code non-interactive)
./vibe/audit_ref_doc.sh        # audit generated MDX docs for accuracy
./vibe/sdk2rest.sh             # generate REST equivalents from SDK test snippets

In client_gen.sh, integration test is only activated when environment variables GOODMEM_BASE_URL and GOODMEM_API_KEY are set.

Warning: Before the integration tests, client_gen.sh, vibe/sdk2rest.sh, and CI all run goodmem-reset.sh to delete ALL resources on the target server. Never point GOODMEM_BASE_URL at a production server. We have a dedicated test server on Fly.io for this purpose. See ci/README.md for more details.

See notes/client_gen.md for the full regeneration workflow and notes/doc_gen.md for the doc and auditing pipelines.

Documentation

TODO

  1. Add gemini-embedding-001 to embedder registry once backend adds OPENAI_COMPATIBLE to ProviderType.
  2. Add Anthropic, Google, Cohere, and Mistral LLMs to registry once backend adds matching LLMProviderType values.
  3. Automate model registry updates to add new models as they are released.
  4. Generate SDK to an intermediate representation, then map that to cURL, HTTPie, HTTPX, Go, JavaScript, etc.

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-0.1.11.tar.gz (111.0 kB view details)

Uploaded Source

Built Distribution

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

goodmem-0.1.11-py3-none-any.whl (149.3 kB view details)

Uploaded Python 3

File details

Details for the file goodmem-0.1.11.tar.gz.

File metadata

  • Download URL: goodmem-0.1.11.tar.gz
  • Upload date:
  • Size: 111.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for goodmem-0.1.11.tar.gz
Algorithm Hash digest
SHA256 868817d71898bef017935b463b4b3b004d8e3cb3b22739544bcf43bad5871263
MD5 1cbc00e6a97e3aeca5c1affac98b3bee
BLAKE2b-256 ac34f79a5f65434c9a2eed7841d0dc44f22a148ac393b89952cb6e779d01183e

See more details on using hashes here.

File details

Details for the file goodmem-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: goodmem-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 149.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for goodmem-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 addfb53d6510b97b0086b483e6b073ef807a1d7d988e3634b733ad4be7c3a36b
MD5 d8d26c241cf789c3133acdf622dee93b
BLAKE2b-256 a8aad2ec752114f89b91e42cdd220512ae9f208b75011fa056e94c3d4a97c26a

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