9router in n8n

Does n8n support 9router? I know there isn’t a dedicated native node for it, but can I connect it using the OpenAI node by overriding the Base URL, or should I use the HTTP Request node instead? Has anyone set this up before? Thanks

Hey @egaprana_fernando, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@mohamed3nan, @kjooleng, @Simon_Quant - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

Hi @egaprana_fernando Welcome!
The OpenAI credential is enough, no HTTP Request node needed. 9router speaks the OpenAI protocol and takes the same Bearer key, so create an OpenAI credential, put your 9router key in API Key, set Base URL to your 9router address ending in /v1, and attach it to an OpenAI Chat Model sub-node under an AI Agent or Basic LLM Chain. Prefer that sub-node over the OpenAI app node’s “Message a model” operation, which has been reported to 404 against custom base URLs even when the credential test passes.
The model dropdown reads your 9router /v1/models, so if a routed model does not show up there, switch the Model field to an expression and type the model ID.
9router defaults to http://localhost:20128/v1, which n8n cannot reach. On Cloud it has to be a public URL, and on self-hosted Docker use http://host.docker.internal:20128/v1 or the compose service name instead of localhost.
HTTP Request is only worth it if you want 9router’s routing headers like prompt_budget, since the chat model node has nowhere to add custom headers.
See this:

Picking and wiring up model providers in general:

Since 9router is designed to be a drop-in replacement for OpenAI endpoints, the OpenAI node in n8n is the easiest and most efficient method.

  • How to do it:
    1. Add an OpenAI node to your workflow.
    2. Create a new OpenAI API Credential.
    3. Look for the Base URL field (in some versions of n8n, you may need to click on “Advanced” or “Additional Fields” to see the Base URL option).
    4. Override the default OpenAI URL with your 9router endpoint (e.g., http://localhost:20128/v1 if running locally, or your hosted URL).
    5. For the API Key, you can usually enter any placeholder string (like sk-123) if 9router doesn’t require a specific key, or use the actual key if you’ve configured one in 9router.

If you need to use specific 9router features that aren’t exposed by the standard OpenAI node (like specialized routing headers or non-standard payload structures), use the HTTP Request node.

  • How to do it:
    1. Set the method to POST.
    2. Set the URL to your 9router endpoint (e.g., http://your-ip:20128/v1/chat/completions).
    3. Set the Authentication to “Header Auth” or “None” depending on your 9router setup.
    4. In the Body, manually construct the JSON payload (e.g., {"model": "...", "messages": [...]}).