Skip to main content
Looking for TypeScript? See the TypeScript guide.
PyPI Version This module provides OpenInference instrumentation for the TypeSafe AI Python SDK (typesafe-sdk). Calls to TypeSafeClient.system_one and AsyncTypeSafeClient.system_one are captured as OpenInference LLM spans. A System One request sends a state plus a map of typed questions (Noul, Choice, Score) and returns one typed answer per question, so the span records the request state/model/questions as input.value, the response answers/usage as output.value, the request and resolved model names, and prompt/completion/total token counts. Requires typesafe-sdk >= 0.6.0.

Install

Setup

Use the register function to connect your application to Phoenix:

Run TypeSafe AI

A simple TypeSafe AI application that is now instrumented:
The AsyncTypeSafeClient is instrumented the same way, and questions can be passed as SDK objects (as above) or as raw dictionaries.

Observe

With instrumentation enabled, each system_one call shows up in Phoenix as an LLM span containing:
  • input.value: the request body (state, model, questions) as JSON
  • llm.invocation_parameters: the call configuration, meaning the model and any extra_body fields
  • output.value: the response body (model, answers, usage) as JSON
  • llm.request.model_name and llm.response.model_name (the resolved model)
  • llm.token_count.prompt, llm.token_count.completion, and llm.token_count.total
TypeSafe AI traces in Phoenix
A System One call is not a chat exchange, so the state and the answers are recorded only as input.value and output.value, not as llm.input_messages / llm.output_messages.

Configuration

Because the state and the questions are recorded only in input.value, TraceConfig(hide_inputs=True) keeps the whole request off the span, and hide_outputs=True does the same for the answers. llm.invocation_parameters holds no request content, only the model and any extra_body fields; mask it with hide_llm_invocation_parameters if those are sensitive.
Tracing can also be suppressed for a block of code with suppress_tracing(), and context attributes such as using_session, using_user, and using_attributes propagate session, user, metadata, and tag information onto the spans it produces.

Resources