Tracking events
Use noryen.track() when you are not using a built-in wrapper, or when you need full control over the payload (custom providers, proxies, or non-HTTP flows).
Validation rules
modelis required.- For successful calls
promptandresponsemust be non-empty. Otherwise the event is dropped (a debug warning will appear ifdebugis on). - For failures, set
success: falseand prefer includingerror.
Example
track.ts
noryen.track({model: "gpt-4o-mini",provider: "openai",prompt: "Summarize this text in 3 bullets.",response: "1) ... 2) ... 3) ...",latency: 820,cost: 0.0012,inputTokens: 120,outputTokens: 80,metadata: { env: "prod", feature: "summary" },});
Common fields
Optional but useful fields include provider, latency (ms), cost, token counts (inputTokens, outputTokens, totalTokens), requestId, and metadata (see Metadata).
Failed requests
track-failure.ts
noryen.track({model: "gpt-4o-mini",success: false,error: "Rate limited",prompt: "…",// response can be omitted or minimal when success is false});
Events are queued and sent asynchronously. In short-lived environments, call flush() before the process or request ends.