DEV Community

APIVAI
APIVAI

Posted on

LobeChat (LobeHub) with Claude and GPT: custom provider, Docker env vars and the /v1 rule

Disclosure: I run APIVAI, the gateway used in the examples below. The setup is the same for any endpoint that speaks the OpenAI or Anthropic format.

LobeChat is now called LobeHub: the GitHub repo lobehub/lobe-chat redirects to lobehub/lobehub, and the Docker image is lobehub/lobehub. It's an open-source chat and agent app that runs on the web, as a desktop app, or self-hosted, and every agent can use its own provider and model. This guide follows the LobeHub docs and UI labels as of October 2026: how to add a third-party API, where /v1 goes, and the usual pitfalls.

Three ways to connect

Method URL Models Best for
Custom provider, Request Format = OpenAI https://api.apivai.com/v1 Claude and GPT Recommended: one provider for every model, built-in OpenAI provider untouched
Built-in Anthropic provider https://api.apivai.com Claude only Claude in its native Messages format
Built-in OpenAI provider https://api.apivai.com/v1 Claude and GPT Quickest, but replaces the OpenAI provider (breaks file indexing, see below)

The /v1 rule: OpenAI-format URLs end in /v1; Anthropic-format URLs don't, because the Anthropic SDK appends /v1/messages itself.

Adding a custom provider

  1. Open App Settings → AI Providers.
  2. Click Add Custom Provider to open Create Custom AI Provider.
  3. Fill in the fields below and click Create.
Field Value
Provider ID apivai (lowercase; can't be changed later)
Provider Name APIVAI
Request Format OpenAI
Proxy URL https://api.apivai.com/v1
API Key your key
Use Client Request Mode off

Use Client Request Mode sends requests straight from the browser instead of through the LobeHub server. Leave it off unless you have a reason; if you turn it on and get network errors, turn it off again.

Then, on the provider's page:

  1. Run Connectivity Check: pick a model, click Check, and you should see Check passed.
  2. Click Fetch models to pull IDs from /v1/models, and switch on the ones you want. Or click Add Model and type a Model ID such as claude-sonnet-4-6 or gpt-5.5.
  3. In an agent's settings, choose this provider and a model.

To see which IDs your key can use:

curl https://api.apivai.com/v1/models \
  -H "Authorization: Bearer your-key"
Enter fullscreen mode Exit fullscreen mode

Alternative: the built-in Anthropic provider

In AI Providers, select Anthropic and enable it. Paste the key into API Key and set API Proxy URL to https://api.apivai.com (no /v1). Run Check, then enable Claude models. If a built-in model card has a different ID from the gateway's, add the correct one with Add Model; if Fetch models returns nothing here, add models by hand.

If you use the built-in OpenAI provider instead, set API Proxy URL to https://api.apivai.com/v1 and leave Use Responses API Specification off: LobeHub says it only supports OpenAI models, and you'll be sending Claude requests through it too.

Self-hosting: Docker environment variables

A self-hosted LobeHub server reads providers from environment variables. Add these to your lobehub.env, next to the database and auth variables you already have:

# OpenAI format: Claude and GPT
OPENAI_API_KEY=your-key
OPENAI_PROXY_URL=https://api.apivai.com/v1
OPENAI_MODEL_LIST=-all,+claude-sonnet-4-6,+claude-haiku-4-5,+gpt-5.5

# Or Anthropic format: Claude only
ANTHROPIC_API_KEY=your-key
ANTHROPIC_PROXY_URL=https://api.apivai.com
Enter fullscreen mode Exit fullscreen mode

Start the container as usual, e.g. docker run -d -p 3210:3210 --env-file lobehub.env --name lobehub lobehub/lobehub, and restart it after every change to the file.

OPENAI_MODEL_LIST syntax: -all hides the default OpenAI models, +id adds a model, id=Display Name renames one. A key set here is a server key shared by every user of your instance, so give it its own budget limit. The LobeHub docs note that empty replies are often caused by OPENAI_PROXY_URL missing /v1; keep it there.

Do files and the knowledge base work?

Chat works fully. Files and the knowledge base also need an embedding model to index documents, and APIVAI doesn't offer embeddings.

By default LobeHub creates embeddings with OpenAI's text-embedding-3-small through the OpenAI provider. If you point OPENAI_PROXY_URL at the gateway, file indexing fails, which is one more reason to chat through a custom provider. Configure embeddings separately with DEFAULT_FILES_CONFIG, e.g. DEFAULT_FILES_CONFIG=embedding_model=ollama/<your-embedding-model>; the supported providers are listed in LobeHub's knowledge-base deployment guide. Answers about your files still come from the Claude or GPT model you picked.

Which model for which job

  • General assistant, quick questions: claude-haiku-4-5 or gpt-6-luna
  • Writing and coding agents: claude-sonnet-4-6 or claude-sonnet-5-5
  • The hardest analysis and long-form writing: claude-opus-5-5, only where it's needed
  • Current GPT: gpt-6-sol

Every message re-sends the conversation so far, so long chats get more expensive per message; start a new topic when the subject changes.

Common errors

  • 401 / API key invalid: the key has extra spaces, is incomplete, or has been deleted.
  • 402 / insufficient_quota: the key's budget is used up, or what's left is too little for one request to an expensive model (Opus, Sonnet 4.6 hit this first). Add budget to the key or switch to a cheaper model. A key stops working with a little still on it; that remainder isn't lost, because deleting the key returns it to your account balance.
  • 404: the /v1 is wrong. OpenAI format (custom provider, OpenAI provider, OPENAI_PROXY_URL) needs https://api.apivai.com/v1; Anthropic format needs https://api.apivai.com. Don't add /chat/completions or /messages.
  • Model not found: the Model ID must match the gateway's ID exactly, such as claude-sonnet-4-6, not the display name. Check with Fetch models or GET /v1/models.
  • Empty or cut-off replies: thinking is on by default and counts as output tokens. In the agent's model settings, turn on Enable Max Tokens Limit and set Max Tokens Limit to 4096 or more. For empty replies in OpenAI format, also check that the URL ends in /v1.
  • Environment variables ignored: restart the container after editing lobehub.env, and check the variable names match exactly.
  • 429: the default limit is 60 requests per minute per key. A shared instance can hit it; split usage across keys.

What it costs

At the time of writing, most Claude models on APIVAI are 56–62% below Anthropic's list prices and GPT models up to 86% below OpenAI's; for example, Claude Sonnet 4.6 is $1.26 / $6.32 per million input / output tokens against the official $3 / $15. It's prepaid and billed per token, with no subscription. The full table is at https://apivai.com/pricing?utm_source=devto&utm_campaign=lobechat.

Questions are welcome in the comments.

Top comments (0)