Skip to main content

Overview

LibreChat is a self-hosted chat UI that talks to OpenAI-compatible APIs through custom endpoints. Pointing one custom endpoint at GoModel gives every LibreChat user all your providers behind a single connection, and every chat is logged, priced, and attributed to the signed-in LibreChat user in GoModel. Flow: LibreChat chat -> LibreChat backend -> GoModel -> OpenAI/Anthropic/Gemini/... What you get:
  • Full request and response bodies for every chat in the GoModel audit log.
  • Cost per LibreChat user via header templates and labels.
  • All providers behind one custom endpoint; no per-provider setup in LibreChat.
  • Prometheus metrics and OpenTelemetry traces for chat traffic, once you enable those exporters (see Notes).
  • Failover, rate limits, budgets, and response caching applied to chat traffic, when you configure them in GoModel.

1. Run GoModel next to LibreChat

LibreChat reads custom endpoints from librechat.yaml. Create it next to your compose file:
librechat.yaml
Then run GoModel, LibreChat, and MongoDB on one Docker network so LibreChat can reach GoModel by container name:
docker-compose.yml
Open http://localhost:3080, register the first account (it becomes the LibreChat admin), and the GoModel endpoint appears in the model picker with every model GoModel exposes — including Anthropic and Gemini models and any virtual models.
Create a dedicated API key for LibreChat in the GoModel dashboard (API Keys -> Create API Key) instead of using the master key. Keys carry labels, budgets, and rate limits, so chat spend shows up separately in the dashboard.

2. Chat, and see every call in GoModel

Pick any model — openai/gpt-5-mini, anthropic/claude-haiku-4-5-20251001, gemini/gemini-2.5-flash — and chat. Streaming responses, and the title generation LibreChat runs after the first exchange, all pass through GoModel. Each call appears in the audit log with the full prompt, response, tokens, cost, and the header identifying the user.
Verified with LibreChat v0.8.7: model fetch, chat and title generation against OpenAI, Anthropic, and Gemini models, per-user labels, and RAG file embedding, all routed through GoModel.

Per-user cost tracking

With the headers template from step 1, every request carries X-LibreChat-User-Email and GoModel records its value as a label. The dashboard’s usage-by-label view then shows requests, tokens, and cost per person. If emails should not appear in usage data, use "{{LIBRECHAT_USER_ID}}" in the template instead, keeping TAGGING_HEADER_1_DONOTPASS. Keep TAGGING_HEADER_1_DONOTPASS set: regular routed requests never forward client headers, but passthrough requests would otherwise carry the email header to the provider. See Labelling for prefixes and other header options.

Curate the model picker

GoModel can expose hundreds of models, and fetch: true lists all of them. To offer a fixed menu instead, set fetch: false and list what your users should see:
Or expose fewer providers in GoModel; fetch: true follows GET /v1/models.

Embeddings and RAG

LibreChat’s file uploads are embedded by its separate RAG API, which speaks the OpenAI embeddings API and can point at GoModel too. Add to the compose file:
Add RAG_API_URL: http://rag_api:8000 to the librechat service and pg_data: to the volumes list. Every uploaded document is chunked and embedded through GoModel’s /v1/embeddings, so embedding usage is logged and priced like any other call. Chat routing works fine without this section.

Troubleshooting

Notes

  • GoModel failover and budgets apply to chat traffic automatically; a per-key budget caps what the whole LibreChat instance can spend.
  • LibreChat’s agents, web search, and image generation features have their own provider settings and were not part of the verification run.
  • For dashboards and alerts, see Prometheus metrics and OpenTelemetry.
Last modified on September 1, 2026