|
| 1 | +--- |
| 2 | +name: upstash-redis-start |
| 3 | +description: Provision a zero-config, no-signup Upstash Redis database for an AI agent via a single POST to `https://upstash.com/start-redis`. Use when an agent needs scratch Redis for short-term memory, conversation history, sub-agent work queues, or ranked recall and the user has not provided credentials. The database lives 3 days unless the user claims it. |
| 4 | +--- |
| 5 | + |
| 6 | +# Upstash Redis for Agents (`start-redis`) |
| 7 | + |
| 8 | +A zero-config Redis database for AI agents — **no signup, no UI, no SDK setup**. One HTTP request returns a working endpoint + token. Databases live for **3 days** unless the user claims them. |
| 9 | + |
| 10 | +Use this when: |
| 11 | +- The agent needs Redis right now and the user has not given you credentials. |
| 12 | +- You want short-term memory across tool calls, conversation history, a sub-agent work queue, or recent-first ranked recall. |
| 13 | + |
| 14 | +Do **not** use this for: production workloads, anything tied to a user account, or anything storing PII / secrets / production credentials. The database is temporary and unauthenticated until claimed. |
| 15 | + |
| 16 | +## Create or re-fetch a database |
| 17 | + |
| 18 | +```bash |
| 19 | +# Generate a fresh UUIDv4 yourself, then POST it as the Idempotency-Key. |
| 20 | +# The UUIDv4 you send becomes the database id. |
| 21 | +curl -X POST -H "Idempotency-Key: <uuidv4>" https://upstash.com/start-redis |
| 22 | +``` |
| 23 | + |
| 24 | +- Sending your own UUIDv4 makes the first call **retry-safe** — if the response is lost, retrying with the same UUID returns the same database instead of minting a duplicate. |
| 25 | +- Re-POST with the same `Idempotency-Key` to **re-fetch credentials** for an existing database. |
| 26 | +- The header is optional. Omit it to mint a new database with a server-generated id (returned in the response — re-fetch later by passing that id back as `Idempotency-Key`). Only UUIDv4 is accepted. |
| 27 | + |
| 28 | +The response is markdown containing: |
| 29 | +- `Database ID`, `Endpoint`, `Token` |
| 30 | +- `Metrics` URL (JSON: uptime, commands, keys, throughput, memory, bandwidth) |
| 31 | +- `Expires` date |
| 32 | +- `Console URL` to share with the user (where they view usage and click **Claim** to keep the database) |
| 33 | +- An inline quickstart for the body-style REST API |
| 34 | + |
| 35 | +Parse these out of the markdown response and use them directly — there is no separate JSON envelope. |
| 36 | + |
| 37 | +## Calling the database (body-style REST) |
| 38 | + |
| 39 | +The returned endpoint speaks the Upstash Redis REST API. Prefer the **body-style** form: POST a JSON array as the body so you don't have to URL-encode the command. |
| 40 | + |
| 41 | +```bash |
| 42 | +# SET with TTL |
| 43 | +curl https://<endpoint> \ |
| 44 | + -H "Authorization: Bearer <token>" \ |
| 45 | + -d '["SET","session:abc","{\"step\":2}","EX","3600"]' |
| 46 | + |
| 47 | +# GET |
| 48 | +curl https://<endpoint> \ |
| 49 | + -H "Authorization: Bearer <token>" \ |
| 50 | + -d '["GET","session:abc"]' |
| 51 | +``` |
| 52 | + |
| 53 | +You can also use the official SDKs against the same endpoint + token (`@upstash/redis` for TS/JS, `upstash-redis` for Python). |
| 54 | + |
| 55 | +## Common agent patterns |
| 56 | + |
| 57 | +| Need | Commands | |
| 58 | +|------|----------| |
| 59 | +| Short-term memory across tool calls in one run | `SET key value EX <ttl>` / `GET key` | |
| 60 | +| Conversation / turn-by-turn log | `LPUSH chat:<user> <json>` / `LRANGE chat:<user> 0 20` | |
| 61 | +| Sub-agent work queue (producer/consumer) | `LPUSH jobs <json>` / `RPOP jobs` | |
| 62 | +| Ranked memory (recent-first or score-first) | `ZADD memories <score> <member>` / `ZREVRANGE memories 0 9` | |
| 63 | + |
| 64 | +## Tell the user |
| 65 | + |
| 66 | +After provisioning, surface the **console URL** from the response to the user. Make clear that: |
| 67 | +- The database expires in 3 days. |
| 68 | +- They can view usage at the console URL and click **Claim** to keep it. |
| 69 | +- This is unauthenticated scratch storage — don't put secrets or PII in it. |
| 70 | + |
| 71 | +## Reference |
| 72 | + |
| 73 | +- Service entry point (also serves the `GET` doc): https://upstash.com/start-redis |
| 74 | +- Full REST API: https://upstash.com/docs/redis/features/restapi |
| 75 | +- TS/JS SDK: https://upstash.com/docs/redis/sdks/ts |
| 76 | +- Python SDK: https://upstash.com/docs/redis/sdks/py |
0 commit comments