> For the complete documentation index, see [llms.txt](https://docs.tensorx.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tensorx.ai/chat-interfaces/librechat.md).

# LibreChat

Configure LibreChat to use TensorX as an OpenAI-compatible provider.

***

## What is LibreChat?

[LibreChat](https://www.librechat.ai/) is a self-hosted chat interface that supports custom OpenAI-compatible providers.

***

## Prerequisites

* LibreChat installed and running (follow the [official LibreChat installation guide](https://www.librechat.ai/docs/configuration/docker_override))
* A TensorX API key ([sign up here](https://app.tensorx.ai))

***

## Configuration

### Step 1: Add Your API Key

Add your TensorX API key to LibreChat's `.env` file:

```bash
TENSORX_API_KEY=your-tensorx-api-key-here
```

### Step 2: Configure the TensorX Endpoint

Create or edit your `librechat.yaml` file:

```yaml
version: 1.1.7
cache: true

endpoints:
  custom:
    - name: "TensorX AI"
      apiKey: "${TENSORX_API_KEY}"
      baseURL: "https://api.tensorx.ai/v1"
      models:
        default:
          - "<MODEL_ID>"
        fetch: true
      titleConvo: true
      titleModel: "<MODEL_ID>"
      summarize: false
      summaryModel: "z-ai/glm-5.2"
      forcePrompt: false
      modelDisplayLabel: "TensorX AI"
      dropParams: ["user"]
```

Replace both `<MODEL_ID>` values with an ID returned by `GET /v1/models`.

### Step 3: Mount the Configuration

Add this to your `docker-compose.override.yml`:

```yaml
services:
  api:
    volumes:
      - ./librechat.yaml:/app/librechat.yaml:ro
```

### Step 4: Restart LibreChat

```bash
docker compose restart api
```

***

## Using TensorX in LibreChat

1. Open LibreChat in your browser
2. Start a new conversation
3. Click the model selector dropdown
4. Select **TensorX AI** as the provider
5. Choose your preferred model

***

## Model selection

Call `GET /v1/models` with your TensorX API key and use one of the returned IDs. If the integration depends on a capability or token limit, query `GET /v1/model/info` before selecting the model. See [Models](/api-reference/models.md) for examples.

***

## Advanced Configuration

### Auto-Fetch All Models

To automatically discover all available TensorX models:

```yaml
models:
  fetch: true
  default:
    - "<MODEL_ID>"
```

### Custom Parameters

```yaml
endpoints:
  custom:
    - name: "TensorX AI"
      apiKey: "${TENSORX_API_KEY}"
      baseURL: "https://api.tensorx.ai/v1"
      models:
        default:
          - "<MODEL_ID>"
        fetch: false
      default: ["max_tokens", "temperature", "top_p"]
      additionalParameters:
        temperature: 0.7
        top_p: 0.9
```

***

## Configuration Options

| Option           | Description                                        |
| ---------------- | -------------------------------------------------- |
| `apiKey`         | Your TensorX API key from environment variables    |
| `baseURL`        | TensorX API endpoint (`https://api.tensorx.ai/v1`) |
| `models.default` | List of models shown in the dropdown               |
| `fetch`          | Set `true` to auto-fetch available models          |
| `titleConvo`     | Auto-generate conversation titles                  |
| `titleModel`     | Model used for titles                              |
| `dropParams`     | Remove parameters that may cause issues            |

***

## Troubleshooting

### Models Not Appearing

1. Verify your API key is set in `.env`
2. Check that `librechat.yaml` is properly mounted
3. Restart the API container: `docker compose restart api`
4. Check logs: `docker compose logs api`

### Test Your API Key

```bash
curl https://api.tensorx.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "<MODEL_ID>",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
```

### Configuration Not Loading

* Use proper YAML indentation (2 spaces)
* Verify quotes around strings
* Check version number matches your LibreChat version

***

## Best Practices

1. **Limit your model list** - Only include models you use
2. **Secure your API key** - Never commit `.env` files to version control
3. **Monitor usage** - Track API usage in your [TensorX dashboard](https://app.tensorx.ai/dashboard)

***

## Resources

* [LibreChat Documentation](https://www.librechat.ai/docs)
* [LibreChat Custom Endpoints Guide](https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/custom_endpoint)
* [TensorX Models & Pricing](https://tensorx.ai/models)
* [TensorX API Examples](/api-reference/api-examples.md)

***

## Need Help?

* **Email**: <support@tensorx.ai>
* **Contact Support**: [Contact page](/support/support.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tensorx.ai/chat-interfaces/librechat.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
