n8n

Use odnoga from any n8n workflow with the built-in OpenAI nodes — no custom node required. You get odnoga's routing, fallbacks, response cache, budgets, alerts, per-end-user metering, and unified cost tracking inside your existing automations.

Why this works

airouter-openai-compat speaks the OpenAI Chat Completions, Embeddings, and Messages API verbatim. Any n8n node that lets you override the OpenAI base URL — the OpenAI node, the OpenAI Chat Model sub-node (used by AI Agent / Chains / Tools), the Embeddings OpenAI node — will route through odnoga transparently.

Prerequisites

  • n8n 1.30 or newer (self-hosted or n8n Cloud)
  • An odnoga API key: sk_live_... (production) or sk_test_... (test)
  • Models you intend to call must be enabled in your workspace allowlist (or the allowlist must be unset)

1. Create the OpenAI credential

In n8n: Credentials → New → OpenAI API

FieldValue
API Keysk_live_... or sk_test_...
Base URLhttps://api.odnoga.com/functions/v1/airouter-openai-compat/v1
Organization IDleave empty

Save. The same credential works across the OpenAI node, OpenAI Chat Model, and OpenAI Embeddings nodes.

The trailing /v1 is required — n8n appends paths like /chat/completions directly to the Base URL.

2. Use it in the OpenAI node

Drop an OpenAI node, select the credential, then:

  • Resource: ChatOperation: Message a model
  • Model: any odnoga model slug, e.g. gpt-4o-mini, claude-3-5-sonnet-latest, gemini-2.0-flash
  • Messages: as usual

odnoga applies routing rules, prompt versioning, cache lookups, and budget gates before forwarding to the upstream vendor. The response is OpenAI-shaped, so all downstream n8n expressions ({{ $json.choices[0].message.content }}) work unchanged.

3. Use it in AI Agent / LangChain nodes

The LangChain nodes in n8n use an OpenAI Chat Model sub-node:

  1. Add an AI Agent (or Basic LLM Chain, Tools Agent, etc.)
  2. Click the Chat Model input → choose OpenAI Chat Model
  3. Pick the credential created above
  4. Set the model slug

Memory, tools, structured output, and chains all work — they only require the OpenAI wire format, which odnoga speaks natively.

4. Per-end-user metering

If your workflow processes events for multiple end-users (your customers' customers), attribute each call so usage rolls up correctly in odnoga's billing and analytics.

In the OpenAI node: Options → Headers → Add Header

NameValue
x-airouter-end-user={{ $json.userId }} (or similar)

Now every request in that node is metered against $json.userId. The same header works on every odnoga endpoint.

5. Managed prompts (HTTP Request node)

The OpenAI node doesn't expose odnoga's prompt.slug field. To call a managed prompt from n8n today, use the HTTP Request node:

  • Method: POST
  • URL: https://api.odnoga.com/functions/v1/airouter-openai-compat/v1/chat/completions
  • Authentication: Generic Credential → Header Auth → Authorization: Bearer sk_live_...
  • Headers: x-airouter-end-user: {{ $json.userId }}
  • Body (JSON):
{
  "model": "gpt-4o-mini",
  "prompt": {
    "slug": "welcome-email",
    "label": "production",
    "variables": { "name": "{{ $json.name }}" }
  }
}

Variables are rendered server-side, A/B experiments fire automatically, and the resolved prompt_version_id is recorded on the request row.

6. Embeddings

The Embeddings OpenAI node (used by Vector Store nodes) accepts the same credential. Set the model to e.g. text-embedding-3-small and odnoga handles the rest — including cost tracking against your workspace budget.

7. Streaming

n8n's OpenAI node consumes the full response before continuing — streaming is invisible to the workflow. If you specifically need SSE streaming (e.g. piping chunks to a webhook), use the HTTP Request node with "stream": true in the body and enable Response → Include Response Headers and Status → Streaming in n8n 1.50+.

8. Troubleshooting

SymptomCause / Fix
401 invalid_api_keyKey is wrong, revoked, or environment mismatch (sk_test_ against a live-only workspace).
402 out of creditsWorkspace credit balance is exhausted. Top up in the odnoga billing page.
404 model_not_foundModel not in your workspace's allowlist, or slug typo. Check Allowed Models in settings.
429 budget exhaustedWorkspace budget cap hit. Increase the cap or wait for the period reset.
Per-end-user usage stays at zerox-airouter-end-user header missing or empty. Confirm via the request inspector.
Base URL not honoredYou forgot the trailing /v1, or n8n cached the old credential — re-save it.

Use the request ID from the response header x-airouter-request-id to look the call up in the workspace Requests panel.

Roadmap

A dedicated community node — n8n-nodes-airouter — is planned. It will add:

  • A branded odnoga credential type with environment hint
  • First-class Prompt by slug operation (no HTTP Request node needed)
  • Automatic x-airouter-end-user injection from workflow context
  • Operations for list models, embeddings, and Anthropic messages

Until then, the OpenAI-compatible path above covers every production use case.

See also