OpenAI Chat Model (Custom w/ Caching)
AI-generatedSummary
Provides an OpenAI-compatible chat model as an n8n AI Language Model connection, with optional LiteLLM prompt caching and configurable generation settings. Connect it to a chain or agent and choose a model using the model list or an explicit model ID.
Inputs
- Model (required) — Select a model from the list or enter its ID. Defaults to gpt-4.1-mini.
- Options.Base URL — Override the API base URL; otherwise the node uses the URL in the OpenAI credentials or the OpenAI default.
- Options.Enable Prompt Caching (LiteLLM) — When enabled, adds LiteLLM cache-control injection points for system messages and an Anthropic prompt-caching header. Defaults to false.
- Options.Cache TTL — When prompt caching is enabled, choose the cache duration: 5 minutes by default or 1 hour.
- Options.Response Format — Choose regular text (default) or JSON mode. For JSON mode, the prompt must include the word “json”; the UI also advises using a model released after November 2023.
- Options.Reasoning Effort — For model IDs matching the displayed pattern (o1, o3–o9, or gpt-5), choose low, medium (default), or high reasoning effort.
- Options.Frequency Penalty — Adjust how strongly repeated token frequency is penalized; defaults to 0.
- Options.Presence Penalty — Adjust how strongly tokens already present are penalized; defaults to 0.
- Options.Maximum Number of Tokens — Set the maximum generated tokens; defaults to -1.
- Options.Sampling Temperature — Set sampling randomness; defaults to 0.7.
- Options.Top P — Set nucleus sampling; defaults to 1.
- Options.Max Retries — Set the maximum retry attempts; defaults to 2.
- Options.Timeout — Set the request timeout in milliseconds; defaults to 60000.
Output shape
An AI Language Model connection exposed as the response value for downstream n8n AI nodes.
This is a model sub-node with no regular workflow inputs. It requires OpenAI API credentials. A custom Base URL may point to a non-OpenAI provider; compatibility with chat, tools, and JSON mode depends on that provider.