How to set up LibreChat with Ozeki AI Gateway

This comprehensive guide walks you through installing and configuring LibreChat on Windows using Docker. By following this tutorial, you'll learn how to clone the LibreChat repository, configure it to connect to Ozeki AI Gateway, mount the configuration into the Docker container, and start having AI-powered conversations.

What is LibreChat?

LibreChat is an open-source, self-hosted chat interface that supports a wide range of AI providers through a unified interface. It offers conversation history, multi-model switching, user management, and a modern chat experience. Because it supports OpenAI-compatible APIs, it works seamlessly with Ozeki AI Gateway, allowing you to route all AI traffic through your own local gateway and use any models available there.

Overview
Overview

Steps to follow

We assume Ozeki AI Gateway is already installed on your system. You can install it on Linux, Windows or Mac.

You will also need Docker Desktop to run LibreChat in a container, and Git to download the LibreChat source code.

  1. Clone the LibreChat repository
  2. Create the environment file
  3. Create and edit the LibreChat config file
  4. Create and edit the Docker Compose override file
  5. Start LibreChat with Docker Compose
  6. Register an account and log in
  7. Select an LLM model and send a test prompt

Quick reference commands

# Clone the LibreChat repository
git clone https://github.com/danny-avila/LibreChat.git
cd LibreChat

# Create th configuration files
copy .env.example .env
copy librechat.example.yaml librechat.yaml
copy docker-compose.override.yml.example docker-compose.override.yml

# Add the following block under the custom: section in librechat.yaml
custom:
  - name: "Ozeki AI Gateway"
    apiKey: "ozkey-abc123"
    baseURL: "http://host.docker.internal/v1"
    models:
      default: ["your-llm-model"]
      fetch: true
    titleConvo: true
    titleModel: "your-llm-model"

# Add the following volume binding under the api: service in docker-compose.override.yml
services:
  api:
    volumes:
      - type: bind
        source: ./librechat.yaml
        target: /app/librechat.yaml

# Start LibreChat
docker compose up -d

# Open LibreChat in your browser
http://localhost:3080

How to set up LibreChat with Ozeki AI Gateway video

The following video shows how to install and configure LibreChat to work with Ozeki AI Gateway step-by-step. The video covers cloning the repository, editing the configuration files and starting the Docker container.

Step 1 - Clone the LibreChat repository

Create a new folder on your computer where you want to store the LibreChat files (Figure 1).

Create a folder for LibreChat
Figure 1 - Create a folder for LibreChat

Open a terminal window inside the folder. You can do this in Windows by right-clicking inside the folder in File Explorer and selecting Open in Terminal from the context menu (Figure 2).

Open terminal in LibreChat folder
Figure 2 - Open terminal in LibreChat folder

In the terminal window, run the following command to download the LibreChat source code from GitHub. This will create a new subfolder called LibreChat containing all the necessary files (Figure 3).

git clone https://github.com/danny-avila/LibreChat.git

Clone the git repository
Figure 3 - Clone the git repository

Step 2 - Create the environment file

Navigate into the newly created LibreChat directory using the cd command (Figure 4).

cd LibreChat

Navigate to cloned repo using cd
Figure 4 - Navigate into the cloned repository

LibreChat requires an environment file named .env to store its settings. The repository includes an example file you can use as a starting point. Copy it using the following command. You do not need to edit this file for a basic setup (Figure 5).

copy .env.example .env

Copy .env.example to .env file
Figure 5 - Copy .env.example to .env

Step 3 - Create and edit the LibreChat config file

The LibreChat config file controls which AI providers and models are available in the interface. Copy the example config file to create your own editable version (Figure 6).

copy librechat.example.yaml librechat.yaml

Copy librechat example to config file
Figure 6 - Copy librechat.example.yaml to librechat.yaml

Open the newly created librechat.yaml file in a text editor such as Notepad (Figure 7).

Open librechat config in text editor
Figure 7 - Open librechat.yaml in a text editor

In the librechat.yaml file, locate the custom: section and add the following block to register Ozeki AI Gateway as a custom endpoint. Replace ozkey-abc123 with the API key you created in Ozeki AI Gateway, and replace your-llm-model with the name of the model you want to use (Figure 8).

custom:
  - name: "Ozeki AI Gateway"
    apiKey: "ozkey-abc123"
    baseURL: "http://host.docker.internal/v1"
    models:
      default: ["your-llm-model"]
      fetch: true
    titleConvo: true
    titleModel: "your-llm-model"

The host.docker.internal hostname allows the Docker container to reach services running on your host machine. If Ozeki AI Gateway is installed on a different server, replace it with that server's IP address or hostname.

Add Ozeki AI Gateway to custom endpoints
Figure 8 - Add Ozeki AI Gateway to custom endpoints

Step 4 - Create and edit the Docker Compose override file

LibreChat uses Docker Compose to manage its containers. To make your custom configuration available inside the container, you need a Docker Compose override file. Copy the example override file to create your own (Figure 9).

copy docker-compose.override.yml.example docker-compose.override.yml

Copy docker-compose override example
Figure 9 - Copy docker-compose.override.yml.example

Open the newly created docker-compose.override.yml file in your text editor (Figure 10).

Open docker-compose override in text editor
Figure 10 - Open docker-compose.override.yml in a text editor

In the docker-compose.override.yml file, find and uncomment the services: section and add a volume binding for the api service. This tells Docker to use your local librechat.yaml file inside the container, so your custom endpoint settings take effect. Save the file after making the change (Figure 11).

services:
  api:
    volumes:
      - type: bind
        source: ./librechat.yaml
        target: /app/librechat.yaml

Mount librechat config into container
Figure 11 - Mount librechat.yaml into the Docker container

Step 5 - Start LibreChat with Docker Compose

With all configuration files in place, start LibreChat by running the following command in your terminal. Docker will download the required images and start all the necessary services. This may take a few minutes the first time (Figure 12).

docker compose up -d

Compose up the container
Figure 12 - Start LibreChat with docker compose up -d

Once Docker has finished starting the containers, open your web browser and navigate to the following address to access the LibreChat interface (Figure 13).

http://localhost:3080

Navigate to LibreChat in browser
Figure 13 - Open LibreChat in your browser

Step 6 - Register an account and log in

The following video walks you through registering a new account, logging in, and sending your first test prompt in LibreChat.

When you first open LibreChat, you will be taken to the login page. Since this is a fresh installation, you need to create a new account. Click the Sign up button to open the sign-up form (Figure 14).

Navigate to LibreChat registration page
Figure 14 - Navigate to the LibreChat registration page

Fill in the registration form with your name, email address, and a password of your choice. After entering all the required information, click the Continue button to create your account (Figure 15).

Register an account
Figure 15 - Fill in the registration form

After registering, you will be redirected to the login page. Enter your email address and password, then click Continue to sign in to your new account (Figure 16).

Log in to LibreChat
Figure 16 - Log in with your new account

On your first login, LibreChat will present its terms of service. Read through the terms and click the accept button to proceed to the main interface (Figure 17).

Review and accept terms of service
Figure 17 - Review and accept the terms of service

Step 7 - Select an LLM model and send a test prompt

In the LibreChat interface, click the model selector at the top of the chat window. You should see "Ozeki AI Gateway" listed as an available endpoint. Select it, then choose the model you configured earlier from the model list (Figure 18).

Select configured Ozeki AI Gateway LLM model
Figure 18 - Select the Ozeki AI Gateway model

Type a test message into the chat input box and press Enter or click the send button (Figure 19).

Send LLM a test prompt
Figure 19 - Send a test prompt to verify the connection

You should see a response appear in the chat window, confirming that the integration is working correctly (Figure 20).

LLM response
Figure 20 - LibreChat displays the AI response

To sum it up

You have successfully installed and configured LibreChat to work with Ozeki AI Gateway. You can now use LibreChat's modern chat interface to interact with any AI model available through your gateway. All requests are routed through Ozeki AI Gateway, giving you centralized control over API keys, model access, and usage statistics.


More information