← Docs

🗄️ Key-Value Store

Simple state persistence for stateless agents. Store key-value pairs scoped to your API key, with atomic increment for counters.

How it works

Each API key gets its own isolated key-value namespace. Set a value with PUT, retrieve it with GET, and use atomic increment for counters. Entries auto-expire based on TTL (default 24 hours).

Set a value

curl -X PUT https://www.agent-utils.com/api/kv \

-H "x-api-key: au_your_key" \

-H "Content-Type: application/json" \

-d '{"key":"session:abc123","value":{"step":3,"status":"running"},"ttl":3600}'

# Response (201 created or 200 updated)

{"success":true,"data":{"key":"session:abc123","expiresAt":"2025-01-15T12:00:00Z"}}

Get a value

curl https://www.agent-utils.com/api/kv/session:abc123 \

-H "x-api-key: au_your_key"

# Response

{"success":true,"data":{"key":"session:abc123","value":{"step":3,"status":"running"},"expiresAt":"2025-01-15T12:00:00Z"}}

List keys

# List all keys (values omitted)

curl https://www.agent-utils.com/api/kv \

-H "x-api-key: au_your_key"

# With pagination

curl "https://www.agent-utils.com/api/kv?limit=10&offset=20" \

-H "x-api-key: au_your_key"

# Response

{"success":true,"data":{"items":[{"key":"session:abc123","expiresAt":"..."}],"total":1,"limit":50,"offset":0}}

Delete a key

curl -X DELETE https://www.agent-utils.com/api/kv/session:abc123 \

-H "x-api-key: au_your_key"

# Response

{"success":true,"data":{"deleted":true}}

Atomic increment

Use atomic increment for counters, rate limiting, or tracking progress. If the key does not exist, it is created with the amount as the initial value.

# Increment by 1 (default)

curl -X POST https://www.agent-utils.com/api/kv/counter:emails/increment \

-H "x-api-key: au_your_key" \

-H "Content-Type: application/json"

# Increment by a custom amount

curl -X POST https://www.agent-utils.com/api/kv/counter:emails/increment \

-H "x-api-key: au_your_key" \

-H "Content-Type: application/json" \

-d '{"amount": 5}'

# Response

{"success":true,"data":{"key":"counter:emails","value":6}}

Parameters

ParamMethodTypeDescription
keyPUTstringKey name (max 256 chars)
valuePUTanyValue to store (JSON-serializable)
ttlPUTnumberTime-to-live in seconds (default: 86400)
amountPOSTnumberIncrement amount (default: 1)
limitGETqueryMax keys to return (default: 50, max: 100)
offsetGETqueryPagination offset (default: 0)

Python

import requests

headers = {"x-api-key": "au_your_key"}

# Set a value

requests.put("https://www.agent-utils.com/api/kv", headers=headers, json={

"key": "agent:state",

"value": {"step": 1, "data": "hello"},

"ttl": 3600

})

# Get a value

requests.get("https://www.agent-utils.com/api/kv/agent:state", headers=headers)

# Atomic increment

requests.post("https://www.agent-utils.com/api/kv/counter/increment",

headers=headers, json={"amount": 1})

Tier limits

TierMax KeysMax Value Size
Free1010 KB
Builder10010 KB
Pro1,00010 KB
EnterpriseUnlimited10 KB