JavaScript SDK
Node.js and browser client with fluent API
Installation
bash
npm install @goreal-ai/echostashInitialization
import { Echostash } from "@goreal-ai/echostash"
const es = new Echostash("https://api.echostash.app", {
apiKey: process.env.ECHOSTASH_API_KEY
})Fetch and Convert
// Fetch → convert to OpenAI (messages + tools + config)
const { messages, tools, model, temperature } = await es
.prompt("support-agent")
.version("published")
.vars({ customerName: "Alice", tier: "premium" })
.openai()
// Use with OpenAI SDK
const response = await openai.chat.completions.create({
messages,
tools,
model,
temperature,
})Server-Side Render
const rendered = await es.prompt("greeting").render({ name: "Alice" })
console.log(rendered.content)Version Pinning
es.prompt("my-prompt").version("published") // latest published
es.prompt("my-prompt").version("staging") // staging target
es.prompt("my-prompt").version(5) // specific versionError Handling
import { EchostashError } from "@goreal-ai/echostash"
try {
const prompt = await es.prompt("missing").get()
} catch (err) {
if (err instanceof EchostashError) {
console.log(err.statusCode) // 404
console.log(err.isRateLimited) // false
console.log(err.retryAfter) // undefined
}
}