Skip to main content
TypeSafe AI answers typed questions about a piece of state — yes/no, scores, and labeled choices — through its systemOne API, returning answers whose TypeScript types are inferred from the questions you ask. Arize AX captures every call through the @arizeai/openinference-instrumentation-typesafe instrumentor, which emits one OpenInference LLM span per TypeSafeClient.systemOne call with the request and answers as JSON, the resolved model, and token usage.
This is the TypeScript / JavaScript guide. For the Python instrumentor, see TypeSafe AI.
client.models.list() is not instrumented — only systemOne produces spans. SDK retries are folded into one span rather than emitting a span per attempt.

Prerequisites

  • Node.js 20+
  • @typesafe-ai/sdk 0.6.0 or newer — the range the instrumentor patches
  • An Arize AX account (sign up)
  • A TYPESAFE_API_KEY from TypeSafe AI

Launch Arize AX

  1. Sign in to your Arize AX account.
  2. From Space Settings, copy your Space ID and API Key. You will set them as ARIZE_SPACE_ID and ARIZE_API_KEY below.

Install

Configure credentials

Setup tracing

Register a NodeTracerProvider that ships spans to Arize AX, then hand it to TypeSafeInstrumentation and patch the SDK with manuallyInstrument.
manuallyInstrument(TypeSafe) patches TypeSafeClient.prototype, so it covers ESM, bundlers, and modules imported before the instrumentor was enabled — import instrumentation.ts first and the rest of your code can keep importing TypeSafeClient normally. On CommonJS you can instead let Node’s require hook patch the SDK, by installing @opentelemetry/instrumentation and passing the instrumentor to its registerInstrumentations({ instrumentations: [instrumentation] }) in place of the manuallyInstrument call. That path only works when instrumentation.ts runs before the SDK is required, which is why the snippet above uses manuallyInstrument.

Run TypeSafe AI

Run the example with npx tsx example.ts. The instrumented systemOne still returns an SDK APIPromise, so await, withResponse(), and map() behave exactly as they do without tracing.

Expected output

Verify in Arize AX

  1. Open your Arize AX space and select project typesafe-tracing-example.
  2. You should see a new trace within ~30 seconds containing a single TypeSafeClient.systemOne LLM span. Its input is the JSON request (state plus questions), its output is the JSON result (model, answers, usage), and it carries llm.request.model_name (jev-latest, which this instrumentor fills in from the client default when the call omits model), llm.response.model_name (the resolved version, for example jev-1.13.0), and prompt, completion, and total token counts.
  3. If no traces appear, see Troubleshooting.

Check from the skill, CLI, or SDK

Confirm spans are actually reaching your Arize AX project. Use whichever fits your workflow — the skill and CLI work for any framework; the SDK check is shown for each language.
Install the Arize Skills plugin and let your coding agent check for you:
Then prompt your agent:
Use the arize-trace skill to export and analyze recent traces from my project. Confirm spans are arriving, and summarize any errors or latency issues.

Mask sensitive payloads

The request state is the document you are asking about, so it often carries customer data. Pass traceConfig to drop inputs, outputs, or both before the span leaves your process:
Model name and token counts are still recorded, so cost and latency dashboards keep working with payloads masked. See the instrumentor README for the full list of masking options.

Troubleshooting

  • No traces in Arize AX. Confirm ARIZE_SPACE_ID and ARIZE_API_KEY are set in the same shell that runs example.ts. Enable OpenTelemetry debug logs with export OTEL_LOG_LEVEL=debug and re-run.
  • Spans missing but systemOne returns answers. manuallyInstrument(TypeSafe) must run before the first systemOne call, so instrumentation.ts has to be imported before any code that calls the SDK.
  • No span for models.list(). Expected — the instrumentor only wraps systemOne.
  • 401 from TypeSafe. Verify TYPESAFE_API_KEY is set and valid; the client reads it from the environment unless you pass apiKey explicitly.
  • SDK fails to install or import. The TypeSafe SDK requires Node.js 20+. Check with node --version.
  • Process exits before spans flush. Spans are exported asynchronously; always await provider.forceFlush() (or provider.shutdown()) before the process exits.

Resources

TypeSafe AI Documentation

OpenInference TypeSafe Instrumentor (JS/TS)

Runnable TypeSafe Tracing Examples

TypeSafe AI SDK on npm

TypeSafe AI (Python) tracing