Skip to main content

Automate a text request with n8n

Use n8n's built-in HTTP Request node with Primex Chat Completions. Select an eligible model in n8n Setup. This workflow sends a text prompt and returns the answer, request ID, model and usage. Primex does not ship a native n8n node.

Import the workflow​

Use your existing n8n Cloud or self-hosted instance. If you need an instance, follow the official installation options.

  1. Download the chat workflow. It contains a model placeholder and no API key or saved credential reference. Setup also provides a download with your selected model filled in.
  2. In a new n8n workflow, open the workflow menu and choose Import from File. Import the JSON. Keep this as a new workflow rather than replacing existing work.
  3. Open Request inputs and set model to your exact eligible offering ID. Set prompt to your first short text request.
  4. Configure the credential below, then use Execute workflow to run it manually.

The template has no schedule or webhook. Importing it does not send a request.

Create the credential​

Create a dedicated Primex API key in API Keys and use the available key spend controls for this automation.

In Primex Chat, leave Authentication as Generic Credential Type and Generic Auth Type as Header Auth. Create or select an n8n Header Auth credential:

Credential fieldValue
NameAuthorization
ValueBearer YOUR_API_KEY

Replace the placeholder inside the credential. Select the credential in the node and save. Keep the key out of Request inputs, workflow JSON and ordinary header parameters. Your n8n instance owns its credential storage and access controls.

The request uses these settings:

HTTP Request settingValue
MethodPOST
URLhttps://gateway.primexos.com/v1/chat/completions
Body content typeJSON
Specify bodyUsing JSON
Include Response Headers and StatusOn
Response formatJSON
Never ErrorOff
Retry On FailOff
Follow RedirectsOff

The JSON body is an n8n expression. JSON.stringify escapes quotes and newlines in the prompt instead of interpolating them into raw JSON:

JavaScript
{{ JSON.stringify({
model: $json.model,
messages: [{ role: 'user', content: $json.prompt }],
stream: false,
}) }}

When entering a complete expression directly in n8n's JSON parameter editor, choose Expression mode. The downloadable JSON's leading = is n8n's stored expression marker.

Run and read the result​

Click Execute workflow. Has a text answer checks the response shape; its true branch sends output to Read result. Expect:

  • answer: the text from body.choices[0].message.content.
  • requestId: the x-primex-request-id response header, or an empty string if absent.
  • model and usage: fields returned by the response; these are not a cost quote.

Use the request ID, dedicated key and run time to investigate the request in Primex Usage. n8n's execution record is separate from Primex's usage and billing record.

The template stops on HTTP errors. A successful HTTP response with a missing, non-string or empty text answer goes to Stop: no text answer. Inspect the HTTP node output rather than treating that run as a completed text task. That response might describe another output type, a tool call, or an incompatible contract.

Failures and production use​

SymptomNext action
Credential missing or 401Select the Header Auth credential; check Bearer and the active key.
404 or unknown modelUse the full Chat Completions URL and exact ID from Setup.
402Inspect credit balance and key spend controls before running again.
429Identify the limit in the response and Usage. Reduce concurrency or wait for a temporary window; waiting does not reset a monthly spend cap.
No text answerInspect the response body and selected model; this template handles text, not tool-only output.
Timeout or connection failureCheck the n8n execution and Primex Usage before manually retrying. The first request may already have completed.

Automatic retries are disabled. The HTTP node's timeout is configured to 60,000ms; n8n describes this option as waiting for response headers/body start, so it does not establish a guaranteed total task deadline. Review your instance's execution timeouts and downstream side effects before adding schedules, webhooks or batches. Each submitted item can create a separate billable model request. A later n8n branch failure does not automatically refund an earlier completed Primex request. See Errors & limits and Usage.

Workflow execution data can contain prompts, outputs and response headers. Review n8n's storage, sharing and retention settings separately from Primex's privacy policy. Exported workflows can contain credential names and IDs, and ordinary node parameters can expose pasted secrets; review them before sharing. The shipped template omits both secrets and credential references.

To disconnect, remove the credential selection and unused workflow, delete the n8n credential if appropriate, and revoke the dedicated Primex key.

Need help connecting? Report a setup issue.