Skip to main content

gistfs

Use GitHub Gists as a persistent key-value filesystem — ideal for AI agent memory.

Install

pip install gistfs

With optional integrations:

pip install gistfs[llamaindex]   # LlamaIndex KVStore
pip install gistfs[langgraph]    # LangGraph BaseStore
pip install gistfs[all]          # everything

Quick start

Creating a new gist

No need to create a gist manually — bootstrap one from code:

from gistfs import GistFS

gfs = GistFS.create(description="my agent memory")
print(gfs.gist_id)  # save this for later

# Or with GistMemory:
from gistfs import GistMemory
mem = GistMemory.create(description="my agent memory")

As a filesystem (context manager)

from gistfs import GistFS

with GistFS(gist_id="your_gist_id") as gfs:
    gfs.write("config.json", {"model": "gpt-4", "temperature": 0.7})
    config = gfs.read("config.json")
    print(gfs.list_files())
    gfs.delete("config.json")

File-like interface

with GistFS(gist_id="your_gist_id") as gfs:
    with gfs.open("notes.txt", "w") as f:
        f.write("hello world")

    with gfs.open("notes.txt", "r") as f:
        content = f.read()

    with gfs.open("notes.txt", "a") as f:
        f.write("\nappended line")

As AI agent memory

from gistfs import GistMemory

with GistMemory(gist_id="your_gist_id") as mem:
    mem.put("conversation_1", {"messages": [{"role": "user", "content": "hi"}]})
    history = mem.get("conversation_1")
    all_data = mem.get_all()
    mem.delete("conversation_1")

LlamaIndex integration

from gistfs.integrations.llamaindex import GistKVStore

store = GistKVStore(gist_id="your_gist_id")
store.put("doc1", {"text": "hello world"}, collection="docstore")
doc = store.get("doc1", collection="docstore")

LangGraph integration

from gistfs.integrations.langgraph import GistStore

store = GistStore(gist_id="your_gist_id")
store.put(("user", "prefs"), "theme", {"value": "dark"})
item = store.get(("user", "prefs"), "theme")

Encryption

Install with encryption support:

pip install gistfs[encryption]

File content is encrypted (Fernet) and base64-encoded before being sent to GitHub, and decrypted transparently on read. Pass an encryption_key to any class:

from gistfs import GistFS, derive_key
from gistfs.integrations.langgraph import GistStore

# Derive a key from a password (store the salt for later reuse)
key, salt = derive_key("mypassword", salt=b"gistfs-demo-salt")

# GistFS — files are encrypted at rest in the gist
with GistFS(gist_id="your_gist_id", encryption_key=key) as gfs:
    gfs.write("secrets.json", {"api_key": "sk-123"})
    assert gfs.read("secrets.json") == {"api_key": "sk-123"}

# LangGraph store — same key, same transparent encryption
store = GistStore(gist_id="your_gist_id", encryption_key=key)
store.put(("user", "prefs"), "theme", {"value": "dark"})

Authentication

Set the GITHUB_TOKEN environment variable with a GitHub personal access token that has gist scope. Read-only operations on public gists work without a token.

export GITHUB_TOKEN=ghp_your_token_here

Or pass it directly:

gfs = GistFS(gist_id="abc123", token="ghp_...")

Download files

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

Source Distribution

gistfs-0.3.0.tar.gz (979.6 kB view details)

Uploaded Source

Built Distribution

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

gistfs-0.3.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file gistfs-0.3.0.tar.gz.

File metadata

  • Download URL: gistfs-0.3.0.tar.gz
  • Upload date:
  • Size: 979.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gistfs-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0ed9a57b2726891de21bde504362d0589b2bd1b16d80e4dd89c1662695eb5553
MD5 a56ec02198af4b5591baf6b70c62ec70
BLAKE2b-256 f81e66a7ec1fdbecc70e7a93792489c7e6d7e9dddd79a8bc7c01b4856c111115

See more details on using hashes here.

File details

Details for the file gistfs-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: gistfs-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gistfs-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5808eaf9dd72c4befa41d693bd052dce17b9e520e32fca963e2ae55fa087f90a
MD5 bfff88f7702f11c1405a77f71ba5b080
BLAKE2b-256 8bea32956b976b54f1a68d1f20ef4ea81e2bf9f1345a47359388d385320980ee

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

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