---
title: "Provider: TypeSafe"
subtitle: "Call TypeSafe Jev through Respan Gateway with unified logs and latency."
---

<Note>This page is for **Respan LLM Gateway** users.</Note>

Use Respan Gateway to call [TypeSafe](https://typesafe.ai)'s Jev, a System One model for structured decisions. Send application state and typed questions, then use the returned answers in your code.

## Quick setup

TypeSafe requires **bring your own key (BYOK)**. Respan gateway credits cannot be used for TypeSafe requests.

<Steps>
  <Step title="Get a Respan API key">
    [Sign up](https://platform.respan.ai) and create a key on the [API keys page](https://platform.respan.ai/platform/gateway/api-keys).
  </Step>
  <Step title="Get a TypeSafe API key">
    Create a key in the [TypeSafe console](https://console.typesafe.ai).
  </Step>
  <Step title="Choose how to provide your TypeSafe key">
    <Tabs>
      <Tab title="Global (UI)">
        Open the [Providers page](https://platform.respan.ai/platform/gateway/api-keys?providers=1), select **TypeSafe**, then **Add deployment** to save your key.

        Omit `respan_params.credential_override` from requests to use the saved key.
      </Tab>
      <Tab title="Per-request (Code)">
        Pass your key in `respan_params.credential_override`, as shown below. This overrides the saved key for that model. Respan removes `respan_params` before forwarding the request to TypeSafe.
      </Tab>
    </Tabs>
  </Step>
</Steps>

## Send your first request

Call `POST https://api.respan.ai/api/typesafe/v1/systemone`. The examples use `RESPAN_API_KEY` for the `Authorization` header and pass `TYPESAFE_API_KEY` with each request.

<Note>
  TypeSafe uses a dedicated endpoint with `state` and `questions`. OpenAI Chat Completions and streaming are not supported on this endpoint.
</Note>

<Tabs>
<Tab title={"Python"}>

```python
import os
import requests

response = requests.post(
    "https://api.respan.ai/api/typesafe/v1/systemone",
    headers={
        "Authorization": f"Bearer {os.environ['RESPAN_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "respan_params": {
            "credential_override": {
                "jev-1.13.0": {"api_key": os.environ["TYPESAFE_API_KEY"]}
            }
        },
        "model": "typesafe/jev-1.13.0",
        "state": "I want a refund.",
        "questions": {
            "is_refund": {
                "type": "noul",
                "instructions": "Is the customer asking for a refund?",
            }
        },
    },
)
response.raise_for_status()
print(response.json()["answers"]["is_refund"]["noul"])
```

</Tab>
<Tab title={"TypeScript"}>

```typescript
const response = await fetch("https://api.respan.ai/api/typesafe/v1/systemone", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RESPAN_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    respan_params: {
      credential_override: {
        "jev-1.13.0": { api_key: process.env.TYPESAFE_API_KEY },
      },
    },
    model: "typesafe/jev-1.13.0",
    state: "I want a refund.",
    questions: {
      is_refund: {
        type: "noul",
        instructions: "Is the customer asking for a refund?",
      },
    },
  }),
});

if (!response.ok) {
  throw new Error(`TypeSafe request failed (${response.status}): ${await response.text()}`);
}

const data = await response.json();
console.log(data.answers.is_refund.noul);
```

</Tab>
<Tab title={"cURL"}>

```bash
curl https://api.respan.ai/api/typesafe/v1/systemone \
  -H "Authorization: Bearer $RESPAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "respan_params": {
      "credential_override": {
        "jev-1.13.0": {"api_key": "'"$TYPESAFE_API_KEY"'"}
      }
    },
    "model": "typesafe/jev-1.13.0",
    "state": "I want a refund.",
    "questions": {
      "is_refund": {
        "type": "noul",
        "instructions": "Is the customer asking for a refund?"
      }
    }
  }'
```

</Tab>
</Tabs>

The `noul` answer is a probability between 0 and 1. Answers are returned under the same names you supplied in `questions`.

A `401` response can mean the TypeSafe key is missing or invalid; a `403` response can mean the Respan key is missing or invalid.

## Supported question types

You can combine these question types in one request:

| Type | Use case | Answer fields |
| --- | --- | --- |
| `noul` | Evaluate a yes/no question | `noul` |
| `choice` | Choose from named options | `choice`, `probabilities`, `confidence` |
| `score` | Rate state against an ordered rubric | `score`, `legend`, `probabilities`, `confidence` |

See the [TypeSafe API reference](https://docs.typesafe.ai/api) for question formats and response details.

## Switch models

Use `typesafe/jev-1.13.0` in the `model` field. When changing the TypeSafe model, also update the key in `credential_override` to the model name **without** the `typesafe/` prefix. Check the [Models page](https://platform.respan.ai/platform/models) for models available through Respan.

Learn more about Jev in TypeSafe's [Introducing System One Models & Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev).
