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

# Portkey

> Route Portkey traffic to Prentis as a custom OpenAI-compatible host.

Prentis is not in Portkey's built-in provider list. It does not need to be: Portkey can
send requests to any OpenAI-compatible host, and that is what this API is. You keep your
Portkey key, logs, configs and guardrails; the model calls land here and are billed by us.

There are two ways to wire it up. Use the first unless you are only trying it out.

## Option 1: Add Prentis as a provider

Do this once per Portkey workspace.

1. In Portkey, open the [Model Catalog](https://app.portkey.ai/model-catalog/providers)
   and click **Add Provider**.
2. Choose the self-hosted / custom option rather than a provider from the list.
3. Set the API specification to **OpenAI**.
4. Set **Custom Host** to `https://compute.prentis.ai/v1`. Keep the `/v1` — Portkey
   appends `/chat/completions` and the other paths itself.
5. Add an authentication header `Authorization` with the value `Bearer <your Prentis API key>`.
   Keys are created in the [console](https://compute.prentis.ai) under **API Keys**.
6. Name the provider. The slug you choose is how your code refers to it; this page uses
   `prentis`.

Then call it with your **Portkey** key and that slug:

```python theme={null}
import os

from portkey_ai import Portkey

portkey = Portkey(
    api_key=os.environ["PORTKEY_API_KEY"],
    provider="@prentis",
)

response = portkey.chat.completions.create(
    model="deepseek-v4.1-flash",
    messages=[{"role": "user", "content": "Say hello."}],
)
```

The `model` value is passed to us unchanged, so it is a Prentis model name. See
[Models and resource names](https://docs.compute.prentis.ai/models-and-resource-names.md) for where to find them.

## Option 2: Per-request headers

Nothing is saved in Portkey; every request says where to go. Useful for a first test.

```bash theme={null}
curl https://api.portkey.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "x-portkey-api-key: $PORTKEY_API_KEY" \
  -H "x-portkey-provider: openai" \
  -H "x-portkey-custom-host: https://compute.prentis.ai/v1" \
  -H "Authorization: Bearer $PRENTIS_API_KEY" \
  -H "x-portkey-forward-headers: Authorization" \
  -d '{
    "model": "deepseek-v4.1-flash",
    "messages": [{"role": "user", "content": "Say hello."}]
  }'
```

`x-portkey-provider: openai` names the API shape, not the vendor. The request still goes
to the custom host.

## Costs in the Portkey dashboard

Portkey does not know our prices, so out of the box its dashboard shows token counts for
Prentis models but not spend. To see spend there, open the provider in Portkey, go to
**Model Provisioning**, edit the model and enter its input and output cost per million
tokens.

That number is for Portkey's dashboard only. What you are charged is what Prentis bills,
from the `usage` on each response — see [Usage and billing](https://docs.compute.prentis.ai/usage-and-billing.md).

## When it does not work

| Symptom | Likely cause |
| - | - |
| `404` on every call, not `MODEL_NOT_FOUND` | Custom host is missing `/v1`, or has a path after it |
| `401` `INVALID_API_KEY` | The `Authorization` header holds the Portkey key, not the Prentis key |
| `404` `MODEL_NOT_FOUND` | The `model` value is a Portkey or OpenAI name rather than a Prentis one |

Errors from Prentis carry the codes listed in [Errors](https://docs.compute.prentis.ai/errors.md).

Portkey's own reference for this setup is
[Bring Your Own LLM](https://portkey.ai/docs/integrations/llms/byollm).


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