Revenium OpenAI Chat Model icon

Revenium OpenAI Chat Model

Chat Model with automatic Revenium usage tracking

Revenium OpenAI Chat Model

AI-generated

Overview

This node implements a chat model using OpenAI's API with integrated automatic usage tracking via Revenium. It allows users to select or specify an OpenAI model to generate chat completions, configure various generation options such as temperature, max tokens, penalties, and timeout, and optionally provide metadata for enhanced tracking and analytics. The node is beneficial for scenarios where detailed usage tracking and analytics are required alongside AI chat completions, such as in enterprise applications or subscription-based AI services. For example, it can be used to generate conversational AI responses while automatically tracking token usage, response quality, and subscriber information for billing or monitoring purposes.

Use Case Examples

  1. Generating chat completions with GPT-4o-mini model while tracking usage and subscriber metadata for billing.
  2. Using a custom model ID to generate AI responses with specific temperature and max token settings, with detailed tracking of request duration and token counts.
  3. Streaming chat completions with automatic timeout and retry handling, capturing detailed usage metadata for analytics.

Properties

Name Meaning
Model Select how to specify the model, either from a dynamically loaded list or by entering a custom model ID.
Model ID The model ID to use for generating the completion. This can be selected from a list or entered manually depending on the 'Model' property.
Options Additional configuration options for the chat completion such as base URL override, frequency penalty, max tokens, presence penalty, temperature, timeout, max retries, and top P.
Usage Metadata Optional metadata for enhanced Revenium tracking and analytics, including identifiers for conversation, subscriber, organization, product, and quality scores.

Output

JSON

  • response - The LangChain ChatOpenAI instance configured with the selected model and options, capable of generating chat completions with integrated Revenium usage tracking.

Dependencies

  • OpenAI API key credential
  • Revenium API key credential

Troubleshooting

  • Model ID is required and must be a non-empty string; ensure the model parameter is correctly set.
  • Temperature must be between 0 and 2; invalid values will cause validation errors.
  • Max tokens must be -1 or a positive number; invalid values will cause validation errors.
  • Timeout must be a valid number and within allowed limits; invalid values will cause validation errors.
  • OpenAI API key must be valid and present; missing or invalid keys will prevent model loading and API calls.
  • Revenium API key and base URL must be correctly configured for usage tracking; errors in tracking calls will be logged but do not block completion generation.
  • Streaming responses may timeout or abort if the configured timeout is exceeded; ensure timeout settings are appropriate.
  • If the OpenAI base URL is invalid, the default URL will be used with a warning logged.

Links

Discussion