# LibreChat

> Add the gateway to LibreChat as a custom endpoint in librechat.yaml, with the key in your .env file and the model list fetched from the API.

Source: https://oneaiapikey.com/docs/apps/librechat

[LibreChat](https://www.librechat.ai) is a self-hosted chat interface configured with a `librechat.yaml` file. The gateway goes in as a custom endpoint. Checked against LibreChat v0.8.8.

You need an API key from [API keys](https://oneaiapikey.com/console/keys) and this base URL:

Base URL `https://api.oneaiapikey.com/v1`

## Add the endpoint

1. Put the key in LibreChat’s `.env` file:

   .env:

   ```bash
   RELAYKIT_API_KEY=<your Relaykit key>
   ```
2. Add the endpoint under `endpoints.custom` in `librechat.yaml`. Keep the rest of your file as it is.

   librechat.yaml:

   ```yaml
   endpoints:
     custom:
       - name: "Relaykit"
         apiKey: "${RELAYKIT_API_KEY}"
         baseURL: "https://api.oneaiapikey.com/v1"
         models:
           default: ["claude-haiku-4-5", "claude-sonnet-5-5"]
           fetch: true
         titleConvo: true
         titleModel: "claude-haiku-4-5"
         modelDisplayLabel: "Relaykit"
   ```
3. Restart LibreChat. With Docker, make sure `librechat.yaml` is mounted into the container (LibreChat’s docs use a `docker-compose.override.yml` for this).
4. Choose **Relaykit** in the endpoint menu, pick a model and send a message. The request shows up on your [usage page](https://oneaiapikey.com/console/usage).

## What the settings do

- `apiKey: “${RELAYKIT_API_KEY}”` reads the key from `.env`, so it never sits in the YAML file.
- `baseURL` must end in `/v1`.
- `fetch: true` loads the model list from the gateway; `default` is the list shown if fetching fails.
- `titleModel` is the model that names each conversation. A fast, cheap model is enough, and saves money on every new chat.

## Troubleshooting

- **The endpoint does not appear**: LibreChat did not load the file. Check its startup log for YAML errors and that the file is mounted.
- **401 errors**: the variable name in `apiKey` does not match the one in `.env`, or the key was revoked.
- **A model fails with 403**: the key’s model list does not include it, or your balance is empty. See [Errors](https://oneaiapikey.com/docs/errors#access-denied).

> **Source:** Settings follow LibreChat’s reference for [custom endpoints](https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/custom_endpoint). Check there for every other option.
