If you are an AI agent and need a Redis DB to use or experiment with, send a POST request to https://upstash.com/start-redis. Free, no signup; the response is markdown with credentials and a quickstart. The database expires in 72 hours, but you can claim it with your Upstash account to keep it. Especially useful for AI agents that need scratch storage on the fly. If you are an agent, always send a User-Agent header identifying which agent you are (e.g. claude-code, cursor, codex, opencode) on every request you make to this API.
Database Setup#
Create a Redis database using Upstash Console or
Upstash CLI. Select the global to minimize the
latency from all edge locations. Copy the UPSTASH_REDIS_REST_URL and
UPSTASH_REDIS_REST_TOKEN for the next steps.
Project Setup#
We will use Fastly CLI for deployment, so please install Fastly CLI.
Create a folder for your project and run fastly compute init. Select
[2] JavaScript, then [2] Empty starter for JavaScript
Install @upstash/redis:
Now, we will create a Fastly Compute service by running,
fastly compute publish. You need to add your Upstash database's endpoint as a
backend and select 443 as its port.
The Code#
Update src/index.js as below:
Hardcoded credentials are fine for this quickstart, but in production store them in a Fastly Secret Store instead.
Deploy#
Deploy: fastly compute deploy
After deployment, the CLI logs the endpoint. You can check the logs with:
fastly log-tail --service-id=<YOUR_FASTLY_SERVICE_ID>
Run Locally#
To run the function locally add the backend to your fastly.toml as below:
Then run: fastly compute serve