Optionalfields: ChatOpenAIFieldsOptionalconfiguration: ClientOptions & LegacyOpenAIInputOptionalkwargs: Partial<CallOptions>Optionalconfig: ChatOpenAIStructuredOutputMethodOptions<false>Optionalconfig: ChatOpenAIStructuredOutputMethodOptions<true>
Wrapper around OpenAI large language models that use the Chat endpoint.
To use you should have the
OPENAI_API_KEYenvironment variable set.To use with Azure you should have the:
AZURE_OPENAI_API_KEY,AZURE_OPENAI_API_INSTANCE_NAME,AZURE_OPENAI_API_DEPLOYMENT_NAMEandAZURE_OPENAI_API_VERSIONenvironment variables set.AZURE_OPENAI_BASE_PATHis optional and will overrideAZURE_OPENAI_API_INSTANCE_NAMEif you need to use a custom endpoint.Remarks
Any parameters that are valid to be passed to
openai.createChatCompletioncan be passed through modelKwargs, even if not explicitly available on this class.Example