langchain_openai library

LangChain.dart integration module for OpenAI (GPT-4o, Embeddings, DALLĀ·E, etc.).

Classes

ChatOpenAI
Wrapper around OpenAI Chat API.
ChatOpenAIJsonSchema
Specifies the schema for the response format.
ChatOpenAIOptions
Options to pass into the OpenAI Chat Model.
ChatOpenAIResponseFormat
An object specifying the format that the model must output.
ChatOpenAIResponseFormatJsonObject
The model will respond with a valid JSON object.
ChatOpenAIResponseFormatJsonSchema
The model will respond with a valid JSON object that adheres to the specified schema.
ChatOpenAIResponseFormatText
The model will respond with text.
OpenAI
Wrapper around OpenAI Completions API.
OpenAIDallETool
Wrapper for OpenAI's DALL-E Image Generator API.
OpenAIDallEToolOptions
Generation options to pass into the OpenAIDallETool.
OpenAIEmbeddings
Wrapper around OpenAI Embeddings API.
OpenAIOptions
Options to pass into the OpenAI LLM.
OpenAIQAWithSourcesChain
A chain that answers questions returning a QAWithSources object containing the answers with the sources used to answer the question.
OpenAIQAWithStructureChain<S extends Object>
A chain that answers questions returning the answers with the specified structure (ToolSpec).
OpenAIToolsAgent

Note: This class is deprecated. Use ToolsAgent (from the langchain package instead). It works with the same API as this class, but can be used with any provider that supports tool calling. You can run dart fix --apply to automatically update your code.

OpenAIToolsAgentOutputParser

Note: This class is deprecated. Use ToolsAgentOutputParser (from the langchain package instead). It is equivalent to this class, but prepared to work with the ToolsAgent. You can run dart fix --apply to automatically update your code.

QAWithSources
The answer to a question with the sources used to answer it.
QAWithSourcesOutputParser
A parser that converts the output of the OpenAI API into a QAWithSources.

Enums

ChatOpenAIReasoningEffort
Constrains effort on reasoning for reasoning models.
ChatOpenAIServiceTier
Specifies the latency tier to use for processing the request. This is relevant for customers subscribed to the scale tier service.
ChatOpenAIVerbosity
Constrains the verbosity of the model's response.
ImageQuality
The quality of the image that will be generated.
ImageResponseFormat
The format in which generated images with dall-e-2 and dall-e-3 are returned. Must be one of url or b64_json. URLs are only valid for 60 minutes after the image has been generated. This parameter isn't supported for gpt-image-1 which will always return base64-encoded images.
ImageSize
The size of the generated images. Must be one of 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait), or auto (default value) for gpt-image-1, one of 256x256, 512x512, or 1024x1024 for dall-e-2, and one of 1024x1024, 1792x1024, or 1024x1792 for dall-e-3.
ImageStyle
The style of the generated images. This parameter is only supported for dall-e-3. Must be one of vivid or natural. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images.

Exceptions / Errors

OpenAIClientException
HTTP exception handler for OpenAIClient
OpenAIRefusalException
Exception thrown when OpenAI Structured Outputs API returns a refusal.