@replayci/replay
v0.1.5
Published
ReplayCI SDK for deterministic tool-call validation and observation.
Maintainers
Readme
@replayci/replay
ReplayCI's Node.js SDK for deterministic contract validation and passive capture of tool-calling responses.
Installation
Install the SDK with the provider you use:
npm install @replayci/replay openainpm install @replayci/replay @anthropic-ai/sdkre2 is optional. If installed, regex invariants run with RE2.
Quick Start
import OpenAI from "openai";
import {
observe,
prepareContracts,
validate,
} from "@replayci/replay";
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const observed = observe(client, {
apiKey: process.env.REPLAYCI_API_KEY,
agent: "support-bot",
});
const contracts = prepareContracts("./contracts");
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "user", content: "What's the weather in San Francisco?" },
],
tools: [
{
type: "function",
function: {
name: "get_weather",
description: "Fetch the weather for a city.",
parameters: {
type: "object",
properties: {
location: { type: "string" },
},
required: ["location"],
},
},
},
],
});
const result = validate(response, { contracts });
if (!result.pass) {
console.error(result.failures);
}
observed.restore();validate()checks a single response against your prepared contracts.observe()passively captures calls for ReplayCI ingest without changing model behavior.
Docs
Full documentation lives at docs.replayci.com.
