LobeChat OpenAI-Compatible API Setup with Base URL and API Key

Configure LobeChat with an OpenAI-compatible API using Base URL, API key, model ID, and /v1 endpoint. Fix 401, 404, and model errors.

Quick answer

To connect LobeChat to an OpenAI-compatible API, add a custom provider or OpenAI-compatible endpoint, enter the Base URL, paste your API key, and use a model ID returned by /v1/models. Use /v1 when your provider requires it, and do not paste a full /v1/chat/completions URL as the Base URL. If you see 401, 404, or model not found errors, verify the Base URL includes /v1, confirm the API key matches the provider, and check that the model name exactly matches an ID from /v1/models.

Before you start

You need a RutaAPI account, a prepaid credit pack, and an API key. Make sure your account has credits before making requests — requests without sufficient credits will return a 401 or 403 error.

What LobeChat asks for LobeChat / LobeHub supports adding custom OpenAI-compatible model providers. Configuration typically involves OPENAI_API_KEY (your API key) and OPENAI_PROXY_URL (the request base URL). Both values must belong to the same provider — using a key from one platform with a URL from another will result in errors.

What OPENAI_API_KEY means OPENAI_API_KEY is the environment variable that stores your API key. LobeChat uses this to authenticate requests to the model provider. Enter your RutaAPI API key in this field — it identifies your account and must match the proxy URL.

What OPENAI_PROXY_URL means OPENAI_PROXY_URL is the environment variable that tells LobeChat where to send API requests. The correct RutaAPI proxy URL is <strong>https://api.rutaapi.com/v1</strong>. This is the OpenAI-compatible API root — it includes /v1 and points to the API gateway, not the marketing site or dashboard.

Should OPENAI_PROXY_URL include /v1? LobeHub documentation notes that whether to include /v1 depends on the model service provider. For RutaAPI OpenAI-compatible usage, use https://api.rutaapi.com/v1. Do not remove /v1 unless a specific deployment layer already appends it. If you see empty responses, double-check whether your LobeChat deployment adds /v1 automatically.

What model name means The model name is the identifier of the AI model that handles your request. It must match one of the models returned by GET /v1/models for your account. Do not guess — identifiers differ between providers.

LobeChat version caveat LobeChat / LobeHub configuration can vary by version, deployment mode, environment variables and feature flags. Official LobeHub documentation describes OPENAI_API_KEY and OPENAI_PROXY_URL, and notes that whether to include /v1 depends on the provider. Users should verify their deployed version and hosting environment before relying on a specific setup.

RutaAPI disclaimer RutaAPI is an OpenAI-compatible API gateway. It is not an official LobeChat, LobeHub, OpenAI, Anthropic, Google or Microsoft service. Model availability and rates depend on your account configuration and upstream providers.

How to start with RutaAPI

Step 1 — Create a RutaAPI account

Register at app.rutaapi.com. No credit card is required to sign up.

Step 2 — Add prepaid credits

Purchase a credit pack from the billing section. Credits are added immediately after payment. Requests without sufficient credits return 401 or 403.

Step 3 — Create an API key

Go to the Tokens section and create a new key. Copy it right away — it is shown only once at creation.

Security: Never paste your full API key into screenshots or shared scripts. If exposed, rotate it immediately from the dashboard.

Step 4 — Verify /v1/models

Before configuring LobeChat, confirm the key works by calling /v1/models:

A 200 response with a model list means the key is valid. A 401 response means the key is wrong or revoked.

curl https://api.rutaapi.com/v1/models \
  -H "Authorization: Bearer YOUR_RUTAAPI_KEY"

Step 5 — Set environment variables

Set the following environment variables in your LobeChat deployment. Exact deployment files vary — some use .env, Docker variables, Vercel variables or provider settings.

Some LobeChat deployments may use environment variables, Docker variables, Vercel variables or provider settings. After changing environment variables, restart or redeploy the service.

OPENAI_API_KEY=YOUR_RUTAAPI_KEY
OPENAI_PROXY_URL=https://api.rutaapi.com/v1

Step 6 — Restart or redeploy LobeChat

After changing OPENAI_API_KEY, OPENAI_PROXY_URL or other environment variables, restart or redeploy the LobeChat service for the new values to take effect.

This applies to Docker, Vercel, Railway, Render and most other hosting platforms. Without a restart, LobeChat may continue using cached configuration.

Step 7 — Send a small test request

Before starting a chat session, confirm end-to-end connectivity from the terminal:

A successful response confirms the key, proxy URL, model name and credits are all working correctly.

curl https://api.rutaapi.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_RUTAAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_NAME",
    "messages": [
      {"role": "user", "content": "Hello from RutaAPI"}
    ]
  }'

Who this guide is for

This guide is for LobeChat / LobeHub users who want to connect their self-hosted chat interface to an OpenAI-compatible API gateway provided by RutaAPI.

It helps if you are familiar with environment variables, .env files, Docker or Vercel deployments.

Who should not use this setup

Testing before you start chatting

Before starting a chat session in LobeChat, send a simple request from the terminal to confirm your key, proxy URL and model name all work together. This rules out configuration issues before you begin.

If the first request succeeds, the LobeChat configuration should also work. If it fails, fix the terminal request first — that gives you clearer error messages than the LobeChat UI.

How to pick a model name

Model names are returned by the GET /v1/models endpoint. Copy one of the model id values from the response and use it as the model name in your LobeChat settings.

Model availability is per-account. If a model name is not in your /v1/models response, it is not active in your account — add more credits or contact support.

Common mistakes

Empty response troubleshooting

If LobeChat returns an empty response, the most common causes are:

Run /v1/models to verify the model ID, and check whether your LobeChat deployment adds /v1 automatically.

Common errors

401 Unauthorized / invalid API key

The API key is missing, incorrect, or sent to the wrong URL. Verify OPENAI_API_KEY and OPENAI_PROXY_URL both come from RutaAPI. Run /v1/models to confirm the key is valid.

403 Forbidden

The key exists but lacks permission. Check credits and model access in your RutaAPI account.

404 Model not found

The model name is not in your account. Run GET /v1/models and copy a returned model id.

429 Too Many Requests

Rate or concurrency limit. Lower the number of concurrent requests and retry.

503 Service Unavailable

The provider route is temporarily unavailable. Try a short request, check model availability, contact support if persistent.

Empty response

Usually caused by a proxy URL suffix mismatch or model name not matching /v1/models. Check whether /v1 is required and verify the model ID is in /v1/models.

When RutaAPI may be a good fit

When RutaAPI may not be the right fit

Related setup and troubleshooting guides

Ready to test RutaAPI? Use one OpenAI-compatible base URL, prepaid credits, and API keys from the dashboard.

FAQ

How do I connect LobeChat to an OpenAI-compatible API?

Open LobeChat settings, add a custom OpenAI-compatible provider, enter the provider Base URL (such as https://api.rutaapi.com/v1), paste your API key, and use a model ID returned by /v1/models. The Base URL, API key and model must all come from the same provider.

What Base URL should I use in LobeChat?

Use the /v1 endpoint of your provider as the Base URL. For RutaAPI this is https://api.rutaapi.com/v1. Do not use the marketing website URL, the dashboard URL, or any path ending in /chat/completions — those are not API roots.

Where do I enter the API key in LobeChat?

Paste your API key into the API key field in your LobeChat custom provider settings. The API key must belong to the same provider as the Base URL — mixing a key from one platform with a URL from another results in 401 errors.

What model ID should I use?

Run GET /v1/models with your API key and copy one of the model id values from the response. Do not guess — model identifiers differ between providers. The model must appear in your /v1/models response before it can be used.

Should the Base URL include /v1 or /v1/chat/completions?

Use /v1 — that is the OpenAI-compatible API root. Do not paste /v1/chat/completions as the Base URL because that is a specific endpoint, not the root. If LobeChat adds /v1 automatically, you may need to omit it — test with a small request to confirm.

Why does LobeChat show 401, 404, or model not found?

401 usually means the API key is wrong, missing, or sent to a mismatched Base URL. 404 usually means the Base URL is wrong or missing /v1. Model not found means the model name does not match any ID in /v1/models. Verify the key, Base URL and model name all belong to the same provider.