Pay-i OpenAI (Proxy)
AI-generatedSummary
Supplies a LangChain ChatOpenAI language model that routes OpenAI chat requests through the Pay-i proxy, attaching tracking headers for cost attribution, use-case tracking and limit enforcement. It is a sub-node that connects to AI Agent/Chain nodes through the Model (AiLanguageModel) connection and makes no API call itself.
Inputs
- model (required) — OpenAI model ID (default gpt-4o). Also sent as the xProxy-PriceAs-Resource header so Pay-i prices usage as that model.
- options — Model settings passed to ChatOpenAI: frequency penalty, max tokens (-1 = no limit), presence penalty, temperature (default 0.7), timeout in ms (default 360000), max retries (default 2), top P.
- userId — User identifier for cost attribution; sent as xProxy-User-ID when non-empty.
- useCaseName — Use case name; defaults to the workflow name with spaces replaced by hyphens. Sent as xProxy-UseCase-Name.
- useCaseId — Use case instance ID; defaults to the n8n execution ID, so each run gets its own Pay-i use case. Sent as xProxy-UseCase-ID.
- useCaseStep — Step label. If left empty or at the default 'Pay-i OpenAI (Proxy)', the node's canvas name is used instead. Sent as xProxy-UseCase-Step.
- advancedTracking — Collection meant for use with Pay-i Support guidance: Use Case Version, Use Case Properties (JSON), Limit IDs (comma-separated, enforced by Pay-i), Debug Logging (verbose server logs with the Pay-i key masked). Flatten Gemini Content is declared but not used by this node's code.
Output shape
A LangChain ChatOpenAI model instance on the Model output connection, for use by downstream AI nodes. It is not item data.
Requires both Pay-i (payiApi) and OpenAI (openAiApi) credentials. Requests go to {Pay-i baseUrl}/api/v1/proxy/openai/v1 with the Pay-i API key in the xProxy-Api-Key header and the OpenAI key as the provider key. Header values are sanitized to ASCII, and empty tracking values are omitted. Token usage is traced through n8n's LLM tracing, and failed attempts are handled by n8n's retry handler.
Examples
Example 1: Track per-run OpenAI spend for an AI Agent workflow
Model gpt-4o, leave the use case fields at their defaults, and connect the Model output to the AI Agent.
Example 2: Attribute costs to a specific customer and step
Set User ID to an expression for the customer ID and Use Case Step to 'Step 1 - Outline'. Set temperature to 0.2 in Options.
Example 3: Enforce a Pay-i budget limit
Under Advanced Tracking, set Limit IDs to your Pay-i limit ID(s), comma-separated.
