Node.js & Web SDK
Use @aerostack/sdk for server-side code: Cloudflare Workers, Node.js, and Bun. This is the full server-side SDK with access to database, cache, AI, queue, storage, and realtime broadcast.
Install
npm install @aerostack/sdkInitialize
import { AerostackClient } from '@aerostack/sdk'
const client = new AerostackClient({
projectId: process.env.PROJECT_ID,
apiKey: process.env.API_KEY,
baseUrl: 'https://api.aerostack.ai/v1',
})
const { sdk, realtime } = clientIn a Cloudflare Worker, the SDK is typically initialized from env bindings:
// Using the module-style Worker
import { AerostackClient } from '@aerostack/sdk'
export default {
async fetch(request, env) {
const { sdk } = new AerostackClient({
projectId: env.PROJECT_ID,
apiKey: env.API_KEY,
})
// Use sdk.db, sdk.cache, etc.
}
}Available modules
| Module | Description |
|---|---|
sdk.db | SQL queries via D1 |
sdk.cache | KV-backed cache |
sdk.storage | File upload and R2 |
sdk.ai | LLM completions and embeddings |
sdk.queue | Background job queue |
sdk.search | Vector similarity search |
sdk.socket | Realtime broadcast (server → clients) |
sdk.secrets | Secret retrieval |
sdk.auth | Server-side token verification |
Next steps
- Authentication — verify tokens, get user context
- Database — query, insert, batch
- Realtime — server-side broadcast
- Full API Reference — all methods