Skip to content

promptrails/javascript-sdk

Repository files navigation

PromptRails JavaScript/TypeScript SDK

npm version Node.js versions License: MIT

Official JavaScript/TypeScript SDK for PromptRails — the AI agent orchestration platform.

Ships as both ESM and CJS. Requires Node.js 18+ (uses native fetch).

The SDK has two independent parts:

  • API client (@promptrails/sdk) — manage agents, prompts, executions, and more.
  • Tracing (@promptrails/sdk/tracing) — send spans to PromptRails from any code, without managing your prompts/agents on the platform.

Installation

npm install @promptrails/sdk
# or
pnpm add @promptrails/sdk

Quick Start

API client

import { PromptRails } from "@promptrails/sdk";

const client = new PromptRails({ apiKey: "pr_key_..." });
const result = await client.agents.execute("agent-id", {
  input: { query: "Summarise this week's sales" },
});
console.log(result.output);

See the API client guide for resources, error handling, media studio, and configuration.

Tracing

import { Tracer } from "@promptrails/sdk/tracing";

const tracer = new Tracer({ apiKey: "pr_..." });

await tracer.span("agent-run", { kind: "agent" }, async (root) => {
  root.setInput({ q: "weather?" });
  await tracer.span("llm-call", { kind: "llm" }, async (llm) => {
    llm.setModel("gpt-4o").setUsage(120, 30);
  });
});

await tracer.flush();

See the tracing guide. LangChain, OpenAI, and OpenTelemetry can be auto-instrumented — see integrations.

Documentation

  • API client — resources, error handling, media studio, configuration
  • Tracing — spans, decorators, batching, configuration
  • Integrations — LangChain, OpenAI, OpenTelemetry

Contributing

npm ci            # install dependencies
npm run lint      # lint
npm run format    # format
npm run build     # build (ESM + CJS)
npm test          # test

License

MIT

About

Promptrails Javascript SDK

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors