Mintplex-Labs/anything-llm · critical · Error

No Novita API key was set.

Error message

No Novita API key was set.

What it means

Constructor guard for NovitaLLM: throws if process.env.NOVITA_LLM_API_KEY is absent. Builds the OpenAI-compatible client at https://api.novita.ai/v3/openai with custom headers (HTTP-Referer, X-Novita-Source). Note the env var is NOVITA_LLM_API_KEY (with _LLM), and there is a defaultTimeout of 3000ms.

Source

Thrown at server/utils/AiProviders/novita/index.js:25

} = require("../../helpers/chat/responses");
const fs = require("fs");
const path = require("path");
const { safeJsonParse } = require("../../http");
const {
  LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const cacheFolder = path.resolve(
  process.env.STORAGE_DIR
    ? path.resolve(process.env.STORAGE_DIR, "models", "novita")
    : path.resolve(__dirname, `../../../storage/models/novita`)
);

class NovitaLLM {
  defaultTimeout = 3_000;

  constructor(embedder = null, modelPreference = null) {
    if (!process.env.NOVITA_LLM_API_KEY)
      throw new Error("No Novita API key was set.");

    this.className = "NovitaLLM";
    const { OpenAI: OpenAIApi } = require("openai");
    this.basePath = "https://api.novita.ai/v3/openai";
    this.openai = new OpenAIApi({
      baseURL: this.basePath,
      apiKey: process.env.NOVITA_LLM_API_KEY ?? null,
      defaultHeaders: {
        "HTTP-Referer": "https://anythingllm.com",
        "X-Novita-Source": "anythingllm",
      },
    });
    this.model =
      modelPreference ||
      process.env.NOVITA_LLM_MODEL_PREF ||
      "deepseek/deepseek-r1";
    this.limits = {
      history: this.promptWindowLimit() * 0.15,

View on GitHub (pinned to 526360e320)

Solutions

  1. Set NOVITA_LLM_API_KEY (note the _LLM segment) in server/.env.
  2. Restart the server to reload env.
  3. Verify the exact variable name — NOVITA_LLM_API_KEY, not NOVITA_API_KEY.
  4. Inject the key into the deployment environment.

Example fix

// server/.env
NOVITA_LLM_API_KEY=your_key_here
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.NOVITA_LLM_API_KEY) {
  throw new Error('NOVITA_LLM_API_KEY missing — note the _LLM segment — set before enabling Novita.');
}

Try / catch

try {
  const llm = new NovitaLLM(embedder, modelPref);
} catch (e) {
  if (/No Novita API key/i.test(e.message)) {
    // config error — exact var: NOVITA_LLM_API_KEY
  }
}

Prevention

When it happens

Trigger: Instantiating `new NovitaLLM(...)` without NOVITA_LLM_API_KEY set; selecting the Novita provider without credentials.

Common situations: Typo between NOVITA_API_KEY and NOVITA_LLM_API_KEY; provider switched without configuring the key; secret absent from container/CI env; .env not reloaded.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/0d7637385c40fd5e. Report an issue: GitHub.