The SDK loads configuration from a configuration file, environment variables, and constructor options.
Control which services are enabled. Useful for applications that only need Storage or only need State.
/** @type {import('rice-node-sdk').RiceConfig} */
module.exports = {
// Enable/Disable Storage
storage: {
enabled: true, // Set to false if you only use State
},
// Enable/Disable State (AI Agent Memory)
state: {
enabled: true, // Set to false if you only use Storage
},
};
{
"storage": {
"enabled": true
},
"state": {
"enabled": true
}
}
.env)Configure connection details and authentication.
# --- Storage ---
# URL of your Storage instance (default: localhost:50051)
STORAGE_INSTANCE_URL=localhost:50051
# Auth token (if enabled on server)
STORAGE_AUTH_TOKEN=my-secret-token
# User for auto-login (default: admin)
STORAGE_USER=admin
# --- State (AI Agent Memory) ---
# URL of your State instance
STATE_INSTANCE_URL=localhost:50051
# Auth token
STATE_AUTH_TOKEN=my-secret-token
# Default Run ID for memory sessions (optional)
STATE_RUN_ID=default-run-id
# --- LLM Providers (for examples) ---
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
GOOGLE_API_KEY=...
You can load a specific config file by passing the path to the Client constructor.
const client = new Client({ configPath: "./config/prod.rice.config.js" });
client = Client(config_path="./config/prod.rice.config.json")
For State memory, the runId determines the session or agent context. You can switch run IDs dynamically to manage memory for different users or agents.
// Option A: Set globally in constructor
const client = new Client({ runId: "user-123-session" });
// Option B: Switch dynamically
client.state.setRunId("user-456-session");
await client.state.focus("New task for user 456");
# Option A: Set globally in constructor
client = Client(run_id="user-123-session")
# Option B: Switch dynamically
client.state.set_run_id("user-456-session")
client.state.focus("New task for user 456")