n8n with a self-hosted LLM on a DGX Spark
By the end of this page, n8n's AI nodes call a model on your own DGX Spark instead of a public API. You add one OpenAI credential with your Spark's base URL, and a workflow that summarizes tickets, drafts replies or extracts invoice fields keeps the same nodes and prompts.
You need:
- A running GPUwerk instance with an OpenAI-compatible endpoint: a console model preset such as Qwen3 Coder 30B, or your own engine on a base image.
- For a console preset, an API key with the
inferencescope, created in the console. - An n8n instance (self-hosted or n8n Cloud) that can reach the Spark over the internet.
- No SSH key. GPUwerk configures the machine, and the console's browser terminal works without one. Add your own key only if you want your own SSH client, scp or port forwarding.
Why route n8n's AI nodes yourself
An AI node usually carries whatever triggered the workflow: a support email, a form submission, a row from a customer database. By default that data goes to a public model API, on infrastructure you do not control, under that provider's retention policy. n8n does not require this. Its AI nodes accept a custom base URL, so the same trigger, prompt template and downstream steps can run against a model on a Spark you rent, and no model provider sees the request.
Start with a running endpoint
- Pick the endpoint. With a console model preset, copy the HTTPS endpoint from the instance page (it looks like
https://app-<instance-id>.gpuwerk.com) and add/v1; requests need your inference-scope API key. With your own vLLM server,<spark-host>below is your instance's hostname,<name>.gpuwerk.com. Start it with--api-key, because the instance's public IPv4 address makes an open port reachable from the internet. Put LiteLLM in front if several workflows or teams will share the model. - Confirm it answers from the n8n host, not just from your laptop:
curl http://<spark-host>:8000/v1/models
For a preset, use its HTTPS URL and add-H "Authorization: Bearer $GPUWERK_API_KEY". You should see JSON listing the model ID, for exampleqwen3-coder-30b. If n8n runs in Docker, run the check from inside the n8n container.
Add the credential in n8n
n8n's built-in OpenAi credential takes a base URL as well as an API key, so you need no community node.
- In n8n, go to Credentials, New, OpenAi.
- Fill in the API key and base URL. For a preset, use your inference-scope key and the HTTPS endpoint plus
/v1:
API Key: not-needed-unless-you-put-a-gateway-in-front Base URL: http://<spark-host>:8000/v1
- Save the credential. n8n should report a successful connection test.
vLLM checks the key only if you started it with --api-key, but the form needs a non-empty value. With LiteLLM in front, use the gateway's URL and a virtual key per workflow; nothing else changes.
Which nodes to use
Three nodes use this credential:
- OpenAI Chat Model is the sub-node that plugs into an AI Agent or a chain, and it's where the credential above gets attached.
- AI Agent is the node for tool-using workflows, for example ticket triage that looks up an order, or a chatbot that calls other n8n workflows as tools. It uses the chat model sub-node you connect to it.
- Basic LLM Chain is the simpler choice without tools: a prompt in, a completion out. Use it for summarization or classification steps.
To move an existing workflow from a public API to your Spark, switch the chat model node to the new credential. You do not rebuild the workflow.
A minimal workflow
- Add a Webhook or email trigger.
- Connect a Basic LLM Chain node with an OpenAI Chat Model sub-node that uses your new credential.
- Put the prompt in the chain node's text field:
Summarize the following support ticket in two sentences,
and flag the priority as low, medium, or high:
{{ $json.body }}
- Set the model to the ID your Spark reports at
/v1/models(qwen3-coder-30bon that preset), or the alias from LiteLLM's config. - Add the output node: a database row, a Slack message or a ticket field.
- Run the workflow with a test ticket. The chain node's output should show a two-sentence summary and a priority.
What actually breaks
- Connection refused or timeout. Cause: n8n runs in Docker, and
localhostinside that container is not your Spark. Fix: use the Spark's hostname,<name>.gpuwerk.com, or the preset's HTTPS endpoint. - The credential looks broken. Cause: usually the model name in the chat model node does not match what the server has loaded. Fix: copy the ID from
/v1/models. On a preset, also check the key has theinferencescope. - The AI Agent never calls its tools. Cause: the model does not emit tool calls reliably. Fix: test a simple tool-using workflow on that model before you depend on it. The Qwen3 Coder 30B vLLM preset does not start with vLLM's
--enable-auto-tool-choice, so use a llama.cpp preset or your own vLLM server with that flag for agents. - Agent runs fail after several steps. Cause: history and tool output passed the server's context limit. Fix: size
--max-model-lenfor the whole workflow, not one prompt. The Qwen3 Coder 30B preset is fixed at 32,768 tokens.