Rate this page:

ChatCompletionsAPIClient

Constructors

constructor
Copy URL

Methods

addEventListener
Copy URL
addEventListener(event: 

Events

|

ChatCompletionsAPIEvents

,
callback:

Function

):

void

Adds a handler for the specified OpenAI.ChatCompletionsAPIEvents or OpenAI.Events event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called.

Parameters

Returns

  • type:

    void

close
Copy URL
close(): 

void

Closes the OpenAI connection (over WebSocket) or connection attempt.

Returns

  • type:

    void

createChatCompletions
Copy URL
createChatCompletions(parameters: 

Object

):

void

Creates a model response for the given chat conversation. https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create

You can use this API not only with OpenAI, but also with other OpenAI-compatible providers (configure the connector via OpenAI.ChatCompletionsAPIClientParameters.baseUrl). Third-party providers often pass custom model settings through the chat_template_kwargs request parameter.

Parameters

  • parameters:

    Object

    Chat completion parameters

Returns

  • type:

    void

id
Copy URL
id(): 

string

Returns the ChatCompletionsAPIClient id.

Returns

  • type:

    string

removeEventListener
Copy URL
removeEventListener(event: 

Events

|

ChatCompletionsAPIEvents

,
callback:

Function

):

void

Removes a handler for the specified OpenAI.ChatCompletionsAPIEvents or OpenAI.Events event.

Parameters

Returns

  • type:

    void

webSocketId
Copy URL
webSocketId(): 

string

Returns the OpenAI WebSocket id.

Returns

  • type:

    string

Rate this page: