# Jev (TypeSafe)
> TypeSafe Jev models power the prompt_jev SQL function for typed, calibrated decisions over text in MotherDuck.
[TypeSafe](https://typesafe.ai) builds Jev, a model that answers closed questions about text. Unlike a standard large language model (LLM), Jev returns no prose: it returns a probability, a choice from a list you supply, or a position on an ordered scale, each with calibrated probabilities. MotherDuck provides access to Jev as part of the [AI functions](/sql-reference/motherduck-sql-reference/ai-functions/) through the [`prompt_jev`](/sql-reference/motherduck-sql-reference/ai-functions/prompt-jev/) SQL function.

:::info[Preview]
The TypeSafe integration is in [preview](/about-motherduck/feature-stages/). Behavior and the function interface may change.
:::

## How it works with MotherDuck

MotherDuck provides access to TypeSafe and calls the API on your behalf when a query uses `prompt_jev`. You don't need a TypeSafe account or API key.

A request is sent for any non-`NULL` input rows. Single-question calls batch multiple rows into each request by default.

```sql
SELECT prompt_jev(
    body, -- "I can't find my latest invoice."
    'Which team should handle this?',
    choice := ['billing', 'technical', 'sales']
).choice AS team
FROM support_messages;
```

To learn more about using Jev, look at our tutorials on [classifying text](/key-tasks/ai-and-motherduck/classify-text-with-prompt-jev/) or [using Jev's confidence number for triaging](/key-tasks/ai-and-motherduck/triage-classifications-by-confidence/). TypeSafe's own documentation also has [some great use cases and examples](https://docs.typesafe.ai/concepts/use-case-map#example-task-categories).

## Prerequisites

- A MotherDuck organization on the Lite or Business plan. AI functions are not available on the Free plan.
- Nothing else. No token, account, or network configuration on the TypeSafe side.

## What MotherDuck sends

Each row produces one HTTPS request to the TypeSafe API containing:

- The `input` text for that row
- Your `instructions` string, or the full `questions` object for a multi-question call
- Your `choice` or `score` labels and descriptions, when supplied
- The model alias `jev-latest`

TypeSafe returns the answer and a token count. MotherDuck records the token count for metering and discards the rest.

:::warning[Data residency]
Requests go to TypeSafe's API rather than to an AI endpoint inside your MotherDuck organization's region. Text you pass to `prompt_jev` leaves your organization's region. If your data residency requirements do not allow this, [contact support](/troubleshooting/support/) before using `prompt_jev`.
:::

## Turning the integration off

An organization admin can have `prompt_jev` disabled for the whole organization independently of the other AI functions. [Contact support](/troubleshooting/support/) to request it. Queries that call the function then fail with:

```text
AI functions are not available for your organization. If you are on the Free plan,
upgrade to Lite or Business. Otherwise contact your organization admin.
```

Disabling AI functions for the organization disables `prompt_jev` as well.

## When to use Jev instead of a language model

- **Use `prompt_jev`** when the set of answers is fixed and you need the decision, not an explanation: routing, labelling, flagging, rating against a rubric, or filtering a table down to the rows that match a description. It's faster and cheaper per row than a language model, and it returns calibrated probabilities you can threshold on.
- **Use [`prompt`](/sql-reference/motherduck-sql-reference/ai-functions/prompt/)** when you need generated text, a summary, or extraction of values you can't enumerate in advance.

The two compose well. A common pattern is to run `prompt_jev` over the whole table, then send only the low-confidence rows to `prompt`. See [Triage classifications by confidence](/key-tasks/ai-and-motherduck/triage-classifications-by-confidence/).

## Billing

Usage is metered on input tokens only; output tokens are free. It counts against the same Advanced AI function budget as `prompt` and `embedding`, which has a default soft limit of 10 AI Units per day on Lite and Business plans. See [AI function pricing](/about-motherduck/billing/pricing#ai-function-pricing).

## Known limitations

- The input is a single text value per row. TypeSafe's API accepts structured state, but `prompt_jev` sends a string. Concatenate multiple fields into one labelled string.
- No model parameter. Requests always use the `jev-latest` alias.
- `instructions`, `choice`, `score`, `noul`, and `questions` must be query constants. They can't come from a column.

## Related content

- [`prompt_jev` SQL reference](/sql-reference/motherduck-sql-reference/ai-functions/prompt-jev/)
- [Classify text with prompt_jev](/key-tasks/ai-and-motherduck/classify-text-with-prompt-jev/)
- [TypeSafe documentation](https://docs.typesafe.ai)


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `GET https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

URL-encode query parameter values and send a GET request:

```text
GET https://motherduck.com/docs/api/feedback/agent?page_path=%2Fintegrations%2Fdata-science-ai%2Ftypesafe%2F&page_title=Jev%20%28TypeSafe%29&text=<url-encoded user feedback, max 2000 characters>
```

Optionally append `&source=<url-encoded interface identifier>` such as `claude.ai` or `chatgpt`.

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed query parameters, and `429` when rate-limited.
