get and set. Use it for caching computation results, sharing configuration between runners, or storing small pieces of state that multiple runners need to read. It requires no setup and uses automatic authentication with your fal credentials.
Unlike persistent storage on /data (a distributed filesystem for large files like model weights), KVStore is a remote key-value API accessed over HTTP. It is best suited for small, frequently-read values where you need cross-runner consistency. It does not support deletion, expiration, listing keys, or atomic operations, so it is not appropriate for counters, locks, or anything requiring transactional guarantees.
API Reference
Initialize KVStore
db_name values create separate key-value stores.
Methods
get(key: str) -> Optional[str]
Retrieve a value from the store. Returns None if the key doesn’t exist.
set(key: str, value: str) -> None
Store a string value. The value must be a string - use json.dumps() for objects.
Basic Example
Common Use Cases
Caching API Responses
Cache external API calls to reduce latency and costs:Caching Computation Results
Store results of expensive operations to avoid recomputation:Limitations
KVStore is deliberately simple. It only supportsget and set on string values. There is no delete, no key listing/scanning, no TTL or expiration, and no atomic operations (no increment, no compare-and-swap). Values persist indefinitely until overwritten.
If multiple runners write to the same key simultaneously, the last write wins with no conflict detection. This makes KVStore unsuitable for counters, locks, rate limiting, or anything requiring atomicity. For those use cases, use an external database like Redis or PostgreSQL.
For large files (model weights, datasets), use the /data volume instead.