n8n · HTTP Request workflow

Call an OpenAI-compatible API without hardcoding a key.

Use n8n's HTTP Request node with a protected Bearer credential, one current model ID, a typed JSON body, and error handling that distinguishes permanent configuration failures from transient responses.

Updated 2026-08-24HTTP Request nodeBearer AuthTyped JSONNon-streaming smoke test

Configure one explicit HTTP Request

Create a Manual Trigger → HTTP Request workflow. Set the request to POST https://www.primoraihub.com/v1/chat/completions, select a Generic Credential Type using Bearer Auth, enable a JSON body, and start with stream: false.

n8n fieldValueWhy
MethodPOSTChat Completions accepts a request body.
URLhttps://www.primoraihub.com/v1/chat/completionsThe HTTP Request node needs the complete endpoint, not only the API root.
AuthenticationGeneric Credential Type → Bearer AuthThe key stays in n8n's credential store instead of the node JSON.
Body Content TypeJSONPreserves arrays, objects, numbers, and booleans.
Response FormatJSONKeeps the returned structure available to later workflow nodes.

Use the official node behavior as the integration boundary

The official n8n HTTP Request documentation supports arbitrary REST URLs, generic credentials, headers, JSON bodies, cURL import, response settings, batching, proxy configuration, and timeouts. The credential reference lists Bearer Auth as a generic credential type.

CheckObserved 2026-08-24Conclusion
Primordial AI GET /v1/models without a keyHTTP 401The model route reaches authentication; this is not a successful n8n model preflight.
Primordial AI POST /v1/chat/completions without a keyHTTP 401The chat route reaches authentication; this is not a successful n8n execution.
n8n credential, model request, chat execution, expressions, retries, and downstream mappingNot independently tested in an n8n instance for this guideRun each authenticated step and inspect the actual execution data.

This guide uses the generic HTTP Request node because its arbitrary REST behavior is documented. It does not claim that every n8n OpenAI or LangChain node accepts this custom endpoint.

Fetch a current model ID before opening n8n

test -n "$PRIMORDIAL_API_KEY" || {
  echo "PRIMORDIAL_API_KEY is not set" >&2
  exit 1
}

curl --fail-with-body --silent --show-error \
  https://www.primoraihub.com/v1/models \
  -H "Authorization: Bearer $PRIMORDIAL_API_KEY" \
  | jq -r '.data[]?.id'

Copy one exact returned ID into the first smoke test. Do not use a guessed name, an old blog example, or the literal MODEL_ID_FROM_V1_MODELS placeholder.

Store only the token in Bearer Auth

  1. In the HTTP Request node, select Generic Credential Type.
  2. Select Bearer Auth and create a dedicated credential.
  3. Paste only the Primordial AI token. Do not add the word Bearer.
  4. Name the credential by environment and purpose, then restrict its allowed domain to www.primoraihub.com when that control is available.

n8n's Bearer Auth implementation adds the Authorization: Bearer prefix. Adding it inside the token field can produce a duplicated prefix and an HTTP 401.

Start with a static, typed JSON smoke test

Enable Send Body, choose JSON, select Using JSON, and replace the model placeholder:

{
  "model": "MODEL_ID_FROM_V1_MODELS",
  "messages": [
    {
      "role": "user",
      "content": "Reply with OK"
    }
  ],
  "stream": false
}

Execute the node once. A successful response verifies only this token, model, endpoint, non-streaming body, and n8n execution at that time. It can consume account quota.

You can also select Import cURL in n8n. Import a cURL command without a real Authorization header, then attach the Bearer credential afterward. n8n documents that imported parameter values are strings, so re-enter the body in JSON mode to preserve false as a boolean.

Map workflow data only after the static test passes

If the previous node emits a prompt field, change the JSON body to an n8n expression that returns an object:

{{
  {
    "model": "MODEL_ID_FROM_V1_MODELS",
    "messages": [
      {
        "role": "user",
        "content": $json.prompt
      }
    ],
    "stream": false
  }
}}

Validate missing, empty, oversized, and non-string input before the request. Keep the original workflow item or a correlation field if downstream nodes must match responses to inputs.

Retry transient failures, not configuration errors

Status or symptomActionRetry?
401Check the selected Bearer credential, token state, whitespace, and duplicated prefix.No
403Check account permission or policy for the selected operation.No
404 or model not foundVerify the complete URL and refresh the exact model ID.No
429Reduce concurrency, use HTTP Request batching, and wait before another attempt.Bounded
5xx or connection timeoutInspect provider status and container network; retry only if repeating the request is safe.Bounded
Invalid JSONUse JSON mode and verify expression output types.No

The n8n HTTP Request common-issues guide documents batching and Retry on Fail. Set a finite maximum and wait interval; do not use automatic retries to hide authentication, route, or schema defects.

Keep credentials out of nodes and exports

  • Use a dedicated key for the workflow and environment.
  • Never paste a real key into a header field, JSON body, sticky note, execution name, or exported workflow.
  • Restrict who can edit or run the workflow and who can use the credential.
  • Prune or limit execution data if prompts or responses contain sensitive business information.
  • Rotate the key after suspected exposure and update only the n8n credential.

n8n's workflow-sharing documentation says editors can run workflows that use credentials even when the credential is not separately shared. Treat workflow access as permission to consume the provider account.

Frequently asked questions

Which n8n node should I use?

Use HTTP Request when you need an explicit custom endpoint and request body. This guide does not assume provider-specific nodes accept a custom API root.

Should the credential contain “Bearer”?

No. Put only the token in the Bearer Auth credential; n8n adds the scheme.

Why use JSON mode after cURL import?

cURL import treats parameter values as strings. JSON mode preserves objects, arrays, numbers, and booleans such as false.

Should every failure be retried?

No. Correct 401, 403, 404, invalid-model, and invalid-JSON failures. Retry only transient 429, 5xx, or network failures with finite limits when duplicate execution is safe.