Upstash Integration with SmythOS
Need a fast, serverless database for your agents? Connect Upstash to SmythOS and empower your agents with a powerful Redis-compatible database for caching, state management, and real-time data storage.
List of Upstash Components
Quickly compare Upstash components by what they do and their key I/O. Click any component name to jump directly to its detailed guide.
Component | Action | What it Does | Inputs | Key Outputs | Use Case |
---|---|---|---|---|---|
Create Record | Write | Creates or updates a record with a specified key and value. | required db_id , db_key , db_value | result | Caching API responses or storing user session data. |
Prerequisites
Before you begin, please ensure you have the following:
- An active SmythOS account. (Sign up here).
- An Upstash account with a Redis database created.
- Your Upstash Database's ID and REST Token.
Getting Started With Upstash
The connection between SmythOS and Upstash is configured using your database credentials.
Step 1: Get Your Upstash Database Credentials
- Log in to the Upstash Console.
- Select the database you want to connect to.
- On the database details page, you will find the Database ID (
db_id
) and the REST Token. The REST token is the password for the REST API. - Copy both of these values.
Step 2: Store Your Credentials in SmythOS Vault
Your REST Token is a sensitive credential. Use the SmythOS Vault
to store it securely.
- In your SmythOS dashboard, navigate to the Vault.
- Create a new secret and paste your Upstash REST Token as the value. Give it a memorable name, like
upstash_rest_token
. The Database ID is less sensitive but can also be stored for convenience. - For more details, see the Vault Documentation.
Step 3: Configure an Upstash Component
- In your SmythOS agent graph, drag and drop any Upstash component.
- Click the component to open its Settings panel.
- In the
Upstash Redis Rest Token
field, select the secret you saved in the Vault (e.g.,upstash_rest_token
). - Your connection is now configured for that component. You will provide the
db_id
as a standard input.
Which Upstash Component Should I Use?
If you need to… | Target | Use this Component | Why this one? |
---|---|---|---|
Save or update a piece of data | A key and a value | Set Record | This is the fundamental "write" operation in a key-value store like Redis/Upstash. |
Component Details
This section provides detailed information for the Upstash components. Note: "Create Record" is equivalent to the SET
command, which creates a record if it doesn't exist or updates it if it does.
Create Record (Create/Update)
Creates a new record or updates an existing record with a specified key and value. This is the primary component for writing data to Upstash.
Inputs
Field | Type | Required | Notes |
---|---|---|---|
db_id | string | Yes | The unique ID of your Upstash database. |
db_key | string | Yes | The key under which the value will be stored (e.g., user:123:session ). |
db_value | string | Yes | The value to be stored. This can be a string, number, or JSON string. |
Outputs
Field | Type | Description |
---|---|---|
result | string | A confirmation message from the API, typically "OK" on success. |
Response | object | The full, raw JSON response from the Upstash API. |
Headers | object | The HTTP headers from the API response. |
{
"component": "upstash.createRecord",
"db_id": "us1-shiny-snake-12345",
"db_key": "user:session:xyz-abc",
"db_value": "{\"name\": \"Jane Doe\", \"loggedIn\": true}"
}
Best Practices & Advanced Tips
- Secure Your REST Token: Always store your Upstash REST Token in the SmythOS
Vault
. - Design a Key Naming Schema: Plan your keys carefully. A good convention, like
object-type:id:attribute
(e.g.,user:123:profile
), makes your data easy to manage and avoids key collisions. - Use JSON for Complex Data: When storing objects or arrays, convert them to a JSON string before using
Set Record
. Remember to parse the JSON string after retrieving it withGet Record
. - Set Time-to-Live (TTL) for Caches: When using Upstash for caching, set an expiration time on your keys to ensure stale data is automatically removed. This can be done by using more advanced Redis commands if the component supports them, or by building time-based logic into your agent.
Troubleshooting Common Issues
-
Error:
401 Unauthorized
- Cause: The
Upstash Redis Rest Token
is incorrect or invalid. - Solution: Verify that the token in your SmythOS Vault is correct and matches the REST Token for the correct database in your Upstash Console.
- Cause: The
-
Error:
404 Not Found
(when getting a record)- Cause: The
db_key
you are trying to retrieve does not exist in the database. - Solution: This is expected if the key has not been set or has expired. Your agent's logic should handle cases where a cache miss occurs.
- Cause: The
-
Incorrect Data Format
- Cause: Storing a complex object without first converting it to a JSON string, or forgetting to parse the JSON string after retrieving it.
- Solution: Always use a Code component or similar tool to
JSON.stringify()
before setting andJSON.parse()
after getting complex data.
What's Next?
You are now ready to build high-performance, stateful agents with the SmythOS Upstash Integration!
Consider these ideas:
-
Build an Agent That...
- Manages user sessions for a web application. When a user logs in, the agent creates a session record in Upstash with a short expiration time.
- Acts as a rate limiter. Before calling an external API, an agent checks a counter key in Upstash to ensure it hasn't exceeded its rate limit for the hour.
- Caches the results of expensive AI model calls. An agent can store the response from an LLM for a given prompt, so if the same prompt is received again, it can return the cached response instantly.
-
Explore Other Integrations:
- Combine Upstash with any API-based integration like Ahrefs or DataForSEO. Store the results of your API calls in Upstash to avoid repeatedly fetching the same data and reduce costs.
- Use Upstash as a simple database for agents that interact with users via Discord, storing user preferences or conversation history.