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

Configure NextChat 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 NextChat to an OpenAI-compatible API, open the provider or custom endpoint settings, 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 NextChat shows 401, 404, or model not found, verify the API key matches the provider, confirm the Base URL is the correct /v1 endpoint, and copy the exact model 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 NextChat asks for NextChat / ChatGPT Next Web typically asks for an API key and a Base URL. Most deployments use OPENAI_API_KEY and BASE_URL environment variables. Both values must belong to the same provider — using a key from one platform with a Base URL from another will result in a 401 error.

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

What BASE_URL means BASE_URL is the environment variable that tells NextChat where to send API requests. The correct RutaAPI Base 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.

What the model name is 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.

NextChat version caveat NextChat / ChatGPT Next Web configuration can vary by deployment method, environment variables, version and hosting platform. Public NextChat documentation and repository examples describe OPENAI_API_KEY and BASE_URL, but users should verify their own deployed version and environment variable names before relying on a specific setup.

RutaAPI disclaimer RutaAPI is an OpenAI-compatible API gateway. It is not an official NextChat, ChatGPT Next Web, 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 NextChat, 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 — Copy a returned model name

Use one of the model id values from the /v1/models response as MODEL_NAME. Do not guess — identifiers differ between providers.

Run /v1/models and copy the exact id string. The model name in NextChat must match one of the returned model identifiers.

Step 6 — Configure NextChat

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

Do not promise exact UI labels or hosting platform steps because NextChat deployments vary by version and fork. After changing environment variables, redeploy or restart the NextChat service.

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

Step 7 — Send a small test request

Before using NextChat, send a simple request from the terminal to confirm end-to-end connectivity:

A successful response confirms the key, Base 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 NextChat / ChatGPT Next Web 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 using NextChat, send a simple request from the terminal to confirm your key, Base URL and model name all work together. This rules out configuration issues before you start a real session.

If the first request succeeds, the NextChat configuration should also work. If it fails, fix the terminal request first — that gives you clearer error messages than the NextChat 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 NextChat 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

Common errors

401 Unauthorized / invalid API key

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

404 Model not found

The Base URL or model ID is wrong. Run GET /v1/models and copy an exact returned model id.

503 Service Unavailable

The provider route is temporarily unavailable. Try a short request and check provider status.

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 NextChat to an OpenAI-compatible API?

Open the custom provider or endpoint settings in NextChat, enter the provider Base URL, 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 OpenAI-compatible API provider.

What Base URL should I use in NextChat?

Use the provider Base URL or /v1 endpoint when your provider requires it. For RutaAPI, use https://api.rutaapi.com/v1. Do not use the marketing site, the dashboard URL, or a full /v1/chat/completions endpoint as the Base URL.

Where do I enter the API key in NextChat?

Paste your API key into the API key field used by your NextChat deployment or hosting settings. Most deployments use OPENAI_API_KEY. The API key must match the same provider as the Base URL.

What model ID should I use?

Run GET /v1/models with your API key and copy one of the returned model id values. Do not guess the model name. If the model is not listed in /v1/models, it is not available for your account.

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

Use /v1 when your provider requires it, but do not paste /v1/chat/completions as the Base URL because that is a specific endpoint, not the API root. NextChat should point to the API root, not a single route.

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

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