Hierarchy

  • APIResource
    • Completions

Constructors

Properties

Methods

  • Delete a stored chat completion. Only Chat Completions that have been created with the store parameter set to true can be deleted.

    Parameters

    • completionID: string
    • Optionaloptions: RequestOptions

    Returns APIPromise<ChatCompletionDeleted>

    const chatCompletionDeleted =
    await client.chat.completions.delete('completion_id');
  • List stored Chat Completions. Only Chat Completions that have been stored with the store parameter set to true will be returned.

    Parameters

    Returns PagePromise<ChatCompletionsPage, ChatCompletion>

    // Automatically fetches more pages as needed.
    for await (const chatCompletion of client.chat.completions.list()) {
    // ...
    }
  • Get a stored chat completion. Only Chat Completions that have been created with the store parameter set to true will be returned.

    Parameters

    • completionID: string
    • Optionaloptions: RequestOptions

    Returns APIPromise<ChatCompletion>

    const chatCompletion =
    await client.chat.completions.retrieve('completion_id');
  • A convenience helper for using tool calls with the /chat/completions endpoint which automatically calls the JavaScript functions you provide and sends their results back to the /chat/completions endpoint, looping as long as the model requests function calls.

    For more details and examples, see the docs

    Type Parameters

    • Params extends ChatCompletionToolRunnerParams<any>
    • ParsedT = ExtractParsedContentFromParams<Params>

    Parameters

    • body: Params
    • Optionaloptions: RunnerOptions

    Returns ChatCompletionRunner<ParsedT>

  • Type Parameters

    • Params extends ChatCompletionStreamingToolRunnerParams<any>
    • ParsedT = ExtractParsedContentFromParams<Params>

    Parameters

    • body: Params
    • Optionaloptions: RunnerOptions

    Returns ChatCompletionStreamingRunner<ParsedT>

  • Creates a chat completion stream

    Type Parameters

    • Params extends ChatCompletionStreamParams
    • ParsedT = ExtractParsedContentFromParams<Params>

    Parameters

    • body: Params
    • Optionaloptions: RequestOptions

    Returns ChatCompletionStream<ParsedT>

  • Modify a stored chat completion. Only Chat Completions that have been created with the store parameter set to true can be modified. Currently, the only supported modification is to update the metadata field.

    Parameters

    Returns APIPromise<ChatCompletion>

    const chatCompletion = await client.chat.completions.update(
    'completion_id',
    { metadata: { foo: 'string' } },
    );