Getting Started

Configuration

Configure Rice SDK via config file or environment variables.

Configuration

The SDK loads configuration from a configuration file, environment variables, and constructor options.

1. Configuration File

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
  },
};

2. Environment Variables (.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=...

3. Advanced Configuration

Custom Config Path

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" });

Managing Run IDs (Multi-User/Multi-Agent)

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");