agent-plasticity
v0.1.2
Published
agentPlasticity AI observability SDK
Readme
agent-plasticity
AI observability SDK for agentPlasticity — track, evaluate, and monitor your AI agent calls.
Install
npm install agent-plasticityQuick Start
import { createClient } from 'agent-plasticity';
const ap = createClient({
apiKey: 'your-agent-token', // from the agentPlasticity dashboard
});
// Fire-and-forget (non-blocking)
ap.track({
prompt: 'Summarize this article...',
output: 'Here is a summary...',
modelName: 'gpt-4o',
});
// Awaited (returns callId)
const result = await ap.track(
{
prompt: 'Summarize this article...',
output: 'Here is a summary...',
modelName: 'gpt-4o',
systemPrompt: 'You are a helpful assistant.',
metadata: {
latencyMs: 320,
tokenUsage: 1500,
},
},
{ await: true },
);
console.log(result.callId);Vercel AI SDK Integration
Wrap generateText to automatically track every call:
import { generateText } from 'ai';
import { createClient } from 'agent-plasticity';
import { trackedGenerate } from 'agent-plasticity/ai';
import { openai } from '@ai-sdk/openai';
const ap = createClient({ apiKey: 'your-agent-token' });
const result = await trackedGenerate(ap, generateText, {
model: openai('gpt-4o'),
prompt: 'What is machine learning?',
});
console.log(result.text);API Reference
createClient(config)
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| apiKey | string | Yes | Agent API token from the dashboard |
| baseUrl | string | No | Custom API URL (defaults to https://www.agentplasticity.com) |
client.track(params, options?)
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| prompt | string | Yes | The input prompt |
| output | string | Yes | The model response |
| modelName | string | Yes | Model identifier (e.g. gpt-4o, claude-sonnet-4-20250514) |
| systemPrompt | string | No | System prompt if used |
| metadata | object | No | Additional data (tokenUsage, latencyMs, etc.) |
Options:
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| await | boolean | false | When true, returns a Promise<TrackResult>. Otherwise fire-and-forget. |
Links
License
MIT
