Skip to content

Instantly share code, notes, and snippets.

@davehague
Last active March 10, 2025 15:29
Show Gist options
  • Save davehague/d9aae9e136d879b77951fc5f272d7f4d to your computer and use it in GitHub Desktop.
Save davehague/d9aae9e136d879b77951fc5f272d7f4d to your computer and use it in GitHub Desktop.
Connect LibreChat to Ollama Local (Mac) or OpenRouter

Integrating Librechat

Connecting Librechat and Ollama

  1. First, follow the official LibreChat instructions to update your librechat.yaml file in the base directory.

  2. (unclear if needed) Set the environment variable launchctl setenv OLLAMA_HOST "0.0.0.0:11434" to expose the ollama API before ollama serve, per this github issue

  3. Set the volume to your docker-compose.override.yml for Librechat (under the service named api):

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

    docker-compose down && docker-compose up -d`
    

Connecting OpenRouter

  1. Set the environment variable

    launchctl setenv OPENROUTER_KEY "sk..."
    
  2. Or in ~/.zshrc

    export OPENROUTER_KEY="sk-..." 
    
  3. Add the OPENROUTER_KEY environment variable to docker-compose.yml for Librechat

    services:
       api:
         environment:
           - OPENROUTER_KEY=${OPENROUTER_KEY}
    

Troubleshooting

Logs

  1. Run this command to watch the Librechat logs:

    cd /path/to/LibreChat
    docker logs LibreChat --follow
    
  2. Cmd-C to stop following

Shell

  1. Run this command to connect to the instance (to check for environment variables or ability to curl to endpoints)

    docker exec -it LibreChat sh
    
  2. exit to leave the shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment