@tracelayer/sdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +74 -0
  2. package/package.json +20 -1
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # @tracelayer/sdk
2
+
3
+ Lightweight TypeScript SDK for [TraceLayer](https://YOUR-DASHBOARD-URL), an observability dashboard for AI calls.
4
+
5
+ Your AI requests still go straight to your provider. TraceLayer only receives telemetry: duration, status, model, tokens, and (optionally) input/output.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @tracelayer/sdk
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ Create a project in the dashboard, copy its API key, and keep it **server-side** only:
16
+
17
+ ```env
18
+ TRACELAYER_API_KEY=tl_live_xxxxxxxx
19
+ ```
20
+
21
+ ```ts
22
+ import { TraceLayer } from "@tracelayer/sdk";
23
+
24
+ const tracer = new TraceLayer({ apiKey: process.env.TRACELAYER_API_KEY! });
25
+
26
+ const response = await tracer.trace("customer-chat", async (span) => {
27
+ const res = await openai.chat.completions.create({
28
+ model: "gpt-4o-mini",
29
+ messages: [{ role: "user", content: "Hello!" }],
30
+ });
31
+
32
+ span
33
+ .setModel(res.model)
34
+ .setInput("Hello!")
35
+ .setOutput(res.choices[0]?.message.content)
36
+ .setUsage({
37
+ inputTokens: res.usage?.prompt_tokens ?? 0,
38
+ outputTokens: res.usage?.completion_tokens ?? 0,
39
+ });
40
+
41
+ return res;
42
+ });
43
+
44
+ // serverless (Vercel, Workers): wait for delivery before responding
45
+ await tracer.flush();
46
+ ```
47
+
48
+ Duration and success/failure are captured automatically. Model, input, output, and token usage are set explicitly through the span.
49
+
50
+ ## Options
51
+
52
+ | Option | Default | Description |
53
+ |---|---|---|
54
+ | `apiKey` | required | Project API key |
55
+ | `baseUrl` | TraceLayer API | Override for self-hosting or local development |
56
+ | `timeoutMs` | `3000` | Per-request timeout |
57
+ | `enabled` | `true` | Set `false` to send nothing (tests, local) |
58
+ | `captureContent` | `true` | `false` = never send input/output |
59
+ | `redact` | none | `(text) => text` applied before anything is sent |
60
+ | `onError` | none | Called when telemetry fails |
61
+
62
+ ## Reliability
63
+
64
+ - Telemetry never throws into your app.
65
+ - Your function's result is returned unchanged, and its errors are rethrown unchanged.
66
+ - Sends are non-blocking with a timeout.
67
+
68
+ ## Privacy
69
+
70
+ Prompts and outputs may contain sensitive data. Use `captureContent: false` or `redact` to control what leaves your app. Your AI provider keys are never sent to TraceLayer.
71
+
72
+ ## License
73
+
74
+ MIT
package/package.json CHANGED
@@ -1,8 +1,27 @@
1
1
  {
2
2
  "name": "@tracelayer/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Lightweight telemetry SDK for TraceLayer AI observability",
5
5
  "type": "module",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "observability",
9
+ "llm",
10
+ "ai",
11
+ "tracing",
12
+ "telemetry",
13
+ "openai",
14
+ "monitoring"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/unainr/project-files.git",
19
+ "directory": "packages/sdk"
20
+ },
21
+ "homepage": "https://<your-dashboard-url>",
22
+ "bugs": {
23
+ "url": "https://github.com/unainr/project-files/issues"
24
+ },
6
25
  "sideEffects": false,
7
26
  "main": "./dist/index.cjs",
8
27
  "module": "./dist/index.js",