Your first trace
Wrap your existing model client and see a complete trace in the Cloudmind UI within a minute.
The fastest path is wrapping a client you already have.
OpenAI
import OpenAI from "openai";
import { monitorOpenAI } from "@cloudmind-ai/js/openai";
const openai = monitorOpenAI(new OpenAI());
const result = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Write a haiku about observability." }],
});
console.log(result.choices[0].message.content);
Run it. Within a few seconds the trace appears in your workspace with the prompt, the completion, token counts, cost and latency.
Anthropic
import Anthropic from "@anthropic-ai/sdk";
import { monitorAnthropic } from "@cloudmind-ai/js/anthropic";
const anthropic = monitorAnthropic(new Anthropic());
Anything else
Wrap the operation directly. This works for any model, including self-hosted ones.
import { cloudmind } from "@cloudmind-ai/js";
await cloudmind.trace({ name: "classify-intent" }, async (span) => {
const output = await myCustomModel(input);
span.record({ input, output, model: "internal-classifier-v3" });
return output;
});
Adding metadata
Metadata is what makes traces findable later. Attach anything you might want to filter by.
await cloudmind.trace(
{
name: "support-summary",
userId: user.id,
metadata: { plan: user.plan, tenant: user.orgId, feature: "inbox-summary" },
},
async () => summarizeTicket(ticket),
);
Flushing before exit
In short-lived processes such as serverless functions or scripts, flush before the process ends or the final batch is lost.
await cloudmind.flush();
Next: core concepts.