Zie619/n8n-workflows · error · Error

Please add your API key for searchapi.io to this node

Error message

Please add your API key for searchapi.io to this node

What it means

Deliberate guard inside the 'LangChain Code' noOp node (workflow 0399): the template hardcodes searchApiKey = '<YOUR API KEY>' and throws this exact message when the value is still the placeholder. The check runs after the SearchApiLoader is constructed but before loader.load(), so it is an intentional fail-fast for an unconfigured template.

Source

Thrown at workflows/Manual/0399_Manual_Stickynote_Automate_Triggered.json:70

        "color": 7,
        "height": 220.82906011310624,
        "content": "## About\nThis workflow shows how you can write LangChain code in n8n (and import its modules if required).\n\nThe workflow fetches a video from YouTube and produces a textual summary of it."
      },
      "typeVersion": 1,
      "notes": "This stickyNote node performs automated tasks as part of the workflow."
    },
    {
      "id": "a43bb1c5-dd90-4331-930c-128ef0ecb38a",
      "name": "LangChain Code",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -380,
        20
      ],
      "parameters": {
        "code": {
          "execute": {
            "code": "// IMPORTANT: add in your API key for searchapi.io below\nconst searchApiKey = \"<YOUR API KEY>\"\n\nconst { loadSummarizationChain } = require(\"langchain/chains\");\nconst { SearchApiLoader } = require(\"@n8n/n8n-nodes-langchain/node_modules/@langchain/community/document_loaders/web/searchapi.cjs\");\nconst { PromptTemplate } = require(\"@langchain/core/prompts\");\nconst { TokenTextSplitter } = require(\"langchain/text_splitter\");\nconst loader = new SearchApiLoader({\n  engine: \"youtube_transcripts\",\n  video_id: $input.item.json.videoId,\n  apiKey: searchApiKey,\n});\n\nif (searchApiKey == \"<YOUR API KEY>\") {\n  throw new Error(\"Please add your API key for searchapi.io to this node\")\n}\n\nconst docs = await loader.load();\n\nconst splitter = new TokenTextSplitter({\n  chunkSize: 10000,\n  chunkOverlap: 250,\n});\n\nconst docsSummary = await splitter.splitDocuments(docs);\n\nconst llmSummary = await this.getInputConnectionData('ai_languageModel', 0);\n\nconst summaryTemplate = `\nYou are an expert in summarizing YouTube videos.\nYour goal is to create a summary of a podcast.\nBelow you find the transcript of a podcast:\n--------\n{text}\n--------\n\nThe transcript of the podcast will also be used as the basis for a question and answer bot.\nProvide some examples questions and answers that could be asked about the podcast. Make these questions very specific.\n\nTotal output will be a summary of the video and a list of example questions the user could ask of the video.\n\nSUMMARY AND QUESTIONS:\n`;\n\nconst SUMMARY_PROMPT = PromptTemplate.fromTemplate(summaryTemplate);\n\nconst summaryRefineTemplate = `\nYou are an expert in summarizing YouTube videos.\nYour goal is to create a summary of a podcast.\nWe have provided an existing summary up to a certain point: {existing_answer}\n\nBelow you find the transcript of a podcast:\n--------\n{text}\n--------\n\nGiven the new context, refine the summary and example questions.\nThe transcript of the podcast will also be used as the basis for a question and answer bot.\nProvide some examples questions and answers that could be asked about the podcast. Make\nthese questions very specific.\nIf the context isn't useful, return the original summary and questions.\nTotal output will be a summary of the video and a list of example questions the user could ask of the video.\n\nSUMMARY AND QUESTIONS:\n`;\n\nconst SUMMARY_REFINE_PROMPT = PromptTemplate.fromTemplate(\n  summaryRefineTemplate\n);\n\nconst summarizeChain = loadSummarizationChain(llmSummary, {\n  type: \"refine\",\n  verbose: true,\n  questionPrompt: SUMMARY_PROMPT,\n  refinePrompt: SUMMARY_REFINE_PROMPT,\n});\n\nconst summary = await summarizeChain.run(docsSummary);\n\nreturn [{json: { summary } } ];"
          }
        },
        "inputs": {
          "input": [
            {
              "type": "main",
              "required": true,
              "maxConnections": 1
            },
            {
              "type": "ai_languageModel",
              "required": true,
              "maxConnections": 1
            }
          ]
        },
        "outputs": {
          "output": [

View on GitHub (pinned to 94007c1445)

Solutions

  1. Open the 'LangChain Code' node parameters and replace "<YOUR API KEY>" with a real searchapi.io key.
  2. Better: move the key out of the code — read it from an n8n credential or $env (see exampleFix) so the workflow JSON carries no secret.
  3. Rotate the key on searchapi.io if it was ever committed inside the JSON.
  4. Verify with a single manual execution on one videoId before scheduling.

Example fix

// before
const searchApiKey = "<YOUR API KEY>";
// ...
if (searchApiKey == "<YOUR API KEY>") {
  throw new Error("Please add your API key for searchapi.io to this node")
}

// after
const searchApiKey = $env.SEARCHAPI_IO_API_KEY; // set via n8n environment variable
if (!searchApiKey) {
  throw new Error("SEARCHAPI_IO_API_KEY is not configured in the n8n environment");
}
Defensive patterns

Strategy: validation

Validate before calling

const searchApiKey = $env.SEARCHAPI_IO_API_KEY;
if (!searchApiKey || searchApiKey.length < 10) {
  throw new Error('SEARCHAPI_IO_API_KEY is not configured in the n8n environment');
}

Prevention

When it happens

Trigger: Executing the YouTube-transcript summarization workflow without editing the embedded code node and replacing the placeholder string. Any execution, manual or triggered, hits the throw because searchApiKey is a compile-time constant in the node.

Common situations: Imported n8n template with an in-code API key placeholder rather than a credential; user clicks Execute before reading the sticky-note instructions; key pasted into the wrong spot (e.g. the loader call) leaving the constant unchanged.

Related errors


AI-assisted analysis of Zie619/n8n-workflows@94007c1445 (2026-08-15). Data as JSON: /api/errors/090970a0c2641cb2. Report an issue: GitHub.