Skip to content

Answers and responses

Read answers, confidence scores, token usage, and available models returned by the TypeSafe API.

export function SdkSignature({children}) { async function copy(event) { const button = event.currentTarget; const code = button.parentElement.querySelector("pre code"); try { await navigator.clipboard.writeText(code.textContent); button.setAttribute("aria-label", "Signature copied"); button.dataset.copied = "true"; } catch { button.setAttribute("aria-label", "Copy failed; select the signature to copy"); } setTimeout(() => { button.setAttribute("aria-label", "Copy signature"); delete button.dataset.copied; }, 2000); } return

{children}
; }

Response

typesafe\_sdk.SystemOneResponse

pydantic-model

Bases: Response

Answers grouped by question type with model and usage metadata.

See System One for details.

Note

Show JSON schema:

Details

{
  "$defs": {
    "ChoiceAnswer": {
      "description": "A selected label and its probabilities.\n\nSee the [choice primitive](https://docs.typesafe.ai/primitives/choice) for details.",
      "properties": {
        "type": {
          "const": "choice",
          "default": "choice",
          "title": "Type",
          "type": "string"
        },
        "choice": {
          "description": "The name of the choice with the highest probability among the question's criteria.",
          "examples": [
            "angry"
          ],
          "title": "Choice",
          "type": "string"
        },
        "confidence": {
          "description": "Confidence in the selected choice, from 0 to 1. Higher values indicate greater certainty; use lower values to flag uncertain selections for review.",
          "examples": [
            0.9
          ],
          "title": "Confidence",
          "type": "number"
        },
        "probabilities": {
          "additionalProperties": {
            "type": "number"
          },
          "description": "Probability of each choice in criteria, keyed by choice name, from 0 to 1. Shows how likely the alternatives are; values sum to approximately 1.",
          "examples": [
            {
              "angry": 0.8,
              "calm": 0.1,
              "excited": 0.1
            }
          ],
          "title": "Probabilities",
          "type": "object"
        }
      },
      "required": [
        "choice",
        "confidence",
        "probabilities"
      ],
      "title": "ChoiceAnswer",
      "type": "object"
    },
    "NoulAnswer": {
      "description": "A yes/no answer.\n\nSee the [noul primitive](https://docs.typesafe.ai/primitives/noul) for details.",
      "properties": {
        "type": {
          "const": "noul",
          "default": "noul",
          "title": "Type",
          "type": "string"
        },
        "noul": {
          "description": "Probability of a yes answer or a true statement, from 0 to 1. Values near 1 favor yes or true, values near 0 favor no or false, and values near 0.5 indicate uncertainty.",
          "examples": [
            0.98
          ],
          "title": "Noul",
          "type": "number"
        }
      },
      "required": [
        "noul"
      ],
      "title": "NoulAnswer",
      "type": "object"
    },
    "ScoreAnswer": {
      "description": "An expected score with its rubric and probabilities.\n\nSee the [score primitive](https://docs.typesafe.ai/primitives/score) for details.",
      "properties": {
        "type": {
          "const": "score",
          "default": "score",
          "title": "Type",
          "type": "string"
        },
        "score": {
          "description": "Expected score: the probability-weighted average of the rubric levels. May fall between integer levels.",
          "examples": [
            1.7
          ],
          "title": "Score",
          "type": "number"
        },
        "confidence": {
          "description": "Confidence in the score, from 0 to 1. Higher values indicate greater certainty; use lower values to flag uncertain ratings for review.",
          "examples": [
            0.9
          ],
          "title": "Confidence",
          "type": "number"
        },
        "legend": {
          "additionalProperties": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "items": {},
                "type": "array"
              }
            ]
          },
          "title": "Legend",
          "type": "object"
        },
        "probabilities": {
          "additionalProperties": {
            "type": "number"
          },
          "title": "Probabilities",
          "type": "object"
        }
      },
      "required": [
        "score",
        "confidence",
        "legend",
        "probabilities"
      ],
      "title": "ScoreAnswer",
      "type": "object"
    },
    "Usage": {
      "description": "Token counts for a request, when reported by the API.",
      "properties": {
        "input_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Input Tokens"
        },
        "output_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Output Tokens"
        }
      },
      "title": "Usage",
      "type": "object"
    }
  },
  "description": "Answers grouped by question type with model and usage metadata.\n\nSee [System One](https://docs.typesafe.ai/concepts/system-one) for details.",
  "properties": {
    "model": {
      "title": "Model",
      "type": "string"
    },
    "usage": {
      "$ref": "#/$defs/Usage"
    },
    "answers": {
      "additionalProperties": {
        "discriminator": {
          "mapping": {
            "choice": "#/$defs/ChoiceAnswer",
            "noul": "#/$defs/NoulAnswer",
            "score": "#/$defs/ScoreAnswer"
          },
          "propertyName": "type"
        },
        "oneOf": [
          {
            "$ref": "#/$defs/NoulAnswer"
          },
          {
            "$ref": "#/$defs/ChoiceAnswer"
          },
          {
            "$ref": "#/$defs/ScoreAnswer"
          }
        ]
      },
      "title": "Answers",
      "type": "object"
    }
  },
  "required": [
    "model",
    "usage"
  ],
  "title": "SystemOneResponse",
  "type": "object"
}

Config:

  • extra: ignore
  • frozen: True
  • strict: True

Fields:

request\_id

cached property

request_id : [str](https://docs.python.org/3/builtins/stdtypes.html#str) \n

The x-typesafe-request-id response header.

raw\_http\_response

property

raw_http_response: httpx2.Response

The underlying httpx2.Response, exposing status, headers, and body.

model\_config

class-attribute instance-attribute

model_config = ConfigDict(
    extra="ignore", frozen=True, strict=True
)

model

pydantic-field

model : [str](https://docs.python.org/3/builtins/stdtypes.html#str) \n

The model used to answer the request.

usage

pydantic-field

usage : [Usage](responses.md#typesafe_sdk.Usage) \n

Token usage for the request.

answers

pydantic-field

answers : [dict](https://docs.python.org/3/builtins/stdtypes.html#dict) [ [str](https://docs.python.org/3/builtins/stdtypes.html#str) , [Answer](responses.md#typesafe_sdk.Answer) ] \n

All answer objects keyed by question name.

nouls

cached property

nouls : [dict](https://docs.python.org/3/builtins/stdtypes.html#dict) [ [str](https://docs.python.org/3/builtins/stdtypes.html#str) , [NoulAnswer](responses.md#typesafe_sdk.NoulAnswer) ] \n

Yes/no answers keyed by question name.

choices

cached property

choices : [dict](https://docs.python.org/3/builtins/stdtypes.html#dict) [ [str](https://docs.python.org/3/builtins/stdtypes.html#str) , [ChoiceAnswer](responses.md#typesafe_sdk.ChoiceAnswer) ] \n

Choice answers keyed by question name.

scores

cached property

scores : [dict](https://docs.python.org/3/builtins/stdtypes.html#dict) [ [str](https://docs.python.org/3/builtins/stdtypes.html#str) , [ScoreAnswer](responses.md#typesafe_sdk.ScoreAnswer) ] \n

Score answers keyed by question name.

typesafe\_sdk.Usage

pydantic-model

Bases: wire.Usage

Token counts for a request, when reported by the API.

Note

Show JSON schema:

Details

{
  "description": "Token counts for a request, when reported by the API.",
  "properties": {
    "input_tokens": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Input Tokens"
    },
    "output_tokens": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Output Tokens"
    }
  },
  "title": "Usage",
  "type": "object"
}

Config:

  • extra: ignore
  • frozen: True
  • strict: True

Fields:

model\_config

class-attribute instance-attribute

model_config = ConfigDict(
    extra="ignore", frozen=True, strict=True
)

input\_tokens

pydantic-field

input_tokens : [int](https://docs.python.org/3/builtins/functions.html#int) | None = None \n

Number of input tokens used, or None when the API did not report it.

output\_tokens

pydantic-field

output_tokens : [int](https://docs.python.org/3/builtins/functions.html#int) | None = None \n

Number of output tokens used, or None when the API did not report it.

Answers

typesafe\_sdk.NoulAnswer

pydantic-model

Bases: wire.NoulAnswer

A yes/no answer.

See the noul primitive for details.

Note

Show JSON schema:

Details

{
  "description": "A yes/no answer.\n\nSee the [noul primitive](https://docs.typesafe.ai/primitives/noul) for details.",
  "properties": {
    "type": {
      "const": "noul",
      "default": "noul",
      "title": "Type",
      "type": "string"
    },
    "noul": {
      "description": "Probability of a yes answer or a true statement, from 0 to 1. Values near 1 favor yes or true, values near 0 favor no or false, and values near 0.5 indicate uncertainty.",
      "examples": [
        0.98
      ],
      "title": "Noul",
      "type": "number"
    }
  },
  "required": [
    "noul"
  ],
  "title": "NoulAnswer",
  "type": "object"
}

Config:

  • extra: ignore
  • frozen: True
  • strict: True

Fields:

noul

pydantic-field

noul : [float](https://docs.python.org/3/builtins/functions.html#float) \n

Probability of a yes answer or a true statement, from 0 to 1. Values near 1 favor yes or true, values near 0 favor no or false, and values near 0.5 indicate uncertainty.

model\_config

class-attribute instance-attribute

model_config = ConfigDict(
    extra="ignore", frozen=True, strict=True
)

typesafe\_sdk.ChoiceAnswer

pydantic-model

Bases: wire.ChoiceAnswer

A selected label and its probabilities.

See the choice primitive for details.

Note

Show JSON schema:

Details

{
  "description": "A selected label and its probabilities.\n\nSee the [choice primitive](https://docs.typesafe.ai/primitives/choice) for details.",
  "properties": {
    "type": {
      "const": "choice",
      "default": "choice",
      "title": "Type",
      "type": "string"
    },
    "choice": {
      "description": "The name of the choice with the highest probability among the question's criteria.",
      "examples": [
        "angry"
      ],
      "title": "Choice",
      "type": "string"
    },
    "confidence": {
      "description": "Confidence in the selected choice, from 0 to 1. Higher values indicate greater certainty; use lower values to flag uncertain selections for review.",
      "examples": [
        0.9
      ],
      "title": "Confidence",
      "type": "number"
    },
    "probabilities": {
      "additionalProperties": {
        "type": "number"
      },
      "description": "Probability of each choice in criteria, keyed by choice name, from 0 to 1. Shows how likely the alternatives are; values sum to approximately 1.",
      "examples": [
        {
          "angry": 0.8,
          "calm": 0.1,
          "excited": 0.1
        }
      ],
      "title": "Probabilities",
      "type": "object"
    }
  },
  "required": [
    "choice",
    "confidence",
    "probabilities"
  ],
  "title": "ChoiceAnswer",
  "type": "object"
}

Config:

  • extra: ignore
  • frozen: True
  • strict: True

Fields:

choice

pydantic-field

choice : [str](https://docs.python.org/3/builtins/stdtypes.html#str) \n

The name of the choice with the highest probability among the question's criteria.

confidence

pydantic-field

confidence : [float](https://docs.python.org/3/builtins/functions.html#float) \n

Confidence in the selected choice, from 0 to 1. Higher values indicate greater certainty; use lower values to flag uncertain selections for review.

probabilities

pydantic-field

probabilities : [dict](https://docs.python.org/3/builtins/stdtypes.html#dict) [ [str](https://docs.python.org/3/builtins/stdtypes.html#str) , [float](https://docs.python.org/3/builtins/functions.html#float) ] \n

Probability of each choice in criteria, keyed by choice name, from 0 to 1. Shows how likely the alternatives are; values sum to approximately 1.

model\_config

class-attribute instance-attribute

model_config = ConfigDict(
    extra="ignore", frozen=True, strict=True
)

typesafe\_sdk.ScoreAnswer

pydantic-model

Bases: wire.ScoreAnswer

An expected score with its rubric and probabilities.

See the score primitive for details.

Note

Show JSON schema:

Details

{
  "description": "An expected score with its rubric and probabilities.\n\nSee the [score primitive](https://docs.typesafe.ai/primitives/score) for details.",
  "properties": {
    "type": {
      "const": "score",
      "default": "score",
      "title": "Type",
      "type": "string"
    },
    "score": {
      "description": "Expected score: the probability-weighted average of the rubric levels. May fall between integer levels.",
      "examples": [
        1.7
      ],
      "title": "Score",
      "type": "number"
    },
    "confidence": {
      "description": "Confidence in the score, from 0 to 1. Higher values indicate greater certainty; use lower values to flag uncertain ratings for review.",
      "examples": [
        0.9
      ],
      "title": "Confidence",
      "type": "number"
    },
    "legend": {
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "additionalProperties": true,
            "type": "object"
          },
          {
            "items": {},
            "type": "array"
          }
        ]
      },
      "title": "Legend",
      "type": "object"
    },
    "probabilities": {
      "additionalProperties": {
        "type": "number"
      },
      "title": "Probabilities",
      "type": "object"
    }
  },
  "required": [
    "score",
    "confidence",
    "legend",
    "probabilities"
  ],
  "title": "ScoreAnswer",
  "type": "object"
}

Config:

  • extra: ignore
  • frozen: True
  • strict: True

Fields:

score

pydantic-field

score : [float](https://docs.python.org/3/builtins/functions.html#float) \n

Expected score: the probability-weighted average of the rubric levels. May fall between integer levels.

confidence

pydantic-field

confidence : [float](https://docs.python.org/3/builtins/functions.html#float) \n

Confidence in the score, from 0 to 1. Higher values indicate greater certainty; use lower values to flag uncertain ratings for review.

model\_config

class-attribute instance-attribute

model_config = ConfigDict(
    extra="ignore", frozen=True, strict=True
)

legend

pydantic-field

legend: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[\n [int](https://docs.python.org/3/builtins/functions.html#int), [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[Any](https://docs.python.org/3/library/typing.html#typing.Any)]\n]\n

Rubric descriptions keyed by integer score.

probabilities

pydantic-field

probabilities : [dict](https://docs.python.org/3/builtins/stdtypes.html#dict) [ [int](https://docs.python.org/3/builtins/functions.html#int) , [float](https://docs.python.org/3/builtins/functions.html#float) ] \n

Probabilities keyed by integer score.

typesafe\_sdk.Answer

module-attribute

Answer: [TypeAlias](https://docs.python.org/3/library/typing.html#typing.TypeAlias) = [Annotated](https://docs.python.org/3/library/typing.html#typing.Annotated)[\n [NoulAnswer](responses.md#typesafe_sdk.NoulAnswer) | [ChoiceAnswer](responses.md#typesafe_sdk.ChoiceAnswer) | [ScoreAnswer](responses.md#typesafe_sdk.ScoreAnswer),\n Field(discriminator=\"type\"),\n]\n

An answer to a single question, identified by its type.

Available models

typesafe\_sdk.ListModelsResponse

pydantic-model

Bases: Response

The models available to the account.

Note

Show JSON schema:

Details

{
  "$defs": {
    "ModelMetadata": {
      "description": "Metadata describing a single available model.",
      "properties": {
        "name": {
          "title": "Name",
          "type": "string"
        },
        "description": {
          "title": "Description",
          "type": "string"
        },
        "release_date": {
          "title": "Release Date",
          "type": "string"
        }
      },
      "required": [
        "name",
        "description",
        "release_date"
      ],
      "title": "ModelMetadata",
      "type": "object"
    }
  },
  "description": "The models available to the account.",
  "properties": {
    "models": {
      "items": {
        "$ref": "#/$defs/ModelMetadata"
      },
      "title": "Models",
      "type": "array"
    }
  },
  "required": [
    "models"
  ],
  "title": "ListModelsResponse",
  "type": "object"
}

Fields:

request\_id

cached property

request_id : [str](https://docs.python.org/3/builtins/stdtypes.html#str) \n

The x-typesafe-request-id response header.

raw\_http\_response

property

raw_http_response: httpx2.Response

The underlying httpx2.Response, exposing status, headers, and body.

model\_config

class-attribute instance-attribute

model_config = ConfigDict(
    extra="ignore", frozen=True, strict=True
)

models

pydantic-field

models : [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple) [ [ModelMetadata](responses.md#typesafe_sdk.ModelMetadata) , ... ] \n

The available models.

typesafe\_sdk.ModelMetadata

pydantic-model

Bases: Schema

Metadata describing a single available model.

Note

Show JSON schema:

Details

{
  "description": "Metadata describing a single available model.",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "type": "string"
    },
    "release_date": {
      "title": "Release Date",
      "type": "string"
    }
  },
  "required": [
    "name",
    "description",
    "release_date"
  ],
  "title": "ModelMetadata",
  "type": "object"
}

Fields:

name

pydantic-field

name : [str](https://docs.python.org/3/builtins/stdtypes.html#str) \n

Model name or alias accepted by a request's model field.

description

pydantic-field

description : [str](https://docs.python.org/3/builtins/stdtypes.html#str) \n

Human-readable description of the model and its capabilities.

release\_date

pydantic-field

release_date : [str](https://docs.python.org/3/builtins/stdtypes.html#str) \n

Model release date, formatted as YYYY-MM-DD.