@cueno/sdk
v0.1.1
Published
Official SDK for the Cueno runtime prompt-resolution API.
Maintainers
Readme
@cueno/sdk
Official SDK for the Cueno runtime prompt-resolution API. Resolve a prompt by
slug, render it with variables, or pin a specific version — from any
JavaScript/TypeScript runtime with fetch (Node 18+, edge, Deno, browsers).
Zero runtime dependencies.
Install
npm install @cueno/sdkQuick start
import { Cueno } from "@cueno/sdk";
const cueno = new Cueno({
apiKey: process.env.CUENO_API_KEY!, // e.g. cueno_live_…
// baseUrl defaults to https://cueno.dev; set it to http://localhost:3000 for local dev
});
// Resolve + render in one call (server validates variables):
const { prompt } = await cueno.prompts.render("support-greeting", {
company: "Acme",
customer: "Lee",
});
console.log(prompt);The API key is a secret and the key's environment is authoritative — a
cueno_live_…key only seesproduction. Keep the key server-side; don't ship it in a browser bundle.
API
cueno.prompts.list(); // prompts deployed to the key's env
cueno.prompts.get("support-greeting"); // resolve slug → body + variables
cueno.prompts.render("support-greeting", vars);// resolve + interpolate
cueno.prompts.versions("support-greeting"); // version history (newest first)
cueno.prompts.version("support-greeting", "v3");// a specific pinned versionAll methods return typed responses (see the exported types). render accepts
Record<string, string | number | boolean>.
Errors
Non-2xx responses throw CuenoApiError:
import { CuenoApiError } from "@cueno/sdk";
try {
await cueno.prompts.render("support-greeting", { company: 123 });
} catch (e) {
if (e instanceof CuenoApiError) {
e.code; // "validation_failed" — branch on this, not e.message
e.status; // 422
e.issues; // [{ variable: "company", message: "Expected a string value." }]
}
}| code | status | Meaning |
|---|---|---|
| unauthorized | 401 | Missing/invalid API key |
| not_found | 404 | Unknown slug, nothing deployed to the env, or unknown version label |
| invalid_request | 400 | Malformed request |
| validation_failed | 422 | Variable values failed validation (see .issues) |
Configuration
| Option | Default | Notes |
|---|---|---|
| apiKey | — | Required. |
| baseUrl | https://cueno.dev | API origin, without /api/v1. Set to http://localhost:3000 for local dev. |
| fetch | globalThis.fetch | Inject a custom fetch (Node <18, or for tests). |
Develop
npm run typecheck # tsc --noEmit
npm run build # emit dist/ (ESM + .d.ts)This package lives inside the Cueno app repo as a standalone, dependency-free
package. The endpoint contract it targets is documented in
docs/sdk-api.md.
