OpenAI Chat Model with Langfuse icon

OpenAI Chat Model with Langfuse

For advanced usage with an AI chain

OpenAI Chat Model with Langfuse

AI-generated

Summary

Constructs an OpenAI Chat model with Langfuse tracing callbacks, returning a ChatOpenAI instance configured via model, options, and metadata parameters.

Inputs

  • langfuseMetadata — Langfuse metadata for trace attribution and session grouping. Passed to Langfuse CallbackHandler to attach custom metadata, session ID, and user ID to traces.
  • model (required) — The OpenAI model to use for chat completion. Choose from the model list or specify a model ID. Models incompatible with chat (e.g., embeddings, instruct, older davinci) are filtered out.
  • options — Additional options forwarded to the OpenAI Chat model. Includes base URL override, temperature, max tokens, response format, timeout, top-p, frequency/presence penalty, max retries, and reasoning effort.

Output shape

ChatOpenAI instance returned as { response: model }

Output is an ai_languageModel type. The model instance includes Langfuse tracing via CallbackHandler and N8nLlmTracing, enabling per-run trace capture.

Examples

Example 1: Generate a chat completion with Langfuse tracing, custom metadata, and JSON response format.

Set model to gpt-4o, responseFormat to json_object, include 'json' in the user prompt, set customMetadata with project/workflow details, and provide sessionId for trace grouping.

Links

Discussion