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

# Jev (TypeSafe)

> Connect TypeSafe's Jev model to TrueFoundry's AI Gateway using Custom Endpoints.

[Jev](https://typesafe.ai/) is TypeSafe's System One model for structured decisions. Use [Custom Endpoints](/docs/ai-gateway/custom-endpoints) to keep your TypeSafe credentials on the AI Gateway and call the TypeSafe API with a TrueFoundry API key, access control, and tracing.

### Prerequisites

* Obtain a TypeSafe API key from [TypeSafe](https://typesafe.ai/).
* Get your **TrueFoundry API key** and **gateway base URL**. See [Authentication](/docs/ai-gateway/authentication) and [Gateway base URL](/docs/ai-gateway/quick-start#gateway-base-url).

### Adding an endpoint

<Steps>
  <Step title="Create a Custom Endpoint model account">
    In the TrueFoundry dashboard, go to **AI Gateway** → **Models** → **Custom Endpoints** and click **Add Custom Endpoint**.

    In **Configure Account**, set:

    * **Name**: `jev-account`
    * **Endpoint Type**: `Other`
    * **Header Auth**: leave disabled at the account level; configure it on the endpoint below.

    Click **Continue to Endpoints**.
  </Step>

  <Step title="Add the Jev endpoint">
    Add an integration with:

    * **Display Name**: `jev-endpoint`
    * **Base URL**: `https://api.typesafe.ai` (no trailing slash)

    Enable **Header Auth** and add:

    | Header | Value |
    | - | - |
    | `Authorization` | `Bearer <TYPESAFE_API_KEY>` |

    Replace `<TYPESAFE_API_KEY>` with your TypeSafe key. The AI Gateway injects this header when forwarding requests to `api.typesafe.ai`. Client applications send their **TrueFoundry API key** to the gateway.

    To use a TrueFoundry secret, store the complete value `Bearer <TYPESAFE_API_KEY>` in the secret and set the **Authorization** value to `tfy-secret://tenant:group:TYPESAFE_AUTHORIZATION`. The reference resolves automatically. Do not prefix the reference with `Bearer`.
  </Step>

  <Step title="Set access control and save">
    On the **Access Control** step, choose the users or teams who can manage and use this model account, then **Save**. See [Gateway access control](/docs/ai-gateway/gateway-access-control).
  </Step>
</Steps>

### Making requests

The gateway appends the upstream path to the configured Base URL:

```text theme={"dark"}
{GATEWAY_BASE_URL}/proxy-api/jev-account/jev-endpoint/v1/systemone
```

This forwards to `https://api.typesafe.ai/v1/systemone`. Here, `jev-account` is the account name and `jev-endpoint` is the endpoint Display Name. The remaining `/v1/systemone` path belongs to the TypeSafe API. Replace the account and endpoint segments if you chose different names. See [Endpoint structure](/docs/ai-gateway/custom-endpoints#endpoint-structure).

<Note>
  Use `https://api.typesafe.ai` as the Base URL. TypeSafe uses its own request schema with `model`, `state`, and `questions`. See the [TypeSafe API reference](https://api.typesafe.ai/docs).
</Note>

### Supported APIs

All paths below are appended to `/proxy-api/jev-account/jev-endpoint`. Custom Endpoint requests support [tracing](/docs/ai-gateway/request-logging); cost tracking is unavailable.

| API | Method | Upstream path |
| - | - | - |
| Evaluate questions | `POST` | `/v1/systemone` |
| List available models | `GET` | `/v1/models` |

Use a model name returned by `GET /v1/models` as the request's `model`. The example below uses the documented alias `jev-latest`.

### Example: classify a support message

Send the content in `state` and named questions in `questions`. This example asks a yes/no (`noul`) question about a support message.

Set `GATEWAY_BASE_URL` to your gateway base URL without a trailing slash and `TFY_API_KEY` to your TrueFoundry API key. For Python, install `requests` with `pip install requests`.

<CodeGroup>
  ```python Python lines theme={"dark"}
  import os

  import requests

  gateway_base_url = os.environ["GATEWAY_BASE_URL"].rstrip("/")
  response = requests.post(
      f"{gateway_base_url}/proxy-api/jev-account/jev-endpoint/v1/systemone",
      headers={"Authorization": f"Bearer {os.environ['TFY_API_KEY']}"},
      json={
          "model": "jev-latest",
          "state": {"message": "My subscription was charged twice this month."},
          "questions": {
              "billing": {
                  "type": "noul",
                  "instructions": "Does this message describe a billing issue?",
              }
          },
      },
      timeout=60,
  )
  response.raise_for_status()
  result = response.json()
  print(result["answers"]["billing"]["noul"])
  ```

  ```bash cURL theme={"dark"}
  curl --fail-with-body -X POST "${GATEWAY_BASE_URL}/proxy-api/jev-account/jev-endpoint/v1/systemone" \
    -H "Authorization: Bearer ${TFY_API_KEY}" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "jev-latest",
      "state": {"message": "My subscription was charged twice this month."},
      "questions": {
        "billing": {
          "type": "noul",
          "instructions": "Does this message describe a billing issue?"
        }
      }
    }'
  ```
</CodeGroup>

Responses contain `model`, `answers`, and `usage`. Answers are keyed by question name. In this example, `answers.billing.noul` is the probability of a yes answer, from 0 to 1. TypeSafe also supports `choice` and `score` questions; see the [TypeSafe API reference](https://api.typesafe.ai/docs) for their schemas.


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