---
title: Query models with the TypeSafe System One API
description: Learn how to query a System One model service on Databricks using the TypeSafe API and typed noul, choice, and score questions.
canonical_url: https://docs.databricks.com/aws/en/machine-learning/model-serving/query-systemone-models
---

# Query models with the TypeSafe System One API

TypeSafe's System One API is a request and response format for evaluating application state against typed questions and returning structured answers. On Databricks, you send System One requests through Unity Gateway to a Unity Catalog model service. The model behind the service can be hosted by Databricks or by TypeSafe AI, Inc.:

* [OpenJev (Qwen3.5 4B)](https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/supported-models.md#openjev-qwen35-4b) is an open model based on Qwen3.5 and hosted by Databricks.
* [TypeSafe AI Jev 1.14.0](https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/supported-models.md#typesafe-ai-jev-1-14-0) is hosted by TypeSafe AI, Inc. and served through Unity Gateway. To use it, an account admin must turn on the **TypeSafe AI Models** preview in the account console. TypeSafe AI's terms govern its use.

  See [Provider-hosted models](https://docs.databricks.com/aws/en/machine-learning/model-serving/acceptable-use-models.md#provider-hosted-models).

Use the System One API when an application needs a compact, structured decision instead of generated prose. It can be a good fit when response time matters, for example to decide whether a request needs escalation, choose a routing label, or score it against a rubric. Response time depends on the model service and request load.

For decisions over table rows in SQL, see the [`ai_decide` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_decide.md).

## Requirements

* A workspace enabled for Unity Catalog and Unity Gateway.
* A Unity Catalog model service backed by a System One-compatible model. The example uses the `openjev-qwen35-4b` model service, whose fully qualified name is `system.ai.openjev-qwen35-4b`.
* Permission to execute the model service.
* To use TypeSafe AI Jev 1.14.0, an account admin must turn on the **TypeSafe AI Models** preview in the account console. See [ Manage account-level previews](https://docs.databricks.com/aws/en/admin/workspace-settings/manage-previews.md#account).

The System One route requires a Unity Catalog model service. It does not support a model provider service or a non-Unity Catalog serving endpoint.

## Query a model service

The request body contains the fully qualified model service name, the state to evaluate, and one or more named questions. Each question uses one of the `noul`, `choice`, or `score` types.

The following request includes one question of each type:

```bash
curl \
-u token:$DATABRICKS_TOKEN \
-X POST \
-H "Content-Type: application/json" \
-d '{
  "model": "system.ai.openjev-qwen35-4b",
  "state": {
    "message": "My card was charged twice for the same order and I need a refund.",
    "channel": "support"
  },
  "questions": {
    "is_billing": {
      "type": "noul",
      "instructions": "Is this a billing-related request?",
      "criteria": {
        "true": "The message concerns a charge, payment, invoice, or refund.",
        "false": "The message does not concern billing."
      }
    },
    "intent": {
      "type": "choice",
      "instructions": "Which intent best matches the message?",
      "criteria": {
        "refund": "The customer requests a refund.",
        "duplicate_charge": "The customer reports being charged more than once.",
        "other": "Another request."
      }
    },
    "urgency": {
      "type": "score",
      "instructions": "How urgent is the request?",
      "criteria": [
        "Can wait",
        "Needs attention soon",
        "Urgent"
      ]
    }
  }
}' \
https://<workspace_host>/ai-gateway/typesafe/v1/systemone
```

Use the fully qualified Unity Catalog model service name, `system.ai.openjev-qwen35-4b`, in the request's `model` field.

## Request fields

| Field       | Type                     | Description                                                                                                         |
| ----------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------- |
| `model`     | String                   | The fully qualified Unity Catalog model service name, such as `system.ai.openjev-qwen35-4b`.                        |
| `state`     | String, object, or array | The content to evaluate. Use a string for text or structured data for records, conversations, or application state. |
| `questions` | Object                   | A non-empty map of question IDs to question definitions. The response uses the same IDs in the `answers` object.    |

Each question has a `type`, optional `instructions`, and type-specific `criteria`:

### Noul questions

A `noul` question returns the probability that the answer is yes. The optional `criteria` object describes what `true` and `false` mean. Provide either `instructions` or a description for `true` or `false`. The response contains a `noul` number from 0 (no) to 1 (yes).

### Choice questions

A `choice` question selects one option from the `criteria` object. Each option maps to a description or to `null` when no additional description is needed. Define 1 to 255 options. The response contains the selected `choice`, a probability for every option, and a `confidence` value.

### Score questions

A `score` question rates the state against an ordered `criteria` array. The response contains a probability-weighted `score`, a `legend` that maps level indexes to the criteria, probabilities for each level, and a `confidence` value. Define 1 to 10 levels.

## <a id="response-format" />Response format

The response contains the model identifier and one answer for each question in `answers`. Token usage appears in `usage`, with `input_tokens` and `output_tokens`:

```json
{
  "model": "<returned-model-id>",
  "answers": {
    "is_billing": {
      "type": "noul",
      "noul": 0.98
    },
    "intent": {
      "type": "choice",
      "choice": "duplicate_charge",
      "confidence": 0.965,
      "probabilities": {
        "refund": 0.023,
        "duplicate_charge": 0.977,
        "other": 0.0002
      }
    },
    "urgency": {
      "type": "score",
      "score": 1.902,
      "confidence": 0.852,
      "legend": {
        "0": "Can wait",
        "1": "Needs attention soon",
        "2": "Urgent"
      },
      "probabilities": {
        "0": 0.0069,
        "1": 0.0845,
        "2": 0.9086
      }
    }
  },
  "usage": {
    "input_tokens": 238,
    "output_tokens": 0
  }
}
```

This response is based on the request above, with numeric values rounded. Answers, probabilities, confidence values, token counts, and the returned model identifier vary by request and backend. The response `model` value identifies the model reported by the backend and can differ from the request's fully qualified model service name.

## Request errors

For request validation errors, the route returns HTTP `422` with a `detail` array that describes the invalid request.

## Additional resources

* [Provider-native APIs](https://docs.databricks.com/aws/en/machine-learning/model-serving/provider-native-apis.md)
* [Query model services](https://docs.databricks.com/aws/en/ai-gateway/query-model-services.md)
* [TypeSafe API reference](https://docs.typesafe.ai/api)
