JavaScript SDK
Official JavaScript client
Installation
bash
npm install @goreal-ai/plp-clientSetup
import { PLPClient } from "@goreal-ai/plp-client"
const client = new PLPClient("https://api.example.com/v1", {
apiKey: "your-key",
timeout: 10000 // ms, default 10000
})Prompt Operations
// Get prompt (latest or specific version)
const prompt = await client.get("welcome-email")
const v1 = await client.get("welcome-email", "1.0.0")
// Create or update (idempotent PUT)
await client.put("welcome-email", {
content: "Hello {{name}}!",
meta: { description: "Welcome template" }
})
// List, publish, delete
const { prompts } = await client.listPrompts({ page: 1, size: 20 })
await client.publish("welcome-email", 3)
await client.delete("welcome-email")Deploy & Eval
await client.deploy("welcome-email", 3, "production")
const result = await client.runEval("welcome-email", evalYaml)Context Store
await client.uploadContextStoreAsset("logo", fileBlob)
await client.addPromptContext("welcome-email", { contextName: "logo", assetId: "logo" })
const resolved = await client.resolvePromptContext("welcome-email", ["logo"])Error Handling
import { PLPError } from "@goreal-ai/plp-client"
try {
await client.get("nonexistent")
} catch (e) {
if (e instanceof PLPError) {
console.log(e.statusCode) // 404
console.log(e.response) // { error: "Not Found", message: "..." }
}
}