> ## Documentation Index
> Fetch the complete documentation index at: https://docs.barndoor.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Calling Jev Through the Gateway

> Call TypeSafe's Jev classifier through the Barndoor LLM Gateway with TypeSafe's own SDKs, so classification traffic gets the same API keys, budgets, audit trail, and usage reporting as your chat models.

[Jev](https://docs.typesafe.ai/) is TypeSafe's **System One** model. It is a classifier, not a chat model: you send it some content (the `state`) and a set of typed questions, and it answers each question with probabilities. For example, "is this ticket about billing?" comes back as `0.97`, not as a sentence.

The gateway serves Jev on TypeSafe's own endpoint, `POST /v1/systemone`, with TypeSafe's request and response format unchanged. So TypeSafe's Python and JavaScript SDKs work against Barndoor once you change their base URL and API key.

<Info>
  Jev answers **only** on `/v1/systemone`. It does not answer `/chat/completions`, `/responses`, or `/messages`. On **My Models**, Jev routes and models carry a **Classifier** badge so they aren't mistaken for chat models.
</Info>

## Before you start

An admin needs to make Jev available in **LLM Management**. There are two ways to serve it:

* **TypeSafe AI provider.** Add the **TypeSafe AI** provider with a TypeSafe API key from the [TypeSafe console](https://console.typesafe.ai/), and enable `jev-latest`, or a pinned version such as `jev-1.13.0` if you need answers that don't change when TypeSafe releases a new model.
* **OpenRouter.** OpenRouter also serves Jev, as `~typesafe/jev-latest`. Enable that model on an OpenRouter provider.

Optionally, create a **model route** for Jev (for example `jev`) so callers use one stable name, and the route can fail over between TypeSafe and OpenRouter.

A few rules apply, and the gateway enforces them when you save:

* **A route holds Jev or chat models, never both.** A request that failed over from one kind to the other would fail, so the gateway refuses a mixed route. In the **Create Model Route** and **Add Targets** dialogs, models of the other kind are disabled.
* **Jev can't be a routing-policy slot.** A slot has to answer chat.
* **Jev can be a routing policy's determiner.** See [Routing Policies](/how-tos/llm-routing-policies#using-jev-as-the-determiner).

## Find the name to call

Open **Settings → My Models**. A Jev route, or a Jev model listed under **Standalone Models**, carries a **Classifier** badge. Use its name in the `model` field: the route name (for example `jev`), or `<provider name>/<model>` for a standalone model. The copy button next to each name gives you the exact string.

When you can see a Jev model, **Gateway Endpoint** also lists the System One URL:

```text theme={null}
https://app.barndoor.ai/api/llm-gateway/v1/systemone
```

## Call Jev

Authenticate with a Barndoor gateway API key (`bd-…`), the same as for chat models.

TypeSafe's SDKs add `/v1/systemone` themselves, so give them the gateway URL **without** `/v1`: `https://app.barndoor.ai/api/llm-gateway`.

<Tabs>
  <Tab title="Python">
    Install TypeSafe's SDK with `pip install typesafe-sdk` (or `uv add typesafe-sdk`).

    ```python theme={null}
    import os

    from typesafe_sdk import Noul, TypeSafeClient

    with TypeSafeClient(
        api_key=os.environ["BARNDOOR_API_KEY"],
        base_url="https://app.barndoor.ai/api/llm-gateway",
        model="jev",  # your Jev route, or "<provider name>/jev-latest"
    ) as client:
        result = client.system_one(
            "I was charged twice. Please fix this ASAP.",
            {"billing": Noul(instructions="Is this ticket about billing?")},
        )
        print(result.nouls["billing"].noul)
    ```

    You can also set `TYPESAFE_BASE_URL` and `TYPESAFE_API_KEY` in the environment instead of passing them.
  </Tab>

  <Tab title="JavaScript">
    Install TypeSafe's SDK with `npm install @typesafe-ai/sdk` (Node.js 20 or newer).

    ```ts theme={null}
    import { choice, TypeSafeClient } from "@typesafe-ai/sdk";

    const client = new TypeSafeClient({
      apiKey: process.env.BARNDOOR_API_KEY,
      baseURL: "https://app.barndoor.ai/api/llm-gateway",
      defaultModel: "jev", // your Jev route, or "<provider name>/jev-latest"
    });

    const response = await client.systemOne({
      state: { document: "I was charged twice. Please fix this ASAP." },
      questions: {
        category: choice("What is this ticket about?", {
          billing: null,
          technical: null,
          other: null,
        }),
      },
    });

    console.log(response.answers.category.choice);
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl https://app.barndoor.ai/api/llm-gateway/v1/systemone \
      -H "Authorization: Bearer $BARNDOOR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "jev",
        "state": "Help! My payouts have been failing for 3 days.",
        "questions": {
          "is_urgent": { "type": "noul", "instructions": "Does this convey urgency?" }
        }
      }'
    ```
  </Tab>
</Tabs>

Replace `app.barndoor.ai` with your own Barndoor host if you have one. The request body and the answers are TypeSafe's format: see TypeSafe's [API reference](https://docs.typesafe.ai/api) for the question types (`noul`, `choice`, `score`) and how to read the answers.

## Usage and cost

Jev requests appear in LLM usage reporting like any other model, with the same user, API key, and budget attribution. TypeSafe charges for input tokens only, so Jev's output tokens are recorded but priced at zero.

## Troubleshooting

<AccordionGroup>
  <Accordion title="A Jev model fails when called from a chat client">
    Jev answers only on `/v1/systemone`. Sending its name to `/chat/completions`, `/responses`, or `/messages` returns a `400` saying the provider does not support that endpoint and to send Jev to `POST /v1/systemone`. Call it with TypeSafe's SDK or the `/v1/systemone` endpoint instead.
  </Accordion>

  <Accordion title="The SDK gets a 401 with &#x22;invalid JWT header&#x22;">
    Check the base URL. TypeSafe's SDKs add `/v1/systemone` themselves, so a base URL ending in `/v1` sends the request to `/v1/v1/systemone`, which isn't a gateway API path, and the gateway rejects your API key there. Use `https://app.barndoor.ai/api/llm-gateway`.
  </Accordion>

  <Accordion title="I can't add Jev to an existing route">
    That route holds chat models, and a route can't mix the two. Create a separate route for Jev.
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.