Mintplex-Labs/anything-llm · error · Error

No Novita API key was set.

Error message

No Novita API key was set.

What it means

NovitaLLM's constructor throws when process.env.NOVITA_LLM_API_KEY is falsy, before the OpenAI-compatible client for https://api.novita.ai/v3/openai is created. Any instantiation of the provider (selecting Novita as the LLM, sending a chat) fails until the key is set.

Solutions

  1. Add NOVITA_LLM_API_KEY=<key from novita.ai> to the server's .env
  2. Restart the AnythingLLM server or container
  3. Confirm the variable name is present in the runtime environment (name check only)
  4. Check for whitespace or quotes around the value

Example fix

# before
# (NOVITA_LLM_API_KEY not set)
# after
NOVITA_LLM_API_KEY=sk-...your-key
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.NOVITA_LLM_API_KEY)
  throw new Error('Novita provider selected but NOVITA_LLM_API_KEY is not configured');
const llm = new NovitaLLM(embedder);

Try / catch

try {
  const llm = new NovitaLLM(embedder);
} catch (e) {
  if (e.message === 'No Novita API key was set.')
    return respondConfigError(e); // configure key, restart, do not retry
  throw e;
}

Prevention

When it happens

Trigger: Selecting Novita AI as the provider with NOVITA_LLM_API_KEY unset, misspelled, or empty; .env edited but the process not restarted; Docker deployments where the variable was not injected.

Common situations: Typo'd variable name (NOVITA_API_KEY, NOVITA_LLM_KEY); stale process after .env edits; missing env entry in docker-compose.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


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

Appendix: 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 3aec848f28)