langchain.js
    Preparing search index...

    Class AzureChatOpenAICompletions<CallOptions>

    Type Parameters

    Implements

    Index

    Constructors

    Properties

    __includeRawResponse?: boolean

    Whether to include the raw OpenAI response in the output message's "additional_kwargs" field. Currently in experimental beta.

    apiKey?: string | ApiKeySetter

    API key to use when making requests to OpenAI. Defaults to the value of OPENAI_API_KEY environment variable.

    audio?: ChatCompletionAudioParam

    Parameters for audio output. Required when audio output is requested with modalities: ["audio"]. Learn more.

    azureADTokenProvider?: () => Promise<string>

    A function that returns an access token for Microsoft Entra (formerly known as Azure Active Directory), which will be invoked on every request.

    azureOpenAIApiDeploymentName?: string

    Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI. This is the name of the deployment you created in the Azure portal. e.g. "my-openai-deployment" this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/

    azureOpenAIApiInstanceName?: string

    Azure OpenAI API instance name to use when making requests to Azure OpenAI. this is the name of the instance you created in the Azure portal. e.g. "my-openai-instance" this will be used in the endpoint URL: https://my-openai-instance.openai.azure.com/openai/deployments/{DeploymentName}/

    azureOpenAIApiKey?: string

    API key to use when making requests to Azure OpenAI.

    azureOpenAIApiVersion?: string

    API version to use when making requests to Azure OpenAI.

    azureOpenAIBasePath?: string

    Custom base url for Azure OpenAI API. This is useful in case you have a deployment in another region. e.g. setting this value to "https://westeurope.api.cognitive.microsoft.com/openai/deployments" will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/

    azureOpenAIEndpoint?: string

    Custom endpoint for Azure OpenAI API. This is useful in case you have a deployment in another region. e.g. setting this value to "https://westeurope.api.cognitive.microsoft.com/" will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/

    defaultOptions: CallOptions
    frequencyPenalty?: number

    Penalizes repeated tokens according to frequency

    lc_serializable: boolean = true
    logitBias?: Record<string, number>

    Dictionary used to adjust the probability of specific tokens being generated

    logprobs?: boolean

    Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.

    maxTokens?: number

    Maximum number of tokens to generate in the completion. -1 returns as many tokens as possible given the prompt and the model's maximum context size.

    modalities?: ChatCompletionModality[]

    Output types that you would like the model to generate for this request. Most models are capable of generating text, which is the default:

    ["text"]

    The gpt-4o-audio-preview model can also be used to generate audio. To request that this model generate both text and audio responses, you can use:

    ["text", "audio"]

    model: string = "gpt-3.5-turbo"

    Model name to use

    modelKwargs?: Record<string, any>

    Holds any additional parameters that are valid to pass to openai.createCompletion that are not explicitly specified on this class.

    n?: number

    Number of completions to generate for each prompt

    organization?: string
    presencePenalty?: number

    Penalizes repeated tokens

    promptCacheKey: string

    Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Learn more.

    reasoning?: Reasoning

    Options for reasoning models.

    Note that some options, like reasoning summaries, are only available when using the responses API. This option is ignored when not using a reasoning model.

    service_tier?: null | "auto" | "default" | "flex" | "scale" | "priority"

    Service tier to use for this request. Can be "auto", "default", or "flex" or "priority". Specifies the service tier for prioritization and latency optimization.

    stop?: string[]

    List of stop words to use when generating Alias for stopSequences

    stopSequences?: string[]

    List of stop words to use when generating

    streaming: boolean = false

    Whether to stream the results or not. Enabling disables tokenUsage reporting

    streamUsage: boolean = true

    Whether or not to include token usage data in streamed chunks.

    true
    
    supportsStrictToolCalling?: boolean

    Whether the model supports the strict argument when passing in tools. If undefined the strict argument will not be passed to OpenAI.

    temperature?: number

    Sampling temperature to use

    timeout?: number

    Timeout to use when making requests to OpenAI.

    topLogprobs?: number

    An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.

    topP?: number

    Total probability mass of tokens to consider at each step

    user?: string

    Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse.

    The verbosity of the model's response.

    zdrEnabled?: boolean

    Must be set to true in tenancies with Zero Data Retention. Setting to true will disable output storage in the Responses API, but this DOES NOT enable Zero Data Retention in your OpenAI organization or project. This must be configured directly with OpenAI.

    See: https://platform.openai.com/docs/guides/your-data https://platform.openai.com/docs/api-reference/responses/create#responses-create-store

    false
    

    Accessors

    • get lc_aliases(): Record<string, string>

      Returns Record<string, string>

    • get lc_secrets(): undefined | { [key: string]: string }

      Returns undefined | { [key: string]: string }

    • get lc_serializable_keys(): string[]

      Returns string[]

    • get profile(): ModelProfile

      Return profiling information for the model.

      Provides information about the model's capabilities and constraints, including token limits, multimodal support, and advanced features like tool calling and structured output.

      Returns ModelProfile

      An object describing the model's capabilities and constraints

      const model = new ChatOpenAI({ model: "gpt-4o" });
      const profile = model.profile;
      console.log(profile.maxInputTokens); // 128000
      console.log(profile.imageInputs); // true

    Methods

    • Parameters

      • delta: Record<string, any>
      • rawResponse: ChatCompletionChunk
      • OptionaldefaultRole: ChatCompletionRole

      Returns BaseMessageChunk

      This function was hoisted into a publicly accessible function from a different export, but to maintain backwards compatibility with chat models that depend on ChatOpenAICompletions, we'll keep it here as an overridable method. This will be removed in a future release

    • Parameters

      • message: ChatCompletionMessage
      • rawResponse: ChatCompletion

      Returns BaseMessage

      This function was hoisted into a publicly accessible function from a different export, but to maintain backwards compatibility with chat models that depend on ChatOpenAICompletions, we'll keep it here as an overridable method. This will be removed in a future release

    • Parameters

      • messages: BaseMessage[]
      • options: unknown
      • OptionalrunManager: any

      Returns Promise<ChatResult>

    • Returns string

    • Parameters

      • messages: BaseMessage[]
      • options: unknown
      • OptionalrunManager: any

      Returns AsyncGenerator<ChatGenerationChunk>

    • Parameters

      Returns Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>

    • Parameters

      • request: ChatCompletionCreateParamsStreaming
      • OptionalrequestOptions: RequestOptions

      Returns Promise<AsyncIterable<ChatCompletionChunk, any, any>>

    • Parameters

      • request: ChatCompletionCreateParamsNonStreaming
      • OptionalrequestOptions: RequestOptions

      Returns Promise<ChatCompletion>

    • Parameters

      • options: unknown

      Returns LangSmithParams

    • Parameters

      • messages: BaseMessage[]

      Returns Promise<{ countPerMessage: any; totalCount: number }>

    • Get the identifying parameters for the model

      Returns Omit<ChatCompletionCreateParams, "messages"> & { model_name: string } & ClientOptions

    • Returns Serialized

    • Type Parameters

      • RunOutput extends Record<string, any> = Record<string, any>

      Parameters

      • outputSchema: any
      • Optionalconfig: any

      Returns Runnable<BaseLanguageModelInput, RunOutput>

    • Type Parameters

      • RunOutput extends Record<string, any> = Record<string, any>

      Parameters

      • outputSchema: any
      • Optionalconfig: any

      Returns Runnable<BaseLanguageModelInput, { parsed: RunOutput; raw: BaseMessage }>

    • Type Parameters

      • RunOutput extends Record<string, any> = Record<string, any>

      Parameters

      • outputSchema: any
      • Optionalconfig: any

      Returns any

    • Returns string