Skip to main content
Looking for Python? See the Python guide.
NPM Version This module provides OpenInference instrumentation for the TypeSafe AI Node.js SDK (@typesafe-ai/sdk). Each TypeSafeClient.systemOne call is captured as an OpenInference DECISION span with JSON input.value / output.value, and with the model and token usage recorded under decision.*. Requires Node.js 20+ and @arizeai/openinference-instrumentation-typesafe >= 0.4.1. client.models.list() is not instrumented.

Install

Setup

Use the register function from @arizeai/phoenix-otel to connect to Phoenix, then register the TypeSafe instrumentation. Create the instrumentation.ts file:
Registering the instrumentation this way patches @typesafe-ai/sdk at load time, which requires instrumentation.ts to run before the SDK is imported (CommonJS only). For ESM, bundlers, or when the SDK is imported first, call manuallyInstrument instead:

Usage

Spans are exported in batches. In short-lived scripts, call await provider.forceFlush() before the process exits so all spans are delivered to Phoenix.

Observe

With instrumentation enabled, each systemOne call shows up in Phoenix as a DECISION span containing:
  • The full state and questions sent to TypeSafe as input.value (JSON)
  • The typed answers returned as output.value (JSON)
  • decision.system and decision.provider: both typesafe
  • decision.request.model_name, decision.response.model_name (the resolved model), and decision.model_name
  • decision.token_count.input and decision.token_count.output, when reported by the SDK
Phoenix names the decision model in the span’s input card. The model and its usage follow the OpenInference decision span conventions and live under decision.* rather than llm.*, so decision-model calls stay out of Phoenix’s LLM token and cost reporting. Earlier releases recorded them under llm.*, and releases before 0.3.0 recorded them as LLM spans.
TypeSafe AI traces in Phoenix

Configuration

Pass traceConfig to mask sensitive request/response payloads before they leave your process:
See the package README for the full list of traceConfig masking options and the SDK compatibility table.

Resources