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 thelangchainpackage instead). It works with the same API as this class, but can be used with any provider that supports tool calling. You can rundart fix --applyto automatically update your code. - OpenAIToolsAgentOutputParser
-
Note: This class is deprecated. Use
ToolsAgentOutputParser(from thelangchainpackage instead). It is equivalent to this class, but prepared to work with theToolsAgent. You can rundart fix --applyto 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-2anddall-e-3are returned. Must be one ofurlorb64_json. URLs are only valid for 60 minutes after the image has been generated. This parameter isn't supported forgpt-image-1which will always return base64-encoded images. - ImageSize
-
The size of the generated images. Must be one of
1024x1024,1536x1024(landscape),1024x1536(portrait), orauto(default value) forgpt-image-1, one of256x256,512x512, or1024x1024fordall-e-2, and one of1024x1024,1792x1024, or1024x1792fordall-e-3. - ImageStyle
-
The style of the generated images. This parameter is only supported for
dall-e-3. Must be one ofvividornatural. 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.