Short path: LLM API gateway · Production LLM API · OpenAI-compatible API · Usage logs
Last verified: August 3, 2026
To call an OpenAI-compatible API from n8n reliably, use the HTTP Request node with a stored Bearer credential, POST to the provider's /v1/chat/completions endpoint, and map choices[0].message.content into the next node. This avoids depending on whether a particular n8n OpenAI node version exposes a custom Base URL or defaults to the Responses API.
For LumeAPI, the request URL is https://api.lumeapi.site/v1/chat/completions. Keep the inference key in n8n Credentials, not in the workflow JSON.
Build the minimum working workflow
Manual Trigger
↓
Set Input
↓
HTTP Request: LumeAPI Chat Completions
↓
Set OutputThe minimum flow is intentionally small. First prove authentication, model selection and response mapping. Add retries, branches and external actions only after the baseline execution succeeds.
Store the Bearer credential
Create a generic Header Auth credential in n8n:
| Credential field | Value |
|---|---|
| Name | Authorization |
| Value | Bearer <your LumeAPI inference key> |
Select that credential in the HTTP Request node. n8n's HTTP Request implementation supports generic credential types; using the credential store keeps the secret out of exported workflow JSON and screenshots.
Do not use the Research ingest key. It publishes articles and is not a model-inference credential.
Configure the HTTP Request node
Use these settings:
| Setting | Value |
|---|---|
| Method | POST |
| URL | https://api.lumeapi.site/v1/chat/completions |
| Authentication | Generic Credential Type → your Header Auth credential |
| Send Headers | On |
| Header | Content-Type: application/json |
| Send Body | On |
| Body Content Type | JSON |
| Response Format | JSON |
Enter this JSON body. The expression reads a prompt created by the preceding Set node:
{
"model": "gpt-5.6-terra",
"messages": [
{
"role": "system",
"content": "Answer briefly and do not invent missing facts."
},
{
"role": "user",
"content": "={{ $json.prompt }}"
}
],
"temperature": 0
}In Set Input, create a string field named prompt. For the first run, use Reply with exactly: n8n connection ok.
Map the result without passing the full response downstream
Add a Set node after the request and create:
answer = {{ $json.choices[0].message.content }}
model = {{ $json.model }}
request_id = {{ $json.id }}
prompt_tokens = {{ $json.usage?.prompt_tokens ?? null }}
completion_tokens = {{ $json.usage?.completion_tokens ?? null }}This mapping is a useful contract boundary. Downstream Slack, email, database or ticket nodes receive only the fields they need, while the raw provider response can remain in execution data for debugging according to your retention policy.
Add failure handling before scheduling the workflow
| Failure | What n8n should do | What it should not do |
|---|---|---|
| 400 invalid body | Stop and send the validation message to an error branch | Retry the same malformed JSON |
| 401 unauthorized | Stop, alert the credential owner and rotate or correct the key | Put the key into a Set node |
| 404 model or route | Recheck /v1, endpoint path and model ID | Keep retrying a stale model name |
| 429 rate limit | Wait with bounded exponential backoff and jitter | Launch parallel retries from every item |
| 5xx or timeout | Retry a small number of times, then use a controlled fallback or dead-letter branch | Loop indefinitely |
Empty choices | Preserve the raw response and fail the mapping step clearly | Convert missing output to an empty successful message |
In production, configure a timeout, cap attempts and record the n8n execution ID with the provider request ID. If the workflow performs an irreversible action after the model call, add an idempotency key before that action. A model retry must not send the same email, ticket or payment twice; see the agent tool-call idempotency guide.
Why not rely on the native OpenAI node?
The native node is convenient when its API surface matches the provider. However, n8n versions and AI nodes can differ in Base URL support and whether they call Chat Completions or Responses. A public n8n feature request documented the absence of a custom Base URL in at least one OpenAI node path. The HTTP Request node makes the route, headers and JSON visible, which is better for a gateway tutorial and easier to debug.
Use the native node if your installed version explicitly supports the endpoint and operation you need. Use HTTP Request when you require a precise OpenAI-compatible URL, a stable Chat Completions payload, or provider-specific response logging.
Turn the baseline into a reusable sub-workflow
After the manual test passes:
- Replace Manual Trigger with Execute Workflow Trigger.
- Define inputs such as
prompt,model,temperatureandrequest_context. - Validate
modelagainst an allowlist rather than accepting arbitrary input. - Return only normalized
answer,model, token fields and request ID. - Set a maximum prompt length before sending the request.
- Route 429 and 5xx errors to bounded retry logic.
- Add a human approval step before high-impact downstream tools.
This creates one controlled gateway sub-workflow instead of copying credentials and request bodies into every automation.
Cost and privacy controls users usually miss
An n8n loop can turn one trigger into hundreds of API calls. Count input items before the model node, batch when the task allows it, and stop unexpectedly large runs. Avoid saving sensitive prompts forever in n8n execution history. Redact or shorten retained data according to your security requirements.
The exact-query research signal for n8n openai api is small, but the parent topic n8n ai is materially larger. That is why this page solves a narrow task while also covering credential storage, mapping, retry behavior and reusable workflow design rather than publishing multiple near-duplicate n8n pages.
Sources and testing boundary
- n8n HTTP Request node source and credential options
- n8n custom Base URL feature request
- LumeAPI developer documentation
- Production failure runbook
The node field map and JSON payload were statically checked on August 3, 2026. No customer inference key or live n8n instance was available in this editorial workspace, so readers should run the exact manual-trigger test before enabling a schedule.