šŸš€ n8n Integration: CodingPlanX Custom LLM Tutorial

In n8n, you can easily connect to third-party Large Language Models (LLMs) by configuring a Custom API Domain and API Key.

This tutorial demonstrates how to configure and use custom AI models in n8n using https://api.codingplanx.ai as an example.


šŸ“‹ Prerequisites

Before you begin, ensure you have:

  1. A running instance of n8n (Self-hosted or Cloud version).
  2. A CodingPlanX API Key (usually starting with sk- or cr_).
  3. The specific Model Name you wish to call (e.g., gpt-4o, claude-3-5-sonnet, etc.).

šŸ› ļø Step 1: Create API Credentials in n8n

Since most custom APIs are OpenAI-compatible, we will use the built-in OpenAI credential type.

  1. Open your n8n dashboard and click Credentials in the left sidebar.
  2. Click the + Add Credential button in the top right.
  3. Search for OpenAI and select OpenAI API.

āš™ļø Step 2: Configure Custom API URL and Key

In the credential configuration window, fill in the following:

  1. Name: Give this credential a recognizable name, e.g., CodingPlanX API.

  2. API Key: Enter your API Key (sk-xxxxxx...).

  3. Base URL (Crucial Step):

    • By default, n8n uses the official OpenAI URL. We need to override this.
    • Find the Base URL field (if not visible, ensure your n8n version supports custom Base URLs or check under advanced settings).
    • Change the address to:
      https://api.codingplanx.ai/v1
      

    > šŸ’” Note: Most OpenAI-compatible APIs require the /v1 suffix. Do not omit it.

  4. Click Save. If configured correctly, you should see a Connection tested successfully message.


🧩 Step 3: Add and Configure the AI Node in a Workflow

Now, let's use the credential in a workflow.

  1. Go to Workflows and click + Add workflow.
  2. Click the + icon on the canvas, search for and add an OpenAI node (usually AI Chat Model).
  3. Open the node settings:
    • Credential to connect with: Select the CodingPlanX API you just created.
    • Model:
      • Since this is a custom API, the dropdown might not list your specific model.
      • Click the āš™ļø (gear icon) next to the Model field or select Expression / Custom mode.
      • Manually enter the model name, e.g., gpt-3.5-turbo or your specific Claude ID.

āœ… Step 4: Test the Connection

  1. Connect a Manual Trigger node to your AI node.
  2. Enter a test prompt in the AI node, e.g., "Hello, please introduce yourself.".
  3. Click Execute Node or Test step.
  4. Check the Output panel on the right. If you see an AI response, congratulations! Your custom model is successfully integrated! šŸŽ‰

ā“ Troubleshooting (FAQ)

Q1: Error Invalid API Key or AuthenticationError?

  • Check if the API Key is copied correctly without extra spaces.
  • Ensure your CodingPlanX account has sufficient balance.

Q2: Error Resource not found or 404?

  • Re-check the Base URL in Step 2. Ensure it includes https://api.codingplanx.ai/v1 (check for missing /v1 or extra trailing slashes).

Q3: Error Model not found?

  • Verify that the Model Name you typed manually is correct. Refer to the CodingPlanX model list for exact IDs.