INTEGRATION GUIDE

n8n

Prepaid text requests

Call ZRouter from an n8n HTTP Request node, including account authentication and BYOK.

On this page

Choose a supported workflow

Use text generation or text embeddings with an account API key. AI Agent workflows that send tools are blocked by prepaid billing. Images, audio, file uploads, and response lifecycle requests are also outside the prepaid API.

The HTTP Request node exposes the URL, headers, and JSON directly, so it works without depending on whether your installed OpenAI node exposes a custom base URL.

Create the credential

Create a ZRouter account key dedicated to this workflow. In n8n, create a Header Auth credential with header name Authorization and value Bearer YOUR_ZROUTER_ACCOUNT_KEY. Store the secret in credentials rather than a hard-coded workflow field.

Configure the HTTP Request node

Setting Value
Method POST
URL https://zrouter.si/v1/chat/completions
Authentication Generic Credential Type → Header Auth
Credential Your ZRouter credential
Send body Enabled, JSON
Response format JSON

Use this JSON body and replace the model ID:

{
  "model": "PROVIDER_INSTANCE/MODEL_ID",
  "messages": [{ "role": "user", "content": "Summarize: the deployment completed successfully." }],
  "max_tokens": 256,
  "stream": false
}

Read the text from choices[0].message.content. Once the fixed example succeeds, substitute workflow data using n8n's expression editor. Keep inputs within the gateway limits. See n8n's HTTP Request node documentation.

Optional BYOK

Save a provider key in your ZRouter dashboard. Add a request header named X-ZRouter-BYOK with value true and use a model belonging to that provider instance. Keep Header Auth enabled: the account key authenticates to ZRouter while the saved provider key authenticates upstream.

Operations and errors

Execute once and inspect the status, JSON response, and ZRouter usage and ledger. Each successful model request consumes tokens. Repeating nodes or retrying completed requests can create additional charges; the inference API does not provide a general retry deduplication guarantee.

The n8n server or container must reach the gateway. For local Docker on macOS/Windows, the gateway URL may need host.docker.internal rather than localhost. Use HTTPS in production. For 402, reduce the requested output or add credit. See shared troubleshooting.

Vendor configuration reviewed September 30, 2026. Model and client capabilities vary. Check the linked official sources when upgrading.