OpenAI Chat Model (JSON Schema)
AI-generatedSummary
Supplies a LangChain ChatOpenAI chat model (via the Chat Completions API) to an AI chain or agent, with optional structured-output support through a user-defined JSON Schema response format.
Inputs
- model (required) — Model to use. For node versions 1.2+ it is a resource locator (pick from a searchable list or enter an ID). Versions below 1.2 use a plain options dropdown. Default is gpt-5-mini.
- options.baseURL — Overrides the API base URL (only shown for versions below 1.1). Falls back to the credential's URL, then https://api.openai.com/v1. Non-OpenAI models may not support tools or JSON formats.
- options.responseFormat — Response format type: Text, JSON Object, or JSON Schema. JSON Schema also takes Name (default response_schema), Schema (JSON, parsed at runtime and errors if invalid), optional Description, and Strict (default false). For JSON modes the prompt must contain the word "json".
- options.temperature — Sampling temperature, 0–2, default 0.7.
- options.topP — Nucleus sampling, 0–1, default 1.
- options.frequencyPenalty — Frequency penalty, -2 to 2, default 0.
- options.presencePenalty — Presence penalty, -2 to 2, default 0.
- options.maxTokens — Maximum tokens to generate; default -1.
- options.reasoningEffort — Low, medium or high. Shown only for o1, o3+ and gpt-5 models. Sent as reasoning_effort.
- options.timeout — Request timeout in milliseconds, default 60000.
- options.maxRetries — Maximum retries, default 2.
Output shape
A single AI Language Model connection (output "Model") carrying a configured ChatOpenAI instance. It makes no direct API call and produces no data items. Downstream chain or agent nodes invoke it.
Requires the openAiApi credential, including optional custom header support. LLM calls are traced to n8n. Rate-limit and non-chat-model errors are rethrown with friendlier messages. The non-chat-model message refers to a "Use Responses API" option that this node does not expose. Strict tool calling is disabled.
Examples
Example 1: Force an AI agent or chain to return structured data such as {name, email}
Model gpt-5-mini; Options > Response Format > Type JSON Schema; paste an object schema with additionalProperties false; Strict on; include "json" in the prompt.
Example 2: Use an OpenAI-compatible server for a basic chat model
Set the credential URL (or Base URL on older versions) to the server endpoint; choose or type the model ID; set Temperature 0.2.
Example 3: Deeper reasoning with a reasoning model
Model o3 or a gpt-5 variant; Reasoning Effort High; raise Timeout to 120000.