> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ruapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# n8n

> How to connect an LLM in n8n: use RuAPI models in your workflows via the OpenAI node and a custom Base URL

[n8n](https://n8n.io) is a workflow automation platform with a visual editor and AI blocks (AI Agent, OpenAI, chains). RuAPI connects through an **OpenAI credential** with a changed Base URL — after that, all AI nodes route to us.

## Prerequisites

<Steps>
  <Step title="RuAPI account and API key">
    Console → **Tokens** → create an `sk-...` key. The balance tops up in USDT — see [Top-up](/en/topup).
  </Step>
</Steps>

## Create the credential

<Steps>
  <Step title="Add an OpenAI credential">
    In n8n: **Credentials → New → OpenAI**.
  </Step>

  <Step title="Fill the fields">
    | Field        | Value                                       |
    | ------------ | ------------------------------------------- |
    | **API Key**  | `sk-your-key`                               |
    | **Base URL** | `https://www.ruapi.ai/v1`  — **with** `/v1` |

    <Note>
      The **Base URL** field may sit under "Optional fields" (the gear) in the OpenAI credential form. Save the credential.
    </Note>
  </Step>
</Steps>

## Use it in a node

<Steps>
  <Step title="Add an AI node">
    Drop an **OpenAI** node or an **AI Agent** (with an OpenAI Chat Model) onto the canvas.
  </Step>

  <Step title="Pick the RuAPI credential">
    In the node's Credentials field, select the credential you created.
  </Step>

  <Step title="Set the model">
    Enter the exact model ID from the [pricing page](https://www.ruapi.ai/pricing). If your model isn't in the dropdown, set the ID manually ("By ID" mode or an expression).
  </Step>
</Steps>

## Verify

Run the node with a simple prompt ("Hi, answer in one word"). A successful reply plus an entry in RuAPI Console → **Logs** means the wiring works.

## Troubleshooting

<AccordionGroup>
  <Accordion title="401 / Unauthorized">
    * The API Key must be a RuAPI token (`sk-...`).
    * Check the credential's Base URL is `https://www.ruapi.ai/v1` with `/v1`.
  </Accordion>

  <Accordion title="I don't see a Base URL field">
    Expand the optional/additional fields in the OpenAI credential form. The field is available in current self-hosted and cloud n8n versions.
  </Accordion>

  <Accordion title="My model isn't in the dropdown">
    The list shows OpenAI models. Enter the model ID manually — it must match RuAPI verbatim.
  </Accordion>
</AccordionGroup>
