feat: Passwordless cross-device authentication

- Arkitektur: docs/auth/passwordless-architecture.md
- Backend: iom/quixzoom-auth-service/ (FastAPI + Redis)
- Webb: quixzoom-market-pages/se/login/ (QR-kod + polling)
- App: iom/quixzoom-app/src/features/auth/ (push + deep links)

Flöde: QR-kod → app-godkännande → webb-inloggad
This commit is contained in:
Bernt
2026-07-07 07:11:50 +00:00
parent 4aa984ad74
commit 6989a98d75
61843 changed files with 5491611 additions and 872231 deletions
+1227
View File
@@ -0,0 +1,1227 @@
import { APIResource } from "../../core/resource.mjs";
import * as Shared from "../shared.mjs";
import * as MessagesAPI from "./threads/messages.mjs";
import * as ThreadsAPI from "./threads/threads.mjs";
import * as RunsAPI from "./threads/runs/runs.mjs";
import * as StepsAPI from "./threads/runs/steps.mjs";
import { APIPromise } from "../../core/api-promise.mjs";
import { CursorPage, type CursorPageParams, PagePromise } from "../../core/pagination.mjs";
import { RequestOptions } from "../../internal/request-options.mjs";
import { AssistantStream } from "../../lib/AssistantStream.mjs";
/**
* Build Assistants that can call models and use tools.
*/
export declare class Assistants extends APIResource {
/**
* Create an assistant with a model and instructions.
*
* @deprecated
*/
create(body: AssistantCreateParams, options?: RequestOptions): APIPromise<Assistant>;
/**
* Retrieves an assistant.
*
* @deprecated
*/
retrieve(assistantID: string, options?: RequestOptions): APIPromise<Assistant>;
/**
* Modifies an assistant.
*
* @deprecated
*/
update(assistantID: string, body: AssistantUpdateParams, options?: RequestOptions): APIPromise<Assistant>;
/**
* Returns a list of assistants.
*
* @deprecated
*/
list(query?: AssistantListParams | null | undefined, options?: RequestOptions): PagePromise<AssistantsPage, Assistant>;
/**
* Delete an assistant.
*
* @deprecated
*/
delete(assistantID: string, options?: RequestOptions): APIPromise<AssistantDeleted>;
}
export type AssistantsPage = CursorPage<Assistant>;
/**
* @deprecated Represents an `assistant` that can call the model and use tools.
*/
export interface Assistant {
/**
* The identifier, which can be referenced in API endpoints.
*/
id: string;
/**
* The Unix timestamp (in seconds) for when the assistant was created.
*/
created_at: number;
/**
* The description of the assistant. The maximum length is 512 characters.
*/
description: string | null;
/**
* The system instructions that the assistant uses. The maximum length is 256,000
* characters.
*/
instructions: string | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata: Shared.Metadata | null;
/**
* ID of the model to use. You can use the
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to
* see all of your available models, or see our
* [Model overview](https://platform.openai.com/docs/models) for descriptions of
* them.
*/
model: string;
/**
* The name of the assistant. The maximum length is 256 characters.
*/
name: string | null;
/**
* The object type, which is always `assistant`.
*/
object: 'assistant';
/**
* A list of tool enabled on the assistant. There can be a maximum of 128 tools per
* assistant. Tools can be of types `code_interpreter`, `file_search`, or
* `function`.
*/
tools: Array<AssistantTool>;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
tool_resources?: Assistant.ToolResources | null;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the
* model considers the results of the tokens with top_p probability mass. So 0.1
* means only the tokens comprising the top 10% probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
}
export declare namespace Assistant {
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter`` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The ID of the
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this assistant. There can be a maximum of 1 vector store attached to
* the assistant.
*/
vector_store_ids?: Array<string>;
}
}
}
export interface AssistantDeleted {
id: string;
deleted: boolean;
object: 'assistant.deleted';
}
/**
* Represents an event emitted when streaming a Run.
*
* Each event in a server-sent events stream has an `event` and `data` property:
*
* ```
* event: thread.created
* data: {"id": "thread_123", "object": "thread", ...}
* ```
*
* We emit events whenever a new object is created, transitions to a new state, or
* is being streamed in parts (deltas). For example, we emit `thread.run.created`
* when a new run is created, `thread.run.completed` when a run completes, and so
* on. When an Assistant chooses to create a message during a run, we emit a
* `thread.message.created event`, a `thread.message.in_progress` event, many
* `thread.message.delta` events, and finally a `thread.message.completed` event.
*
* We may add additional events over time, so we recommend handling unknown events
* gracefully in your code. See the
* [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview)
* to learn how to integrate the Assistants API with streaming.
*/
export type AssistantStreamEvent = AssistantStreamEvent.ThreadCreated | AssistantStreamEvent.ThreadRunCreated | AssistantStreamEvent.ThreadRunQueued | AssistantStreamEvent.ThreadRunInProgress | AssistantStreamEvent.ThreadRunRequiresAction | AssistantStreamEvent.ThreadRunCompleted | AssistantStreamEvent.ThreadRunIncomplete | AssistantStreamEvent.ThreadRunFailed | AssistantStreamEvent.ThreadRunCancelling | AssistantStreamEvent.ThreadRunCancelled | AssistantStreamEvent.ThreadRunExpired | AssistantStreamEvent.ThreadRunStepCreated | AssistantStreamEvent.ThreadRunStepInProgress | AssistantStreamEvent.ThreadRunStepDelta | AssistantStreamEvent.ThreadRunStepCompleted | AssistantStreamEvent.ThreadRunStepFailed | AssistantStreamEvent.ThreadRunStepCancelled | AssistantStreamEvent.ThreadRunStepExpired | AssistantStreamEvent.ThreadMessageCreated | AssistantStreamEvent.ThreadMessageInProgress | AssistantStreamEvent.ThreadMessageDelta | AssistantStreamEvent.ThreadMessageCompleted | AssistantStreamEvent.ThreadMessageIncomplete | AssistantStreamEvent.ErrorEvent;
export declare namespace AssistantStreamEvent {
/**
* Occurs when a new
* [thread](https://platform.openai.com/docs/api-reference/threads/object) is
* created.
*/
interface ThreadCreated {
/**
* Represents a thread that contains
* [messages](https://platform.openai.com/docs/api-reference/messages).
*/
data: ThreadsAPI.Thread;
event: 'thread.created';
/**
* Whether to enable input audio transcription.
*/
enabled?: boolean;
}
/**
* Occurs when a new
* [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
*/
interface ThreadRunCreated {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.created';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `queued` status.
*/
interface ThreadRunQueued {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.queued';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to an `in_progress` status.
*/
interface ThreadRunInProgress {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.in_progress';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `requires_action` status.
*/
interface ThreadRunRequiresAction {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.requires_action';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* is completed.
*/
interface ThreadRunCompleted {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.completed';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* ends with status `incomplete`.
*/
interface ThreadRunIncomplete {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.incomplete';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* fails.
*/
interface ThreadRunFailed {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.failed';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `cancelling` status.
*/
interface ThreadRunCancelling {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.cancelling';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* is cancelled.
*/
interface ThreadRunCancelled {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.cancelled';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* expires.
*/
interface ThreadRunExpired {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.expired';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is created.
*/
interface ThreadRunStepCreated {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.created';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* moves to an `in_progress` state.
*/
interface ThreadRunStepInProgress {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.in_progress';
}
/**
* Occurs when parts of a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* are being streamed.
*/
interface ThreadRunStepDelta {
/**
* Represents a run step delta i.e. any changed fields on a run step during
* streaming.
*/
data: StepsAPI.RunStepDeltaEvent;
event: 'thread.run.step.delta';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is completed.
*/
interface ThreadRunStepCompleted {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.completed';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* fails.
*/
interface ThreadRunStepFailed {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.failed';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is cancelled.
*/
interface ThreadRunStepCancelled {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.cancelled';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* expires.
*/
interface ThreadRunStepExpired {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.expired';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) is
* created.
*/
interface ThreadMessageCreated {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.created';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) moves
* to an `in_progress` state.
*/
interface ThreadMessageInProgress {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.in_progress';
}
/**
* Occurs when parts of a
* [Message](https://platform.openai.com/docs/api-reference/messages/object) are
* being streamed.
*/
interface ThreadMessageDelta {
/**
* Represents a message delta i.e. any changed fields on a message during
* streaming.
*/
data: MessagesAPI.MessageDeltaEvent;
event: 'thread.message.delta';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) is
* completed.
*/
interface ThreadMessageCompleted {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.completed';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) ends
* before it is completed.
*/
interface ThreadMessageIncomplete {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.incomplete';
}
/**
* Occurs when an
* [error](https://platform.openai.com/docs/guides/error-codes#api-errors) occurs.
* This can happen due to an internal server error or a timeout.
*/
interface ErrorEvent {
data: Shared.ErrorObject;
event: 'error';
}
}
export type AssistantTool = CodeInterpreterTool | FileSearchTool | FunctionTool;
export interface CodeInterpreterTool {
/**
* The type of tool being defined: `code_interpreter`
*/
type: 'code_interpreter';
}
export interface FileSearchTool {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
/**
* Overrides for the file search tool.
*/
file_search?: FileSearchTool.FileSearch;
}
export declare namespace FileSearchTool {
/**
* Overrides for the file search tool.
*/
interface FileSearch {
/**
* The maximum number of results the file search tool should output. The default is
* 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
* 1 and 50 inclusive.
*
* Note that the file search tool may output fewer than `max_num_results` results.
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
max_num_results?: number;
/**
* The ranking options for the file search. If not specified, the file search tool
* will use the `auto` ranker and a score_threshold of 0.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
ranking_options?: FileSearch.RankingOptions;
}
namespace FileSearch {
/**
* The ranking options for the file search. If not specified, the file search tool
* will use the `auto` ranker and a score_threshold of 0.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
interface RankingOptions {
/**
* The score threshold for the file search. All values must be a floating point
* number between 0 and 1.
*/
score_threshold: number;
/**
* The ranker to use for the file search. If not specified will use the `auto`
* ranker.
*/
ranker?: 'auto' | 'default_2024_08_21';
}
}
}
export interface FunctionTool {
function: Shared.FunctionDefinition;
/**
* The type of tool being defined: `function`
*/
type: 'function';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) is
* created.
*/
export type MessageStreamEvent = MessageStreamEvent.ThreadMessageCreated | MessageStreamEvent.ThreadMessageInProgress | MessageStreamEvent.ThreadMessageDelta | MessageStreamEvent.ThreadMessageCompleted | MessageStreamEvent.ThreadMessageIncomplete;
export declare namespace MessageStreamEvent {
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) is
* created.
*/
interface ThreadMessageCreated {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.created';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) moves
* to an `in_progress` state.
*/
interface ThreadMessageInProgress {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.in_progress';
}
/**
* Occurs when parts of a
* [Message](https://platform.openai.com/docs/api-reference/messages/object) are
* being streamed.
*/
interface ThreadMessageDelta {
/**
* Represents a message delta i.e. any changed fields on a message during
* streaming.
*/
data: MessagesAPI.MessageDeltaEvent;
event: 'thread.message.delta';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) is
* completed.
*/
interface ThreadMessageCompleted {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.completed';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) ends
* before it is completed.
*/
interface ThreadMessageIncomplete {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.incomplete';
}
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is created.
*/
export type RunStepStreamEvent = RunStepStreamEvent.ThreadRunStepCreated | RunStepStreamEvent.ThreadRunStepInProgress | RunStepStreamEvent.ThreadRunStepDelta | RunStepStreamEvent.ThreadRunStepCompleted | RunStepStreamEvent.ThreadRunStepFailed | RunStepStreamEvent.ThreadRunStepCancelled | RunStepStreamEvent.ThreadRunStepExpired;
export declare namespace RunStepStreamEvent {
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is created.
*/
interface ThreadRunStepCreated {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.created';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* moves to an `in_progress` state.
*/
interface ThreadRunStepInProgress {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.in_progress';
}
/**
* Occurs when parts of a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* are being streamed.
*/
interface ThreadRunStepDelta {
/**
* Represents a run step delta i.e. any changed fields on a run step during
* streaming.
*/
data: StepsAPI.RunStepDeltaEvent;
event: 'thread.run.step.delta';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is completed.
*/
interface ThreadRunStepCompleted {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.completed';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* fails.
*/
interface ThreadRunStepFailed {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.failed';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is cancelled.
*/
interface ThreadRunStepCancelled {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.cancelled';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* expires.
*/
interface ThreadRunStepExpired {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.expired';
}
}
/**
* Occurs when a new
* [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
*/
export type RunStreamEvent = RunStreamEvent.ThreadRunCreated | RunStreamEvent.ThreadRunQueued | RunStreamEvent.ThreadRunInProgress | RunStreamEvent.ThreadRunRequiresAction | RunStreamEvent.ThreadRunCompleted | RunStreamEvent.ThreadRunIncomplete | RunStreamEvent.ThreadRunFailed | RunStreamEvent.ThreadRunCancelling | RunStreamEvent.ThreadRunCancelled | RunStreamEvent.ThreadRunExpired;
export declare namespace RunStreamEvent {
/**
* Occurs when a new
* [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
*/
interface ThreadRunCreated {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.created';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `queued` status.
*/
interface ThreadRunQueued {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.queued';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to an `in_progress` status.
*/
interface ThreadRunInProgress {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.in_progress';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `requires_action` status.
*/
interface ThreadRunRequiresAction {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.requires_action';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* is completed.
*/
interface ThreadRunCompleted {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.completed';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* ends with status `incomplete`.
*/
interface ThreadRunIncomplete {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.incomplete';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* fails.
*/
interface ThreadRunFailed {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.failed';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `cancelling` status.
*/
interface ThreadRunCancelling {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.cancelling';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* is cancelled.
*/
interface ThreadRunCancelled {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.cancelled';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* expires.
*/
interface ThreadRunExpired {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.expired';
}
}
/**
* Occurs when a new
* [thread](https://platform.openai.com/docs/api-reference/threads/object) is
* created.
*/
export interface ThreadStreamEvent {
/**
* Represents a thread that contains
* [messages](https://platform.openai.com/docs/api-reference/messages).
*/
data: ThreadsAPI.Thread;
event: 'thread.created';
/**
* Whether to enable input audio transcription.
*/
enabled?: boolean;
}
export interface AssistantCreateParams {
/**
* ID of the model to use. You can use the
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to
* see all of your available models, or see our
* [Model overview](https://platform.openai.com/docs/models) for descriptions of
* them.
*/
model: (string & {}) | Shared.ChatModel;
/**
* The description of the assistant. The maximum length is 512 characters.
*/
description?: string | null;
/**
* The system instructions that the assistant uses. The maximum length is 256,000
* characters.
*/
instructions?: string | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* The name of the assistant. The maximum length is 256 characters.
*/
name?: string | null;
/**
* Constrains effort on reasoning for
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
* supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
* Reducing reasoning effort can result in faster responses and fewer tokens used
* on reasoning in a response.
*
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
* calls are supported for all reasoning values in gpt-5.1.
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
* support `none`.
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
* - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
*/
reasoning_effort?: Shared.ReasoningEffort | null;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
tool_resources?: AssistantCreateParams.ToolResources | null;
/**
* A list of tool enabled on the assistant. There can be a maximum of 128 tools per
* assistant. Tools can be of types `code_interpreter`, `file_search`, or
* `function`.
*/
tools?: Array<AssistantTool>;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the
* model considers the results of the tokens with top_p probability mass. So 0.1
* means only the tokens comprising the top 10% probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
}
export declare namespace AssistantCreateParams {
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this assistant. There can be a maximum of 1 vector store attached to
* the assistant.
*/
vector_store_ids?: Array<string>;
/**
* A helper to create a
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* with file_ids and attach it to this assistant. There can be a maximum of 1
* vector store attached to the assistant.
*/
vector_stores?: Array<FileSearch.VectorStore>;
}
namespace FileSearch {
interface VectorStore {
/**
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
* strategy.
*/
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
* add to the vector store. For vector stores created before Nov 2025, there can be
* a maximum of 10,000 files in a vector store. For vector stores created starting
* in Nov 2025, the limit is 100,000,000 files.
*/
file_ids?: Array<string>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace VectorStore {
/**
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
* `800` and `chunk_overlap_tokens` of `400`.
*/
interface Auto {
/**
* Always `auto`.
*/
type: 'auto';
}
interface Static {
static: Static.Static;
/**
* Always `static`.
*/
type: 'static';
}
namespace Static {
interface Static {
/**
* The number of tokens that overlap between chunks. The default value is `400`.
*
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
*/
chunk_overlap_tokens: number;
/**
* The maximum number of tokens in each chunk. The default value is `800`. The
* minimum value is `100` and the maximum value is `4096`.
*/
max_chunk_size_tokens: number;
}
}
}
}
}
}
export interface AssistantUpdateParams {
/**
* The description of the assistant. The maximum length is 512 characters.
*/
description?: string | null;
/**
* The system instructions that the assistant uses. The maximum length is 256,000
* characters.
*/
instructions?: string | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* ID of the model to use. You can use the
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to
* see all of your available models, or see our
* [Model overview](https://platform.openai.com/docs/models) for descriptions of
* them.
*/
model?: (string & {}) | 'gpt-5' | 'gpt-5-mini' | 'gpt-5-nano' | 'gpt-5-2025-08-07' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano-2025-08-07' | 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4.1-nano' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano-2025-04-14' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o1' | 'o1-2024-12-17' | 'gpt-4o' | 'gpt-4o-2024-11-20' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-05-13' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-0125-preview' | 'gpt-4-turbo-preview' | 'gpt-4-1106-preview' | 'gpt-4-vision-preview' | 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-16k' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-16k-0613';
/**
* The name of the assistant. The maximum length is 256 characters.
*/
name?: string | null;
/**
* Constrains effort on reasoning for
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
* supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
* Reducing reasoning effort can result in faster responses and fewer tokens used
* on reasoning in a response.
*
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
* calls are supported for all reasoning values in gpt-5.1.
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
* support `none`.
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
* - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
*/
reasoning_effort?: Shared.ReasoningEffort | null;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
tool_resources?: AssistantUpdateParams.ToolResources | null;
/**
* A list of tool enabled on the assistant. There can be a maximum of 128 tools per
* assistant. Tools can be of types `code_interpreter`, `file_search`, or
* `function`.
*/
tools?: Array<AssistantTool>;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the
* model considers the results of the tokens with top_p probability mass. So 0.1
* means only the tokens comprising the top 10% probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
}
export declare namespace AssistantUpdateParams {
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* Overrides the list of
* [file](https://platform.openai.com/docs/api-reference/files) IDs made available
* to the `code_interpreter` tool. There can be a maximum of 20 files associated
* with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* Overrides the
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this assistant. There can be a maximum of 1 vector store attached to
* the assistant.
*/
vector_store_ids?: Array<string>;
}
}
}
export interface AssistantListParams extends CursorPageParams {
/**
* A cursor for use in pagination. `before` is an object ID that defines your place
* in the list. For instance, if you make a list request and receive 100 objects,
* starting with obj_foo, your subsequent call can include before=obj_foo in order
* to fetch the previous page of the list.
*/
before?: string;
/**
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
* order and `desc` for descending order.
*/
order?: 'asc' | 'desc';
}
export declare namespace Assistants {
export { type Assistant as Assistant, type AssistantDeleted as AssistantDeleted, type AssistantStreamEvent as AssistantStreamEvent, type AssistantTool as AssistantTool, type CodeInterpreterTool as CodeInterpreterTool, type FileSearchTool as FileSearchTool, type FunctionTool as FunctionTool, type MessageStreamEvent as MessageStreamEvent, type RunStepStreamEvent as RunStepStreamEvent, type RunStreamEvent as RunStreamEvent, type ThreadStreamEvent as ThreadStreamEvent, type AssistantsPage as AssistantsPage, type AssistantCreateParams as AssistantCreateParams, type AssistantUpdateParams as AssistantUpdateParams, type AssistantListParams as AssistantListParams, };
export { AssistantStream };
}
//# sourceMappingURL=assistants.d.mts.map
File diff suppressed because one or more lines are too long
+1227
View File
@@ -0,0 +1,1227 @@
import { APIResource } from "../../core/resource.js";
import * as Shared from "../shared.js";
import * as MessagesAPI from "./threads/messages.js";
import * as ThreadsAPI from "./threads/threads.js";
import * as RunsAPI from "./threads/runs/runs.js";
import * as StepsAPI from "./threads/runs/steps.js";
import { APIPromise } from "../../core/api-promise.js";
import { CursorPage, type CursorPageParams, PagePromise } from "../../core/pagination.js";
import { RequestOptions } from "../../internal/request-options.js";
import { AssistantStream } from "../../lib/AssistantStream.js";
/**
* Build Assistants that can call models and use tools.
*/
export declare class Assistants extends APIResource {
/**
* Create an assistant with a model and instructions.
*
* @deprecated
*/
create(body: AssistantCreateParams, options?: RequestOptions): APIPromise<Assistant>;
/**
* Retrieves an assistant.
*
* @deprecated
*/
retrieve(assistantID: string, options?: RequestOptions): APIPromise<Assistant>;
/**
* Modifies an assistant.
*
* @deprecated
*/
update(assistantID: string, body: AssistantUpdateParams, options?: RequestOptions): APIPromise<Assistant>;
/**
* Returns a list of assistants.
*
* @deprecated
*/
list(query?: AssistantListParams | null | undefined, options?: RequestOptions): PagePromise<AssistantsPage, Assistant>;
/**
* Delete an assistant.
*
* @deprecated
*/
delete(assistantID: string, options?: RequestOptions): APIPromise<AssistantDeleted>;
}
export type AssistantsPage = CursorPage<Assistant>;
/**
* @deprecated Represents an `assistant` that can call the model and use tools.
*/
export interface Assistant {
/**
* The identifier, which can be referenced in API endpoints.
*/
id: string;
/**
* The Unix timestamp (in seconds) for when the assistant was created.
*/
created_at: number;
/**
* The description of the assistant. The maximum length is 512 characters.
*/
description: string | null;
/**
* The system instructions that the assistant uses. The maximum length is 256,000
* characters.
*/
instructions: string | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata: Shared.Metadata | null;
/**
* ID of the model to use. You can use the
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to
* see all of your available models, or see our
* [Model overview](https://platform.openai.com/docs/models) for descriptions of
* them.
*/
model: string;
/**
* The name of the assistant. The maximum length is 256 characters.
*/
name: string | null;
/**
* The object type, which is always `assistant`.
*/
object: 'assistant';
/**
* A list of tool enabled on the assistant. There can be a maximum of 128 tools per
* assistant. Tools can be of types `code_interpreter`, `file_search`, or
* `function`.
*/
tools: Array<AssistantTool>;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
tool_resources?: Assistant.ToolResources | null;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the
* model considers the results of the tokens with top_p probability mass. So 0.1
* means only the tokens comprising the top 10% probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
}
export declare namespace Assistant {
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter`` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The ID of the
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this assistant. There can be a maximum of 1 vector store attached to
* the assistant.
*/
vector_store_ids?: Array<string>;
}
}
}
export interface AssistantDeleted {
id: string;
deleted: boolean;
object: 'assistant.deleted';
}
/**
* Represents an event emitted when streaming a Run.
*
* Each event in a server-sent events stream has an `event` and `data` property:
*
* ```
* event: thread.created
* data: {"id": "thread_123", "object": "thread", ...}
* ```
*
* We emit events whenever a new object is created, transitions to a new state, or
* is being streamed in parts (deltas). For example, we emit `thread.run.created`
* when a new run is created, `thread.run.completed` when a run completes, and so
* on. When an Assistant chooses to create a message during a run, we emit a
* `thread.message.created event`, a `thread.message.in_progress` event, many
* `thread.message.delta` events, and finally a `thread.message.completed` event.
*
* We may add additional events over time, so we recommend handling unknown events
* gracefully in your code. See the
* [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview)
* to learn how to integrate the Assistants API with streaming.
*/
export type AssistantStreamEvent = AssistantStreamEvent.ThreadCreated | AssistantStreamEvent.ThreadRunCreated | AssistantStreamEvent.ThreadRunQueued | AssistantStreamEvent.ThreadRunInProgress | AssistantStreamEvent.ThreadRunRequiresAction | AssistantStreamEvent.ThreadRunCompleted | AssistantStreamEvent.ThreadRunIncomplete | AssistantStreamEvent.ThreadRunFailed | AssistantStreamEvent.ThreadRunCancelling | AssistantStreamEvent.ThreadRunCancelled | AssistantStreamEvent.ThreadRunExpired | AssistantStreamEvent.ThreadRunStepCreated | AssistantStreamEvent.ThreadRunStepInProgress | AssistantStreamEvent.ThreadRunStepDelta | AssistantStreamEvent.ThreadRunStepCompleted | AssistantStreamEvent.ThreadRunStepFailed | AssistantStreamEvent.ThreadRunStepCancelled | AssistantStreamEvent.ThreadRunStepExpired | AssistantStreamEvent.ThreadMessageCreated | AssistantStreamEvent.ThreadMessageInProgress | AssistantStreamEvent.ThreadMessageDelta | AssistantStreamEvent.ThreadMessageCompleted | AssistantStreamEvent.ThreadMessageIncomplete | AssistantStreamEvent.ErrorEvent;
export declare namespace AssistantStreamEvent {
/**
* Occurs when a new
* [thread](https://platform.openai.com/docs/api-reference/threads/object) is
* created.
*/
interface ThreadCreated {
/**
* Represents a thread that contains
* [messages](https://platform.openai.com/docs/api-reference/messages).
*/
data: ThreadsAPI.Thread;
event: 'thread.created';
/**
* Whether to enable input audio transcription.
*/
enabled?: boolean;
}
/**
* Occurs when a new
* [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
*/
interface ThreadRunCreated {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.created';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `queued` status.
*/
interface ThreadRunQueued {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.queued';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to an `in_progress` status.
*/
interface ThreadRunInProgress {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.in_progress';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `requires_action` status.
*/
interface ThreadRunRequiresAction {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.requires_action';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* is completed.
*/
interface ThreadRunCompleted {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.completed';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* ends with status `incomplete`.
*/
interface ThreadRunIncomplete {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.incomplete';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* fails.
*/
interface ThreadRunFailed {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.failed';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `cancelling` status.
*/
interface ThreadRunCancelling {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.cancelling';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* is cancelled.
*/
interface ThreadRunCancelled {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.cancelled';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* expires.
*/
interface ThreadRunExpired {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.expired';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is created.
*/
interface ThreadRunStepCreated {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.created';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* moves to an `in_progress` state.
*/
interface ThreadRunStepInProgress {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.in_progress';
}
/**
* Occurs when parts of a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* are being streamed.
*/
interface ThreadRunStepDelta {
/**
* Represents a run step delta i.e. any changed fields on a run step during
* streaming.
*/
data: StepsAPI.RunStepDeltaEvent;
event: 'thread.run.step.delta';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is completed.
*/
interface ThreadRunStepCompleted {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.completed';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* fails.
*/
interface ThreadRunStepFailed {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.failed';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is cancelled.
*/
interface ThreadRunStepCancelled {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.cancelled';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* expires.
*/
interface ThreadRunStepExpired {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.expired';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) is
* created.
*/
interface ThreadMessageCreated {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.created';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) moves
* to an `in_progress` state.
*/
interface ThreadMessageInProgress {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.in_progress';
}
/**
* Occurs when parts of a
* [Message](https://platform.openai.com/docs/api-reference/messages/object) are
* being streamed.
*/
interface ThreadMessageDelta {
/**
* Represents a message delta i.e. any changed fields on a message during
* streaming.
*/
data: MessagesAPI.MessageDeltaEvent;
event: 'thread.message.delta';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) is
* completed.
*/
interface ThreadMessageCompleted {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.completed';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) ends
* before it is completed.
*/
interface ThreadMessageIncomplete {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.incomplete';
}
/**
* Occurs when an
* [error](https://platform.openai.com/docs/guides/error-codes#api-errors) occurs.
* This can happen due to an internal server error or a timeout.
*/
interface ErrorEvent {
data: Shared.ErrorObject;
event: 'error';
}
}
export type AssistantTool = CodeInterpreterTool | FileSearchTool | FunctionTool;
export interface CodeInterpreterTool {
/**
* The type of tool being defined: `code_interpreter`
*/
type: 'code_interpreter';
}
export interface FileSearchTool {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
/**
* Overrides for the file search tool.
*/
file_search?: FileSearchTool.FileSearch;
}
export declare namespace FileSearchTool {
/**
* Overrides for the file search tool.
*/
interface FileSearch {
/**
* The maximum number of results the file search tool should output. The default is
* 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
* 1 and 50 inclusive.
*
* Note that the file search tool may output fewer than `max_num_results` results.
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
max_num_results?: number;
/**
* The ranking options for the file search. If not specified, the file search tool
* will use the `auto` ranker and a score_threshold of 0.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
ranking_options?: FileSearch.RankingOptions;
}
namespace FileSearch {
/**
* The ranking options for the file search. If not specified, the file search tool
* will use the `auto` ranker and a score_threshold of 0.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
interface RankingOptions {
/**
* The score threshold for the file search. All values must be a floating point
* number between 0 and 1.
*/
score_threshold: number;
/**
* The ranker to use for the file search. If not specified will use the `auto`
* ranker.
*/
ranker?: 'auto' | 'default_2024_08_21';
}
}
}
export interface FunctionTool {
function: Shared.FunctionDefinition;
/**
* The type of tool being defined: `function`
*/
type: 'function';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) is
* created.
*/
export type MessageStreamEvent = MessageStreamEvent.ThreadMessageCreated | MessageStreamEvent.ThreadMessageInProgress | MessageStreamEvent.ThreadMessageDelta | MessageStreamEvent.ThreadMessageCompleted | MessageStreamEvent.ThreadMessageIncomplete;
export declare namespace MessageStreamEvent {
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) is
* created.
*/
interface ThreadMessageCreated {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.created';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) moves
* to an `in_progress` state.
*/
interface ThreadMessageInProgress {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.in_progress';
}
/**
* Occurs when parts of a
* [Message](https://platform.openai.com/docs/api-reference/messages/object) are
* being streamed.
*/
interface ThreadMessageDelta {
/**
* Represents a message delta i.e. any changed fields on a message during
* streaming.
*/
data: MessagesAPI.MessageDeltaEvent;
event: 'thread.message.delta';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) is
* completed.
*/
interface ThreadMessageCompleted {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.completed';
}
/**
* Occurs when a
* [message](https://platform.openai.com/docs/api-reference/messages/object) ends
* before it is completed.
*/
interface ThreadMessageIncomplete {
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: MessagesAPI.Message;
event: 'thread.message.incomplete';
}
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is created.
*/
export type RunStepStreamEvent = RunStepStreamEvent.ThreadRunStepCreated | RunStepStreamEvent.ThreadRunStepInProgress | RunStepStreamEvent.ThreadRunStepDelta | RunStepStreamEvent.ThreadRunStepCompleted | RunStepStreamEvent.ThreadRunStepFailed | RunStepStreamEvent.ThreadRunStepCancelled | RunStepStreamEvent.ThreadRunStepExpired;
export declare namespace RunStepStreamEvent {
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is created.
*/
interface ThreadRunStepCreated {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.created';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* moves to an `in_progress` state.
*/
interface ThreadRunStepInProgress {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.in_progress';
}
/**
* Occurs when parts of a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* are being streamed.
*/
interface ThreadRunStepDelta {
/**
* Represents a run step delta i.e. any changed fields on a run step during
* streaming.
*/
data: StepsAPI.RunStepDeltaEvent;
event: 'thread.run.step.delta';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is completed.
*/
interface ThreadRunStepCompleted {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.completed';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* fails.
*/
interface ThreadRunStepFailed {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.failed';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* is cancelled.
*/
interface ThreadRunStepCancelled {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.cancelled';
}
/**
* Occurs when a
* [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
* expires.
*/
interface ThreadRunStepExpired {
/**
* Represents a step in execution of a run.
*/
data: StepsAPI.RunStep;
event: 'thread.run.step.expired';
}
}
/**
* Occurs when a new
* [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
*/
export type RunStreamEvent = RunStreamEvent.ThreadRunCreated | RunStreamEvent.ThreadRunQueued | RunStreamEvent.ThreadRunInProgress | RunStreamEvent.ThreadRunRequiresAction | RunStreamEvent.ThreadRunCompleted | RunStreamEvent.ThreadRunIncomplete | RunStreamEvent.ThreadRunFailed | RunStreamEvent.ThreadRunCancelling | RunStreamEvent.ThreadRunCancelled | RunStreamEvent.ThreadRunExpired;
export declare namespace RunStreamEvent {
/**
* Occurs when a new
* [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
*/
interface ThreadRunCreated {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.created';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `queued` status.
*/
interface ThreadRunQueued {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.queued';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to an `in_progress` status.
*/
interface ThreadRunInProgress {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.in_progress';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `requires_action` status.
*/
interface ThreadRunRequiresAction {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.requires_action';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* is completed.
*/
interface ThreadRunCompleted {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.completed';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* ends with status `incomplete`.
*/
interface ThreadRunIncomplete {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.incomplete';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* fails.
*/
interface ThreadRunFailed {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.failed';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* moves to a `cancelling` status.
*/
interface ThreadRunCancelling {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.cancelling';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* is cancelled.
*/
interface ThreadRunCancelled {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.cancelled';
}
/**
* Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
* expires.
*/
interface ThreadRunExpired {
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
data: RunsAPI.Run;
event: 'thread.run.expired';
}
}
/**
* Occurs when a new
* [thread](https://platform.openai.com/docs/api-reference/threads/object) is
* created.
*/
export interface ThreadStreamEvent {
/**
* Represents a thread that contains
* [messages](https://platform.openai.com/docs/api-reference/messages).
*/
data: ThreadsAPI.Thread;
event: 'thread.created';
/**
* Whether to enable input audio transcription.
*/
enabled?: boolean;
}
export interface AssistantCreateParams {
/**
* ID of the model to use. You can use the
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to
* see all of your available models, or see our
* [Model overview](https://platform.openai.com/docs/models) for descriptions of
* them.
*/
model: (string & {}) | Shared.ChatModel;
/**
* The description of the assistant. The maximum length is 512 characters.
*/
description?: string | null;
/**
* The system instructions that the assistant uses. The maximum length is 256,000
* characters.
*/
instructions?: string | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* The name of the assistant. The maximum length is 256 characters.
*/
name?: string | null;
/**
* Constrains effort on reasoning for
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
* supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
* Reducing reasoning effort can result in faster responses and fewer tokens used
* on reasoning in a response.
*
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
* calls are supported for all reasoning values in gpt-5.1.
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
* support `none`.
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
* - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
*/
reasoning_effort?: Shared.ReasoningEffort | null;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
tool_resources?: AssistantCreateParams.ToolResources | null;
/**
* A list of tool enabled on the assistant. There can be a maximum of 128 tools per
* assistant. Tools can be of types `code_interpreter`, `file_search`, or
* `function`.
*/
tools?: Array<AssistantTool>;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the
* model considers the results of the tokens with top_p probability mass. So 0.1
* means only the tokens comprising the top 10% probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
}
export declare namespace AssistantCreateParams {
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this assistant. There can be a maximum of 1 vector store attached to
* the assistant.
*/
vector_store_ids?: Array<string>;
/**
* A helper to create a
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* with file_ids and attach it to this assistant. There can be a maximum of 1
* vector store attached to the assistant.
*/
vector_stores?: Array<FileSearch.VectorStore>;
}
namespace FileSearch {
interface VectorStore {
/**
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
* strategy.
*/
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
* add to the vector store. For vector stores created before Nov 2025, there can be
* a maximum of 10,000 files in a vector store. For vector stores created starting
* in Nov 2025, the limit is 100,000,000 files.
*/
file_ids?: Array<string>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace VectorStore {
/**
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
* `800` and `chunk_overlap_tokens` of `400`.
*/
interface Auto {
/**
* Always `auto`.
*/
type: 'auto';
}
interface Static {
static: Static.Static;
/**
* Always `static`.
*/
type: 'static';
}
namespace Static {
interface Static {
/**
* The number of tokens that overlap between chunks. The default value is `400`.
*
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
*/
chunk_overlap_tokens: number;
/**
* The maximum number of tokens in each chunk. The default value is `800`. The
* minimum value is `100` and the maximum value is `4096`.
*/
max_chunk_size_tokens: number;
}
}
}
}
}
}
export interface AssistantUpdateParams {
/**
* The description of the assistant. The maximum length is 512 characters.
*/
description?: string | null;
/**
* The system instructions that the assistant uses. The maximum length is 256,000
* characters.
*/
instructions?: string | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* ID of the model to use. You can use the
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to
* see all of your available models, or see our
* [Model overview](https://platform.openai.com/docs/models) for descriptions of
* them.
*/
model?: (string & {}) | 'gpt-5' | 'gpt-5-mini' | 'gpt-5-nano' | 'gpt-5-2025-08-07' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano-2025-08-07' | 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4.1-nano' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano-2025-04-14' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o1' | 'o1-2024-12-17' | 'gpt-4o' | 'gpt-4o-2024-11-20' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-05-13' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-0125-preview' | 'gpt-4-turbo-preview' | 'gpt-4-1106-preview' | 'gpt-4-vision-preview' | 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-16k' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-16k-0613';
/**
* The name of the assistant. The maximum length is 256 characters.
*/
name?: string | null;
/**
* Constrains effort on reasoning for
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
* supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
* Reducing reasoning effort can result in faster responses and fewer tokens used
* on reasoning in a response.
*
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
* calls are supported for all reasoning values in gpt-5.1.
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
* support `none`.
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
* - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
*/
reasoning_effort?: Shared.ReasoningEffort | null;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
tool_resources?: AssistantUpdateParams.ToolResources | null;
/**
* A list of tool enabled on the assistant. There can be a maximum of 128 tools per
* assistant. Tools can be of types `code_interpreter`, `file_search`, or
* `function`.
*/
tools?: Array<AssistantTool>;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the
* model considers the results of the tokens with top_p probability mass. So 0.1
* means only the tokens comprising the top 10% probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
}
export declare namespace AssistantUpdateParams {
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* Overrides the list of
* [file](https://platform.openai.com/docs/api-reference/files) IDs made available
* to the `code_interpreter` tool. There can be a maximum of 20 files associated
* with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* Overrides the
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this assistant. There can be a maximum of 1 vector store attached to
* the assistant.
*/
vector_store_ids?: Array<string>;
}
}
}
export interface AssistantListParams extends CursorPageParams {
/**
* A cursor for use in pagination. `before` is an object ID that defines your place
* in the list. For instance, if you make a list request and receive 100 objects,
* starting with obj_foo, your subsequent call can include before=obj_foo in order
* to fetch the previous page of the list.
*/
before?: string;
/**
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
* order and `desc` for descending order.
*/
order?: 'asc' | 'desc';
}
export declare namespace Assistants {
export { type Assistant as Assistant, type AssistantDeleted as AssistantDeleted, type AssistantStreamEvent as AssistantStreamEvent, type AssistantTool as AssistantTool, type CodeInterpreterTool as CodeInterpreterTool, type FileSearchTool as FileSearchTool, type FunctionTool as FunctionTool, type MessageStreamEvent as MessageStreamEvent, type RunStepStreamEvent as RunStepStreamEvent, type RunStreamEvent as RunStreamEvent, type ThreadStreamEvent as ThreadStreamEvent, type AssistantsPage as AssistantsPage, type AssistantCreateParams as AssistantCreateParams, type AssistantUpdateParams as AssistantUpdateParams, type AssistantListParams as AssistantListParams, };
export { AssistantStream };
}
//# sourceMappingURL=assistants.d.ts.map
File diff suppressed because one or more lines are too long
+78
View File
@@ -0,0 +1,78 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Assistants = void 0;
const resource_1 = require("../../core/resource.js");
const pagination_1 = require("../../core/pagination.js");
const headers_1 = require("../../internal/headers.js");
const path_1 = require("../../internal/utils/path.js");
/**
* Build Assistants that can call models and use tools.
*/
class Assistants extends resource_1.APIResource {
/**
* Create an assistant with a model and instructions.
*
* @deprecated
*/
create(body, options) {
return this._client.post('/assistants', {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Retrieves an assistant.
*
* @deprecated
*/
retrieve(assistantID, options) {
return this._client.get((0, path_1.path) `/assistants/${assistantID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Modifies an assistant.
*
* @deprecated
*/
update(assistantID, body, options) {
return this._client.post((0, path_1.path) `/assistants/${assistantID}`, {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Returns a list of assistants.
*
* @deprecated
*/
list(query = {}, options) {
return this._client.getAPIList('/assistants', (pagination_1.CursorPage), {
query,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Delete an assistant.
*
* @deprecated
*/
delete(assistantID, options) {
return this._client.delete((0, path_1.path) `/assistants/${assistantID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
exports.Assistants = Assistants;
//# sourceMappingURL=assistants.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"assistants.js","sourceRoot":"","sources":["../../src/resources/beta/assistants.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;AAOlD,yDAAuF;AACvF,uDAAsD;AAEtD,uDAAiD;AAGjD;;GAEG;AACH,MAAa,UAAW,SAAQ,sBAAW;IACzC;;;;OAIG;IACH,MAAM,CAAC,IAA2B,EAAE,OAAwB;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;YACtC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,WAAmB,EAAE,OAAwB;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,eAAe,WAAW,EAAE,EAAE;YACxD,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAmB,EAAE,IAA2B,EAAE,OAAwB;QAC/E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,eAAe,WAAW,EAAE,EAAE;YACzD,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,IAAI,CACF,QAAgD,EAAE,EAClD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,EAAE,CAAA,uBAAqB,CAAA,EAAE;YACnE,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAmB,EAAE,OAAwB;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAA,WAAI,EAAA,eAAe,WAAW,EAAE,EAAE;YAC3D,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AAvED,gCAuEC"}
+74
View File
@@ -0,0 +1,74 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { CursorPage } from "../../core/pagination.mjs";
import { buildHeaders } from "../../internal/headers.mjs";
import { path } from "../../internal/utils/path.mjs";
/**
* Build Assistants that can call models and use tools.
*/
export class Assistants extends APIResource {
/**
* Create an assistant with a model and instructions.
*
* @deprecated
*/
create(body, options) {
return this._client.post('/assistants', {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Retrieves an assistant.
*
* @deprecated
*/
retrieve(assistantID, options) {
return this._client.get(path `/assistants/${assistantID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Modifies an assistant.
*
* @deprecated
*/
update(assistantID, body, options) {
return this._client.post(path `/assistants/${assistantID}`, {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Returns a list of assistants.
*
* @deprecated
*/
list(query = {}, options) {
return this._client.getAPIList('/assistants', (CursorPage), {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Delete an assistant.
*
* @deprecated
*/
delete(assistantID, options) {
return this._client.delete(path `/assistants/${assistantID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
//# sourceMappingURL=assistants.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"assistants.mjs","sourceRoot":"","sources":["../../src/resources/beta/assistants.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAOlD,OAAO,EAAE,UAAU,EAAsC,kCAA8B;AACvF,OAAO,EAAE,YAAY,EAAE,mCAA+B;AAEtD,OAAO,EAAE,IAAI,EAAE,sCAAkC;AAGjD;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IACzC;;;;OAIG;IACH,MAAM,CAAC,IAA2B,EAAE,OAAwB;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;YACtC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,WAAmB,EAAE,OAAwB;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,eAAe,WAAW,EAAE,EAAE;YACxD,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAmB,EAAE,IAA2B,EAAE,OAAwB;QAC/E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,eAAe,WAAW,EAAE,EAAE;YACzD,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,IAAI,CACF,QAAgD,EAAE,EAClD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,EAAE,CAAA,UAAqB,CAAA,EAAE;YACnE,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAmB,EAAE,OAAwB;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,eAAe,WAAW,EAAE,EAAE;YAC3D,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
+21
View File
@@ -0,0 +1,21 @@
import { APIResource } from "../../core/resource.mjs";
import * as AssistantsAPI from "./assistants.mjs";
import { Assistant, AssistantCreateParams, AssistantDeleted, AssistantListParams, AssistantStreamEvent, AssistantTool, AssistantUpdateParams, Assistants, AssistantsPage, CodeInterpreterTool, FileSearchTool, FunctionTool, MessageStreamEvent, RunStepStreamEvent, RunStreamEvent, ThreadStreamEvent } from "./assistants.mjs";
import * as RealtimeAPI from "./realtime/realtime.mjs";
import { ConversationCreatedEvent, ConversationItem, ConversationItemContent, ConversationItemCreateEvent, ConversationItemCreatedEvent, ConversationItemDeleteEvent, ConversationItemDeletedEvent, ConversationItemInputAudioTranscriptionCompletedEvent, ConversationItemInputAudioTranscriptionDeltaEvent, ConversationItemInputAudioTranscriptionFailedEvent, ConversationItemRetrieveEvent, ConversationItemTruncateEvent, ConversationItemTruncatedEvent, ConversationItemWithReference, ErrorEvent, InputAudioBufferAppendEvent, InputAudioBufferClearEvent, InputAudioBufferClearedEvent, InputAudioBufferCommitEvent, InputAudioBufferCommittedEvent, InputAudioBufferSpeechStartedEvent, InputAudioBufferSpeechStoppedEvent, RateLimitsUpdatedEvent, Realtime, RealtimeClientEvent, RealtimeResponse, RealtimeResponseStatus, RealtimeResponseUsage, RealtimeServerEvent, ResponseAudioDeltaEvent, ResponseAudioDoneEvent, ResponseAudioTranscriptDeltaEvent, ResponseAudioTranscriptDoneEvent, ResponseCancelEvent, ResponseContentPartAddedEvent, ResponseContentPartDoneEvent, ResponseCreateEvent, ResponseCreatedEvent, ResponseDoneEvent, ResponseFunctionCallArgumentsDeltaEvent, ResponseFunctionCallArgumentsDoneEvent, ResponseOutputItemAddedEvent, ResponseOutputItemDoneEvent, ResponseTextDeltaEvent, ResponseTextDoneEvent, SessionCreatedEvent, SessionUpdateEvent, SessionUpdatedEvent, TranscriptionSessionUpdate, TranscriptionSessionUpdatedEvent } from "./realtime/realtime.mjs";
import * as ChatKitAPI from "./chatkit/chatkit.mjs";
import { ChatKit, ChatKitWorkflow } from "./chatkit/chatkit.mjs";
import * as ThreadsAPI from "./threads/threads.mjs";
import { AssistantResponseFormatOption, AssistantToolChoice, AssistantToolChoiceFunction, AssistantToolChoiceOption, Thread, ThreadCreateAndRunParams, ThreadCreateAndRunParamsNonStreaming, ThreadCreateAndRunParamsStreaming, ThreadCreateAndRunPollParams, ThreadCreateAndRunStreamParams, ThreadCreateParams, ThreadDeleted, ThreadUpdateParams, Threads } from "./threads/threads.mjs";
export declare class Beta extends APIResource {
realtime: RealtimeAPI.Realtime;
chatkit: ChatKitAPI.ChatKit;
assistants: AssistantsAPI.Assistants;
threads: ThreadsAPI.Threads;
}
export declare namespace Beta {
export { Realtime as Realtime, type ConversationCreatedEvent as ConversationCreatedEvent, type ConversationItem as ConversationItem, type ConversationItemContent as ConversationItemContent, type ConversationItemCreateEvent as ConversationItemCreateEvent, type ConversationItemCreatedEvent as ConversationItemCreatedEvent, type ConversationItemDeleteEvent as ConversationItemDeleteEvent, type ConversationItemDeletedEvent as ConversationItemDeletedEvent, type ConversationItemInputAudioTranscriptionCompletedEvent as ConversationItemInputAudioTranscriptionCompletedEvent, type ConversationItemInputAudioTranscriptionDeltaEvent as ConversationItemInputAudioTranscriptionDeltaEvent, type ConversationItemInputAudioTranscriptionFailedEvent as ConversationItemInputAudioTranscriptionFailedEvent, type ConversationItemRetrieveEvent as ConversationItemRetrieveEvent, type ConversationItemTruncateEvent as ConversationItemTruncateEvent, type ConversationItemTruncatedEvent as ConversationItemTruncatedEvent, type ConversationItemWithReference as ConversationItemWithReference, type ErrorEvent as ErrorEvent, type InputAudioBufferAppendEvent as InputAudioBufferAppendEvent, type InputAudioBufferClearEvent as InputAudioBufferClearEvent, type InputAudioBufferClearedEvent as InputAudioBufferClearedEvent, type InputAudioBufferCommitEvent as InputAudioBufferCommitEvent, type InputAudioBufferCommittedEvent as InputAudioBufferCommittedEvent, type InputAudioBufferSpeechStartedEvent as InputAudioBufferSpeechStartedEvent, type InputAudioBufferSpeechStoppedEvent as InputAudioBufferSpeechStoppedEvent, type RateLimitsUpdatedEvent as RateLimitsUpdatedEvent, type RealtimeClientEvent as RealtimeClientEvent, type RealtimeResponse as RealtimeResponse, type RealtimeResponseStatus as RealtimeResponseStatus, type RealtimeResponseUsage as RealtimeResponseUsage, type RealtimeServerEvent as RealtimeServerEvent, type ResponseAudioDeltaEvent as ResponseAudioDeltaEvent, type ResponseAudioDoneEvent as ResponseAudioDoneEvent, type ResponseAudioTranscriptDeltaEvent as ResponseAudioTranscriptDeltaEvent, type ResponseAudioTranscriptDoneEvent as ResponseAudioTranscriptDoneEvent, type ResponseCancelEvent as ResponseCancelEvent, type ResponseContentPartAddedEvent as ResponseContentPartAddedEvent, type ResponseContentPartDoneEvent as ResponseContentPartDoneEvent, type ResponseCreateEvent as ResponseCreateEvent, type ResponseCreatedEvent as ResponseCreatedEvent, type ResponseDoneEvent as ResponseDoneEvent, type ResponseFunctionCallArgumentsDeltaEvent as ResponseFunctionCallArgumentsDeltaEvent, type ResponseFunctionCallArgumentsDoneEvent as ResponseFunctionCallArgumentsDoneEvent, type ResponseOutputItemAddedEvent as ResponseOutputItemAddedEvent, type ResponseOutputItemDoneEvent as ResponseOutputItemDoneEvent, type ResponseTextDeltaEvent as ResponseTextDeltaEvent, type ResponseTextDoneEvent as ResponseTextDoneEvent, type SessionCreatedEvent as SessionCreatedEvent, type SessionUpdateEvent as SessionUpdateEvent, type SessionUpdatedEvent as SessionUpdatedEvent, type TranscriptionSessionUpdate as TranscriptionSessionUpdate, type TranscriptionSessionUpdatedEvent as TranscriptionSessionUpdatedEvent, ChatKit as ChatKit, type ChatKitWorkflow as ChatKitWorkflow, };
export { Assistants as Assistants, type Assistant as Assistant, type AssistantDeleted as AssistantDeleted, type AssistantStreamEvent as AssistantStreamEvent, type AssistantTool as AssistantTool, type CodeInterpreterTool as CodeInterpreterTool, type FileSearchTool as FileSearchTool, type FunctionTool as FunctionTool, type MessageStreamEvent as MessageStreamEvent, type RunStepStreamEvent as RunStepStreamEvent, type RunStreamEvent as RunStreamEvent, type ThreadStreamEvent as ThreadStreamEvent, type AssistantsPage as AssistantsPage, type AssistantCreateParams as AssistantCreateParams, type AssistantUpdateParams as AssistantUpdateParams, type AssistantListParams as AssistantListParams, };
export { Threads as Threads, type AssistantResponseFormatOption as AssistantResponseFormatOption, type AssistantToolChoice as AssistantToolChoice, type AssistantToolChoiceFunction as AssistantToolChoiceFunction, type AssistantToolChoiceOption as AssistantToolChoiceOption, type Thread as Thread, type ThreadDeleted as ThreadDeleted, type ThreadCreateParams as ThreadCreateParams, type ThreadUpdateParams as ThreadUpdateParams, type ThreadCreateAndRunParams as ThreadCreateAndRunParams, type ThreadCreateAndRunParamsNonStreaming as ThreadCreateAndRunParamsNonStreaming, type ThreadCreateAndRunParamsStreaming as ThreadCreateAndRunParamsStreaming, type ThreadCreateAndRunPollParams, type ThreadCreateAndRunStreamParams, };
}
//# sourceMappingURL=beta.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"beta.d.mts","sourceRoot":"","sources":["../../src/resources/beta/beta.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAClD,OAAO,KAAK,aAAa,yBAAqB;AAC9C,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EAClB,yBAAqB;AACtB,OAAO,KAAK,WAAW,gCAA4B;AACnD,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,EAC3B,4BAA4B,EAC5B,qDAAqD,EACrD,iDAAiD,EACjD,kDAAkD,EAClD,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,6BAA6B,EAC7B,UAAU,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,8BAA8B,EAC9B,kCAAkC,EAClC,kCAAkC,EAClC,sBAAsB,EACtB,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,iCAAiC,EACjC,gCAAgC,EAChC,mBAAmB,EACnB,6BAA6B,EAC7B,4BAA4B,EAC5B,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,uCAAuC,EACvC,sCAAsC,EACtC,4BAA4B,EAC5B,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,EAC1B,gCAAgC,EACjC,gCAA4B;AAC7B,OAAO,KAAK,UAAU,8BAA0B;AAChD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,8BAA0B;AAC7D,OAAO,KAAK,UAAU,8BAA0B;AAChD,OAAO,EACL,6BAA6B,EAC7B,mBAAmB,EACnB,2BAA2B,EAC3B,yBAAyB,EACzB,MAAM,EACN,wBAAwB,EACxB,oCAAoC,EACpC,iCAAiC,EACjC,4BAA4B,EAC5B,8BAA8B,EAC9B,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,OAAO,EACR,8BAA0B;AAE3B,qBAAa,IAAK,SAAQ,WAAW;IACnC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAA0C;IACxE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAwC;IACnE,UAAU,EAAE,aAAa,CAAC,UAAU,CAA8C;IAClF,OAAO,EAAE,UAAU,CAAC,OAAO,CAAwC;CACpE;AAOD,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,OAAO,EACL,QAAQ,IAAI,QAAQ,EACpB,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,qDAAqD,IAAI,qDAAqD,EACnH,KAAK,iDAAiD,IAAI,iDAAiD,EAC3G,KAAK,kDAAkD,IAAI,kDAAkD,EAC7G,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,8BAA8B,IAAI,8BAA8B,EACrE,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,UAAU,IAAI,UAAU,EAC7B,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,8BAA8B,IAAI,8BAA8B,EACrE,KAAK,kCAAkC,IAAI,kCAAkC,EAC7E,KAAK,kCAAkC,IAAI,kCAAkC,EAC7E,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,gCAAgC,IAAI,gCAAgC,EACzE,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,uCAAuC,IAAI,uCAAuC,EACvF,KAAK,sCAAsC,IAAI,sCAAsC,EACrF,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,gCAAgC,IAAI,gCAAgC,EACzE,OAAO,IAAI,OAAO,EAClB,KAAK,eAAe,IAAI,eAAe,GACxC,CAAC;IAEF,OAAO,EACL,UAAU,IAAI,UAAU,EACxB,KAAK,SAAS,IAAI,SAAS,EAC3B,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,YAAY,IAAI,YAAY,EACjC,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,mBAAmB,IAAI,mBAAmB,GAChD,CAAC;IAEF,OAAO,EACL,OAAO,IAAI,OAAO,EAClB,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,MAAM,IAAI,MAAM,EACrB,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,oCAAoC,IAAI,oCAAoC,EACjF,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,GACpC,CAAC;CACH"}
+21
View File
@@ -0,0 +1,21 @@
import { APIResource } from "../../core/resource.js";
import * as AssistantsAPI from "./assistants.js";
import { Assistant, AssistantCreateParams, AssistantDeleted, AssistantListParams, AssistantStreamEvent, AssistantTool, AssistantUpdateParams, Assistants, AssistantsPage, CodeInterpreterTool, FileSearchTool, FunctionTool, MessageStreamEvent, RunStepStreamEvent, RunStreamEvent, ThreadStreamEvent } from "./assistants.js";
import * as RealtimeAPI from "./realtime/realtime.js";
import { ConversationCreatedEvent, ConversationItem, ConversationItemContent, ConversationItemCreateEvent, ConversationItemCreatedEvent, ConversationItemDeleteEvent, ConversationItemDeletedEvent, ConversationItemInputAudioTranscriptionCompletedEvent, ConversationItemInputAudioTranscriptionDeltaEvent, ConversationItemInputAudioTranscriptionFailedEvent, ConversationItemRetrieveEvent, ConversationItemTruncateEvent, ConversationItemTruncatedEvent, ConversationItemWithReference, ErrorEvent, InputAudioBufferAppendEvent, InputAudioBufferClearEvent, InputAudioBufferClearedEvent, InputAudioBufferCommitEvent, InputAudioBufferCommittedEvent, InputAudioBufferSpeechStartedEvent, InputAudioBufferSpeechStoppedEvent, RateLimitsUpdatedEvent, Realtime, RealtimeClientEvent, RealtimeResponse, RealtimeResponseStatus, RealtimeResponseUsage, RealtimeServerEvent, ResponseAudioDeltaEvent, ResponseAudioDoneEvent, ResponseAudioTranscriptDeltaEvent, ResponseAudioTranscriptDoneEvent, ResponseCancelEvent, ResponseContentPartAddedEvent, ResponseContentPartDoneEvent, ResponseCreateEvent, ResponseCreatedEvent, ResponseDoneEvent, ResponseFunctionCallArgumentsDeltaEvent, ResponseFunctionCallArgumentsDoneEvent, ResponseOutputItemAddedEvent, ResponseOutputItemDoneEvent, ResponseTextDeltaEvent, ResponseTextDoneEvent, SessionCreatedEvent, SessionUpdateEvent, SessionUpdatedEvent, TranscriptionSessionUpdate, TranscriptionSessionUpdatedEvent } from "./realtime/realtime.js";
import * as ChatKitAPI from "./chatkit/chatkit.js";
import { ChatKit, ChatKitWorkflow } from "./chatkit/chatkit.js";
import * as ThreadsAPI from "./threads/threads.js";
import { AssistantResponseFormatOption, AssistantToolChoice, AssistantToolChoiceFunction, AssistantToolChoiceOption, Thread, ThreadCreateAndRunParams, ThreadCreateAndRunParamsNonStreaming, ThreadCreateAndRunParamsStreaming, ThreadCreateAndRunPollParams, ThreadCreateAndRunStreamParams, ThreadCreateParams, ThreadDeleted, ThreadUpdateParams, Threads } from "./threads/threads.js";
export declare class Beta extends APIResource {
realtime: RealtimeAPI.Realtime;
chatkit: ChatKitAPI.ChatKit;
assistants: AssistantsAPI.Assistants;
threads: ThreadsAPI.Threads;
}
export declare namespace Beta {
export { Realtime as Realtime, type ConversationCreatedEvent as ConversationCreatedEvent, type ConversationItem as ConversationItem, type ConversationItemContent as ConversationItemContent, type ConversationItemCreateEvent as ConversationItemCreateEvent, type ConversationItemCreatedEvent as ConversationItemCreatedEvent, type ConversationItemDeleteEvent as ConversationItemDeleteEvent, type ConversationItemDeletedEvent as ConversationItemDeletedEvent, type ConversationItemInputAudioTranscriptionCompletedEvent as ConversationItemInputAudioTranscriptionCompletedEvent, type ConversationItemInputAudioTranscriptionDeltaEvent as ConversationItemInputAudioTranscriptionDeltaEvent, type ConversationItemInputAudioTranscriptionFailedEvent as ConversationItemInputAudioTranscriptionFailedEvent, type ConversationItemRetrieveEvent as ConversationItemRetrieveEvent, type ConversationItemTruncateEvent as ConversationItemTruncateEvent, type ConversationItemTruncatedEvent as ConversationItemTruncatedEvent, type ConversationItemWithReference as ConversationItemWithReference, type ErrorEvent as ErrorEvent, type InputAudioBufferAppendEvent as InputAudioBufferAppendEvent, type InputAudioBufferClearEvent as InputAudioBufferClearEvent, type InputAudioBufferClearedEvent as InputAudioBufferClearedEvent, type InputAudioBufferCommitEvent as InputAudioBufferCommitEvent, type InputAudioBufferCommittedEvent as InputAudioBufferCommittedEvent, type InputAudioBufferSpeechStartedEvent as InputAudioBufferSpeechStartedEvent, type InputAudioBufferSpeechStoppedEvent as InputAudioBufferSpeechStoppedEvent, type RateLimitsUpdatedEvent as RateLimitsUpdatedEvent, type RealtimeClientEvent as RealtimeClientEvent, type RealtimeResponse as RealtimeResponse, type RealtimeResponseStatus as RealtimeResponseStatus, type RealtimeResponseUsage as RealtimeResponseUsage, type RealtimeServerEvent as RealtimeServerEvent, type ResponseAudioDeltaEvent as ResponseAudioDeltaEvent, type ResponseAudioDoneEvent as ResponseAudioDoneEvent, type ResponseAudioTranscriptDeltaEvent as ResponseAudioTranscriptDeltaEvent, type ResponseAudioTranscriptDoneEvent as ResponseAudioTranscriptDoneEvent, type ResponseCancelEvent as ResponseCancelEvent, type ResponseContentPartAddedEvent as ResponseContentPartAddedEvent, type ResponseContentPartDoneEvent as ResponseContentPartDoneEvent, type ResponseCreateEvent as ResponseCreateEvent, type ResponseCreatedEvent as ResponseCreatedEvent, type ResponseDoneEvent as ResponseDoneEvent, type ResponseFunctionCallArgumentsDeltaEvent as ResponseFunctionCallArgumentsDeltaEvent, type ResponseFunctionCallArgumentsDoneEvent as ResponseFunctionCallArgumentsDoneEvent, type ResponseOutputItemAddedEvent as ResponseOutputItemAddedEvent, type ResponseOutputItemDoneEvent as ResponseOutputItemDoneEvent, type ResponseTextDeltaEvent as ResponseTextDeltaEvent, type ResponseTextDoneEvent as ResponseTextDoneEvent, type SessionCreatedEvent as SessionCreatedEvent, type SessionUpdateEvent as SessionUpdateEvent, type SessionUpdatedEvent as SessionUpdatedEvent, type TranscriptionSessionUpdate as TranscriptionSessionUpdate, type TranscriptionSessionUpdatedEvent as TranscriptionSessionUpdatedEvent, ChatKit as ChatKit, type ChatKitWorkflow as ChatKitWorkflow, };
export { Assistants as Assistants, type Assistant as Assistant, type AssistantDeleted as AssistantDeleted, type AssistantStreamEvent as AssistantStreamEvent, type AssistantTool as AssistantTool, type CodeInterpreterTool as CodeInterpreterTool, type FileSearchTool as FileSearchTool, type FunctionTool as FunctionTool, type MessageStreamEvent as MessageStreamEvent, type RunStepStreamEvent as RunStepStreamEvent, type RunStreamEvent as RunStreamEvent, type ThreadStreamEvent as ThreadStreamEvent, type AssistantsPage as AssistantsPage, type AssistantCreateParams as AssistantCreateParams, type AssistantUpdateParams as AssistantUpdateParams, type AssistantListParams as AssistantListParams, };
export { Threads as Threads, type AssistantResponseFormatOption as AssistantResponseFormatOption, type AssistantToolChoice as AssistantToolChoice, type AssistantToolChoiceFunction as AssistantToolChoiceFunction, type AssistantToolChoiceOption as AssistantToolChoiceOption, type Thread as Thread, type ThreadDeleted as ThreadDeleted, type ThreadCreateParams as ThreadCreateParams, type ThreadUpdateParams as ThreadUpdateParams, type ThreadCreateAndRunParams as ThreadCreateAndRunParams, type ThreadCreateAndRunParamsNonStreaming as ThreadCreateAndRunParamsNonStreaming, type ThreadCreateAndRunParamsStreaming as ThreadCreateAndRunParamsStreaming, type ThreadCreateAndRunPollParams, type ThreadCreateAndRunStreamParams, };
}
//# sourceMappingURL=beta.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"beta.d.ts","sourceRoot":"","sources":["../../src/resources/beta/beta.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAClD,OAAO,KAAK,aAAa,wBAAqB;AAC9C,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EAClB,wBAAqB;AACtB,OAAO,KAAK,WAAW,+BAA4B;AACnD,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,EAC3B,4BAA4B,EAC5B,qDAAqD,EACrD,iDAAiD,EACjD,kDAAkD,EAClD,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,6BAA6B,EAC7B,UAAU,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,8BAA8B,EAC9B,kCAAkC,EAClC,kCAAkC,EAClC,sBAAsB,EACtB,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,iCAAiC,EACjC,gCAAgC,EAChC,mBAAmB,EACnB,6BAA6B,EAC7B,4BAA4B,EAC5B,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,uCAAuC,EACvC,sCAAsC,EACtC,4BAA4B,EAC5B,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,EAC1B,gCAAgC,EACjC,+BAA4B;AAC7B,OAAO,KAAK,UAAU,6BAA0B;AAChD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,6BAA0B;AAC7D,OAAO,KAAK,UAAU,6BAA0B;AAChD,OAAO,EACL,6BAA6B,EAC7B,mBAAmB,EACnB,2BAA2B,EAC3B,yBAAyB,EACzB,MAAM,EACN,wBAAwB,EACxB,oCAAoC,EACpC,iCAAiC,EACjC,4BAA4B,EAC5B,8BAA8B,EAC9B,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,OAAO,EACR,6BAA0B;AAE3B,qBAAa,IAAK,SAAQ,WAAW;IACnC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAA0C;IACxE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAwC;IACnE,UAAU,EAAE,aAAa,CAAC,UAAU,CAA8C;IAClF,OAAO,EAAE,UAAU,CAAC,OAAO,CAAwC;CACpE;AAOD,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,OAAO,EACL,QAAQ,IAAI,QAAQ,EACpB,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,qDAAqD,IAAI,qDAAqD,EACnH,KAAK,iDAAiD,IAAI,iDAAiD,EAC3G,KAAK,kDAAkD,IAAI,kDAAkD,EAC7G,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,8BAA8B,IAAI,8BAA8B,EACrE,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,UAAU,IAAI,UAAU,EAC7B,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,8BAA8B,IAAI,8BAA8B,EACrE,KAAK,kCAAkC,IAAI,kCAAkC,EAC7E,KAAK,kCAAkC,IAAI,kCAAkC,EAC7E,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,gCAAgC,IAAI,gCAAgC,EACzE,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,uCAAuC,IAAI,uCAAuC,EACvF,KAAK,sCAAsC,IAAI,sCAAsC,EACrF,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,gCAAgC,IAAI,gCAAgC,EACzE,OAAO,IAAI,OAAO,EAClB,KAAK,eAAe,IAAI,eAAe,GACxC,CAAC;IAEF,OAAO,EACL,UAAU,IAAI,UAAU,EACxB,KAAK,SAAS,IAAI,SAAS,EAC3B,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,YAAY,IAAI,YAAY,EACjC,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,mBAAmB,IAAI,mBAAmB,GAChD,CAAC;IAEF,OAAO,EACL,OAAO,IAAI,OAAO,EAClB,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,MAAM,IAAI,MAAM,EACrB,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,oCAAoC,IAAI,oCAAoC,EACjF,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,GACpC,CAAC;CACH"}
+29
View File
@@ -0,0 +1,29 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Beta = void 0;
const tslib_1 = require("../../internal/tslib.js");
const resource_1 = require("../../core/resource.js");
const AssistantsAPI = tslib_1.__importStar(require("./assistants.js"));
const assistants_1 = require("./assistants.js");
const RealtimeAPI = tslib_1.__importStar(require("./realtime/realtime.js"));
const realtime_1 = require("./realtime/realtime.js");
const ChatKitAPI = tslib_1.__importStar(require("./chatkit/chatkit.js"));
const chatkit_1 = require("./chatkit/chatkit.js");
const ThreadsAPI = tslib_1.__importStar(require("./threads/threads.js"));
const threads_1 = require("./threads/threads.js");
class Beta extends resource_1.APIResource {
constructor() {
super(...arguments);
this.realtime = new RealtimeAPI.Realtime(this._client);
this.chatkit = new ChatKitAPI.ChatKit(this._client);
this.assistants = new AssistantsAPI.Assistants(this._client);
this.threads = new ThreadsAPI.Threads(this._client);
}
}
exports.Beta = Beta;
Beta.Realtime = realtime_1.Realtime;
Beta.ChatKit = chatkit_1.ChatKit;
Beta.Assistants = assistants_1.Assistants;
Beta.Threads = threads_1.Threads;
//# sourceMappingURL=beta.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"beta.js","sourceRoot":"","sources":["../../src/resources/beta/beta.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,qDAAkD;AAClD,uEAA8C;AAC9C,gDAiBsB;AACtB,4EAAmD;AACnD,qDAmD6B;AAC7B,yEAAgD;AAChD,kDAA6D;AAC7D,yEAAgD;AAChD,kDAe2B;AAE3B,MAAa,IAAK,SAAQ,sBAAW;IAArC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxE,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnE,eAAU,GAA6B,IAAI,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClF,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CAAA;AALD,oBAKC;AAED,IAAI,CAAC,QAAQ,GAAG,mBAAQ,CAAC;AACzB,IAAI,CAAC,OAAO,GAAG,iBAAO,CAAC;AACvB,IAAI,CAAC,UAAU,GAAG,uBAAU,CAAC;AAC7B,IAAI,CAAC,OAAO,GAAG,iBAAO,CAAC"}
+24
View File
@@ -0,0 +1,24 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import * as AssistantsAPI from "./assistants.mjs";
import { Assistants, } from "./assistants.mjs";
import * as RealtimeAPI from "./realtime/realtime.mjs";
import { Realtime, } from "./realtime/realtime.mjs";
import * as ChatKitAPI from "./chatkit/chatkit.mjs";
import { ChatKit } from "./chatkit/chatkit.mjs";
import * as ThreadsAPI from "./threads/threads.mjs";
import { Threads, } from "./threads/threads.mjs";
export class Beta extends APIResource {
constructor() {
super(...arguments);
this.realtime = new RealtimeAPI.Realtime(this._client);
this.chatkit = new ChatKitAPI.ChatKit(this._client);
this.assistants = new AssistantsAPI.Assistants(this._client);
this.threads = new ThreadsAPI.Threads(this._client);
}
}
Beta.Realtime = Realtime;
Beta.ChatKit = ChatKit;
Beta.Assistants = Assistants;
Beta.Threads = Threads;
//# sourceMappingURL=beta.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"beta.mjs","sourceRoot":"","sources":["../../src/resources/beta/beta.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAClD,OAAO,KAAK,aAAa,yBAAqB;AAC9C,OAAO,EAQL,UAAU,GASX,yBAAqB;AACtB,OAAO,KAAK,WAAW,gCAA4B;AACnD,OAAO,EAwBL,QAAQ,GA2BT,gCAA4B;AAC7B,OAAO,KAAK,UAAU,8BAA0B;AAChD,OAAO,EAAE,OAAO,EAAmB,8BAA0B;AAC7D,OAAO,KAAK,UAAU,8BAA0B;AAChD,OAAO,EAcL,OAAO,GACR,8BAA0B;AAE3B,MAAM,OAAO,IAAK,SAAQ,WAAW;IAArC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxE,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnE,eAAU,GAA6B,IAAI,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClF,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CAAA;AAED,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;AAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
export * from "./chatkit/index.mjs";
//# sourceMappingURL=chatkit.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.d.mts","sourceRoot":"","sources":["../../src/resources/beta/chatkit.ts"],"names":[],"mappings":"AAEA,oCAAgC"}
+2
View File
@@ -0,0 +1,2 @@
export * from "./chatkit/index.js";
//# sourceMappingURL=chatkit.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.d.ts","sourceRoot":"","sources":["../../src/resources/beta/chatkit.ts"],"names":[],"mappings":"AAEA,mCAAgC"}
+6
View File
@@ -0,0 +1,6 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("../../internal/tslib.js");
tslib_1.__exportStar(require("./chatkit/index.js"), exports);
//# sourceMappingURL=chatkit.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.js","sourceRoot":"","sources":["../../src/resources/beta/chatkit.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6DAAgC"}
+3
View File
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export * from "./chatkit/index.mjs";
//# sourceMappingURL=chatkit.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.mjs","sourceRoot":"","sources":["../../src/resources/beta/chatkit.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,oCAAgC"}
+51
View File
@@ -0,0 +1,51 @@
import { APIResource } from "../../../core/resource.mjs";
import * as SessionsAPI from "./sessions.mjs";
import { SessionCreateParams, Sessions } from "./sessions.mjs";
import * as ThreadsAPI from "./threads.mjs";
import { ChatKitAttachment, ChatKitResponseOutputText, ChatKitThread, ChatKitThreadAssistantMessageItem, ChatKitThreadItemList, ChatKitThreadItemListDataPage, ChatKitThreadUserMessageItem, ChatKitThreadsPage, ChatKitWidgetItem, ChatSession, ChatSessionAutomaticThreadTitling, ChatSessionChatKitConfiguration, ChatSessionChatKitConfigurationParam, ChatSessionExpiresAfterParam, ChatSessionFileUpload, ChatSessionHistory, ChatSessionRateLimits, ChatSessionRateLimitsParam, ChatSessionStatus, ChatSessionWorkflowParam, ThreadDeleteResponse, ThreadListItemsParams, ThreadListParams, Threads } from "./threads.mjs";
export declare class ChatKit extends APIResource {
sessions: SessionsAPI.Sessions;
threads: ThreadsAPI.Threads;
}
/**
* Workflow metadata and state returned for the session.
*/
export interface ChatKitWorkflow {
/**
* Identifier of the workflow backing the session.
*/
id: string;
/**
* State variable key-value pairs applied when invoking the workflow. Defaults to
* null when no overrides were provided.
*/
state_variables: {
[key: string]: string | boolean | number;
} | null;
/**
* Tracing settings applied to the workflow.
*/
tracing: ChatKitWorkflow.Tracing;
/**
* Specific workflow version used for the session. Defaults to null when using the
* latest deployment.
*/
version: string | null;
}
export declare namespace ChatKitWorkflow {
/**
* Tracing settings applied to the workflow.
*/
interface Tracing {
/**
* Indicates whether tracing is enabled.
*/
enabled: boolean;
}
}
export declare namespace ChatKit {
export { type ChatKitWorkflow as ChatKitWorkflow };
export { Sessions as Sessions, type SessionCreateParams as SessionCreateParams };
export { Threads as Threads, type ChatSession as ChatSession, type ChatSessionAutomaticThreadTitling as ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration as ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam as ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam as ChatSessionExpiresAfterParam, type ChatSessionFileUpload as ChatSessionFileUpload, type ChatSessionHistory as ChatSessionHistory, type ChatSessionRateLimits as ChatSessionRateLimits, type ChatSessionRateLimitsParam as ChatSessionRateLimitsParam, type ChatSessionStatus as ChatSessionStatus, type ChatSessionWorkflowParam as ChatSessionWorkflowParam, type ChatKitAttachment as ChatKitAttachment, type ChatKitResponseOutputText as ChatKitResponseOutputText, type ChatKitThread as ChatKitThread, type ChatKitThreadAssistantMessageItem as ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList as ChatKitThreadItemList, type ChatKitThreadUserMessageItem as ChatKitThreadUserMessageItem, type ChatKitWidgetItem as ChatKitWidgetItem, type ThreadDeleteResponse as ThreadDeleteResponse, type ChatKitThreadsPage as ChatKitThreadsPage, type ChatKitThreadItemListDataPage as ChatKitThreadItemListDataPage, type ThreadListParams as ThreadListParams, type ThreadListItemsParams as ThreadListItemsParams, };
}
//# sourceMappingURL=chatkit.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/chatkit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,mCAA+B;AACrD,OAAO,KAAK,WAAW,uBAAmB;AAC1C,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,uBAAmB;AAC3D,OAAO,KAAK,UAAU,sBAAkB;AACxC,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,aAAa,EACb,iCAAiC,EACjC,qBAAqB,EACrB,6BAA6B,EAC7B,4BAA4B,EAC5B,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,4BAA4B,EAC5B,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,OAAO,EACR,sBAAkB;AAEnB,qBAAa,OAAQ,SAAQ,WAAW;IACtC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAA0C;IACxE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAwC;CACpE;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAErE;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;IAEjC;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,yBAAiB,eAAe,CAAC;IAC/B;;OAEG;IACH,UAAiB,OAAO;QACtB;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;KAClB;CACF;AAKD,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,OAAO,EAAE,KAAK,eAAe,IAAI,eAAe,EAAE,CAAC;IAEnD,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,KAAK,mBAAmB,IAAI,mBAAmB,EAAE,CAAC;IAEjF,OAAO,EACL,OAAO,IAAI,OAAO,EAClB,KAAK,WAAW,IAAI,WAAW,EAC/B,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,oCAAoC,IAAI,oCAAoC,EACjF,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,qBAAqB,IAAI,qBAAqB,GACpD,CAAC;CACH"}
+51
View File
@@ -0,0 +1,51 @@
import { APIResource } from "../../../core/resource.js";
import * as SessionsAPI from "./sessions.js";
import { SessionCreateParams, Sessions } from "./sessions.js";
import * as ThreadsAPI from "./threads.js";
import { ChatKitAttachment, ChatKitResponseOutputText, ChatKitThread, ChatKitThreadAssistantMessageItem, ChatKitThreadItemList, ChatKitThreadItemListDataPage, ChatKitThreadUserMessageItem, ChatKitThreadsPage, ChatKitWidgetItem, ChatSession, ChatSessionAutomaticThreadTitling, ChatSessionChatKitConfiguration, ChatSessionChatKitConfigurationParam, ChatSessionExpiresAfterParam, ChatSessionFileUpload, ChatSessionHistory, ChatSessionRateLimits, ChatSessionRateLimitsParam, ChatSessionStatus, ChatSessionWorkflowParam, ThreadDeleteResponse, ThreadListItemsParams, ThreadListParams, Threads } from "./threads.js";
export declare class ChatKit extends APIResource {
sessions: SessionsAPI.Sessions;
threads: ThreadsAPI.Threads;
}
/**
* Workflow metadata and state returned for the session.
*/
export interface ChatKitWorkflow {
/**
* Identifier of the workflow backing the session.
*/
id: string;
/**
* State variable key-value pairs applied when invoking the workflow. Defaults to
* null when no overrides were provided.
*/
state_variables: {
[key: string]: string | boolean | number;
} | null;
/**
* Tracing settings applied to the workflow.
*/
tracing: ChatKitWorkflow.Tracing;
/**
* Specific workflow version used for the session. Defaults to null when using the
* latest deployment.
*/
version: string | null;
}
export declare namespace ChatKitWorkflow {
/**
* Tracing settings applied to the workflow.
*/
interface Tracing {
/**
* Indicates whether tracing is enabled.
*/
enabled: boolean;
}
}
export declare namespace ChatKit {
export { type ChatKitWorkflow as ChatKitWorkflow };
export { Sessions as Sessions, type SessionCreateParams as SessionCreateParams };
export { Threads as Threads, type ChatSession as ChatSession, type ChatSessionAutomaticThreadTitling as ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration as ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam as ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam as ChatSessionExpiresAfterParam, type ChatSessionFileUpload as ChatSessionFileUpload, type ChatSessionHistory as ChatSessionHistory, type ChatSessionRateLimits as ChatSessionRateLimits, type ChatSessionRateLimitsParam as ChatSessionRateLimitsParam, type ChatSessionStatus as ChatSessionStatus, type ChatSessionWorkflowParam as ChatSessionWorkflowParam, type ChatKitAttachment as ChatKitAttachment, type ChatKitResponseOutputText as ChatKitResponseOutputText, type ChatKitThread as ChatKitThread, type ChatKitThreadAssistantMessageItem as ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList as ChatKitThreadItemList, type ChatKitThreadUserMessageItem as ChatKitThreadUserMessageItem, type ChatKitWidgetItem as ChatKitWidgetItem, type ThreadDeleteResponse as ThreadDeleteResponse, type ChatKitThreadsPage as ChatKitThreadsPage, type ChatKitThreadItemListDataPage as ChatKitThreadItemListDataPage, type ThreadListParams as ThreadListParams, type ThreadListItemsParams as ThreadListItemsParams, };
}
//# sourceMappingURL=chatkit.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/chatkit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,kCAA+B;AACrD,OAAO,KAAK,WAAW,sBAAmB;AAC1C,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,sBAAmB;AAC3D,OAAO,KAAK,UAAU,qBAAkB;AACxC,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,aAAa,EACb,iCAAiC,EACjC,qBAAqB,EACrB,6BAA6B,EAC7B,4BAA4B,EAC5B,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,4BAA4B,EAC5B,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,OAAO,EACR,qBAAkB;AAEnB,qBAAa,OAAQ,SAAQ,WAAW;IACtC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAA0C;IACxE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAwC;CACpE;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAErE;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;IAEjC;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,yBAAiB,eAAe,CAAC;IAC/B;;OAEG;IACH,UAAiB,OAAO;QACtB;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;KAClB;CACF;AAKD,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,OAAO,EAAE,KAAK,eAAe,IAAI,eAAe,EAAE,CAAC;IAEnD,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,KAAK,mBAAmB,IAAI,mBAAmB,EAAE,CAAC;IAEjF,OAAO,EACL,OAAO,IAAI,OAAO,EAClB,KAAK,WAAW,IAAI,WAAW,EAC/B,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,oCAAoC,IAAI,oCAAoC,EACjF,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,qBAAqB,IAAI,qBAAqB,GACpD,CAAC;CACH"}
+21
View File
@@ -0,0 +1,21 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatKit = void 0;
const tslib_1 = require("../../../internal/tslib.js");
const resource_1 = require("../../../core/resource.js");
const SessionsAPI = tslib_1.__importStar(require("./sessions.js"));
const sessions_1 = require("./sessions.js");
const ThreadsAPI = tslib_1.__importStar(require("./threads.js"));
const threads_1 = require("./threads.js");
class ChatKit extends resource_1.APIResource {
constructor() {
super(...arguments);
this.sessions = new SessionsAPI.Sessions(this._client);
this.threads = new ThreadsAPI.Threads(this._client);
}
}
exports.ChatKit = ChatKit;
ChatKit.Sessions = sessions_1.Sessions;
ChatKit.Threads = threads_1.Threads;
//# sourceMappingURL=chatkit.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.js","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/chatkit.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,wDAAqD;AACrD,mEAA0C;AAC1C,4CAA2D;AAC3D,iEAAwC;AACxC,0CAyBmB;AAEnB,MAAa,OAAQ,SAAQ,sBAAW;IAAxC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxE,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CAAA;AAHD,0BAGC;AAyCD,OAAO,CAAC,QAAQ,GAAG,mBAAQ,CAAC;AAC5B,OAAO,CAAC,OAAO,GAAG,iBAAO,CAAC"}
+16
View File
@@ -0,0 +1,16 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as SessionsAPI from "./sessions.mjs";
import { Sessions } from "./sessions.mjs";
import * as ThreadsAPI from "./threads.mjs";
import { Threads, } from "./threads.mjs";
export class ChatKit extends APIResource {
constructor() {
super(...arguments);
this.sessions = new SessionsAPI.Sessions(this._client);
this.threads = new ThreadsAPI.Threads(this._client);
}
}
ChatKit.Sessions = Sessions;
ChatKit.Threads = Threads;
//# sourceMappingURL=chatkit.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.mjs","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/chatkit.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AACrD,OAAO,KAAK,WAAW,uBAAmB;AAC1C,OAAO,EAAuB,QAAQ,EAAE,uBAAmB;AAC3D,OAAO,KAAK,UAAU,sBAAkB;AACxC,OAAO,EAwBL,OAAO,GACR,sBAAkB;AAEnB,MAAM,OAAO,OAAQ,SAAQ,WAAW;IAAxC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxE,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CAAA;AAyCD,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC5B,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC"}
+4
View File
@@ -0,0 +1,4 @@
export { ChatKit, type ChatKitWorkflow } from "./chatkit.mjs";
export { Sessions, type SessionCreateParams } from "./sessions.mjs";
export { Threads, type ChatSession, type ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam, type ChatSessionFileUpload, type ChatSessionHistory, type ChatSessionRateLimits, type ChatSessionRateLimitsParam, type ChatSessionStatus, type ChatSessionWorkflowParam, type ChatKitAttachment, type ChatKitResponseOutputText, type ChatKitThread, type ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList, type ChatKitThreadUserMessageItem, type ChatKitWidgetItem, type ThreadDeleteResponse, type ThreadListParams, type ThreadListItemsParams, type ChatKitThreadsPage, type ChatKitThreadItemListDataPage, } from "./threads.mjs";
//# sourceMappingURL=index.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,eAAe,EAAE,sBAAkB;AAC1D,OAAO,EAAE,QAAQ,EAAE,KAAK,mBAAmB,EAAE,uBAAmB;AAChE,OAAO,EACL,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,iCAAiC,EACtC,KAAK,+BAA+B,EACpC,KAAK,oCAAoC,EACzC,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,iCAAiC,EACtC,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,GACnC,sBAAkB"}
+4
View File
@@ -0,0 +1,4 @@
export { ChatKit, type ChatKitWorkflow } from "./chatkit.js";
export { Sessions, type SessionCreateParams } from "./sessions.js";
export { Threads, type ChatSession, type ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam, type ChatSessionFileUpload, type ChatSessionHistory, type ChatSessionRateLimits, type ChatSessionRateLimitsParam, type ChatSessionStatus, type ChatSessionWorkflowParam, type ChatKitAttachment, type ChatKitResponseOutputText, type ChatKitThread, type ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList, type ChatKitThreadUserMessageItem, type ChatKitWidgetItem, type ThreadDeleteResponse, type ThreadListParams, type ThreadListItemsParams, type ChatKitThreadsPage, type ChatKitThreadItemListDataPage, } from "./threads.js";
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,eAAe,EAAE,qBAAkB;AAC1D,OAAO,EAAE,QAAQ,EAAE,KAAK,mBAAmB,EAAE,sBAAmB;AAChE,OAAO,EACL,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,iCAAiC,EACtC,KAAK,+BAA+B,EACpC,KAAK,oCAAoC,EACzC,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,iCAAiC,EACtC,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,GACnC,qBAAkB"}
+11
View File
@@ -0,0 +1,11 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Threads = exports.Sessions = exports.ChatKit = void 0;
var chatkit_1 = require("./chatkit.js");
Object.defineProperty(exports, "ChatKit", { enumerable: true, get: function () { return chatkit_1.ChatKit; } });
var sessions_1 = require("./sessions.js");
Object.defineProperty(exports, "Sessions", { enumerable: true, get: function () { return sessions_1.Sessions; } });
var threads_1 = require("./threads.js");
Object.defineProperty(exports, "Threads", { enumerable: true, get: function () { return threads_1.Threads; } });
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wCAA0D;AAAjD,kGAAA,OAAO,OAAA;AAChB,0CAAgE;AAAvD,oGAAA,QAAQ,OAAA;AACjB,wCAyBmB;AAxBjB,kGAAA,OAAO,OAAA"}
+5
View File
@@ -0,0 +1,5 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export { ChatKit } from "./chatkit.mjs";
export { Sessions } from "./sessions.mjs";
export { Threads, } from "./threads.mjs";
//# sourceMappingURL=index.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,OAAO,EAAwB,sBAAkB;AAC1D,OAAO,EAAE,QAAQ,EAA4B,uBAAmB;AAChE,OAAO,EACL,OAAO,GAwBR,sBAAkB"}
+59
View File
@@ -0,0 +1,59 @@
import { APIResource } from "../../../core/resource.mjs";
import * as ThreadsAPI from "./threads.mjs";
import { APIPromise } from "../../../core/api-promise.mjs";
import { RequestOptions } from "../../../internal/request-options.mjs";
export declare class Sessions extends APIResource {
/**
* Create a ChatKit session.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.create({
* user: 'x',
* workflow: { id: 'id' },
* });
* ```
*/
create(body: SessionCreateParams, options?: RequestOptions): APIPromise<ThreadsAPI.ChatSession>;
/**
* Cancel an active ChatKit session and return its most recent metadata.
*
* Cancelling prevents new requests from using the issued client secret.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.cancel('cksess_123');
* ```
*/
cancel(sessionID: string, options?: RequestOptions): APIPromise<ThreadsAPI.ChatSession>;
}
export interface SessionCreateParams {
/**
* A free-form string that identifies your end user; ensures this Session can
* access other objects that have the same `user` scope.
*/
user: string;
/**
* Workflow that powers the session.
*/
workflow: ThreadsAPI.ChatSessionWorkflowParam;
/**
* Optional overrides for ChatKit runtime configuration features
*/
chatkit_configuration?: ThreadsAPI.ChatSessionChatKitConfigurationParam;
/**
* Optional override for session expiration timing in seconds from creation.
* Defaults to 10 minutes.
*/
expires_after?: ThreadsAPI.ChatSessionExpiresAfterParam;
/**
* Optional override for per-minute request limits. When omitted, defaults to 10.
*/
rate_limits?: ThreadsAPI.ChatSessionRateLimitsParam;
}
export declare namespace Sessions {
export { type SessionCreateParams as SessionCreateParams };
}
//# sourceMappingURL=sessions.d.mts.map
@@ -0,0 +1 @@
{"version":3,"file":"sessions.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/sessions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,mCAA+B;AACrD,OAAO,KAAK,UAAU,sBAAkB;AACxC,OAAO,EAAE,UAAU,EAAE,sCAAkC;AAEvD,OAAO,EAAE,cAAc,EAAE,8CAA0C;AAGnE,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC;IAS/F;;;;;;;;;;OAUG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC;CAOxF;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC,wBAAwB,CAAC;IAE9C;;OAEG;IACH,qBAAqB,CAAC,EAAE,UAAU,CAAC,oCAAoC,CAAC;IAExE;;;OAGG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC,4BAA4B,CAAC;IAExD;;OAEG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC,0BAA0B,CAAC;CACrD;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EAAE,KAAK,mBAAmB,IAAI,mBAAmB,EAAE,CAAC;CAC5D"}
+59
View File
@@ -0,0 +1,59 @@
import { APIResource } from "../../../core/resource.js";
import * as ThreadsAPI from "./threads.js";
import { APIPromise } from "../../../core/api-promise.js";
import { RequestOptions } from "../../../internal/request-options.js";
export declare class Sessions extends APIResource {
/**
* Create a ChatKit session.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.create({
* user: 'x',
* workflow: { id: 'id' },
* });
* ```
*/
create(body: SessionCreateParams, options?: RequestOptions): APIPromise<ThreadsAPI.ChatSession>;
/**
* Cancel an active ChatKit session and return its most recent metadata.
*
* Cancelling prevents new requests from using the issued client secret.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.cancel('cksess_123');
* ```
*/
cancel(sessionID: string, options?: RequestOptions): APIPromise<ThreadsAPI.ChatSession>;
}
export interface SessionCreateParams {
/**
* A free-form string that identifies your end user; ensures this Session can
* access other objects that have the same `user` scope.
*/
user: string;
/**
* Workflow that powers the session.
*/
workflow: ThreadsAPI.ChatSessionWorkflowParam;
/**
* Optional overrides for ChatKit runtime configuration features
*/
chatkit_configuration?: ThreadsAPI.ChatSessionChatKitConfigurationParam;
/**
* Optional override for session expiration timing in seconds from creation.
* Defaults to 10 minutes.
*/
expires_after?: ThreadsAPI.ChatSessionExpiresAfterParam;
/**
* Optional override for per-minute request limits. When omitted, defaults to 10.
*/
rate_limits?: ThreadsAPI.ChatSessionRateLimitsParam;
}
export declare namespace Sessions {
export { type SessionCreateParams as SessionCreateParams };
}
//# sourceMappingURL=sessions.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/sessions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,kCAA+B;AACrD,OAAO,KAAK,UAAU,qBAAkB;AACxC,OAAO,EAAE,UAAU,EAAE,qCAAkC;AAEvD,OAAO,EAAE,cAAc,EAAE,6CAA0C;AAGnE,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC;IAS/F;;;;;;;;;;OAUG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC;CAOxF;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC,wBAAwB,CAAC;IAE9C;;OAEG;IACH,qBAAqB,CAAC,EAAE,UAAU,CAAC,oCAAoC,CAAC;IAExE;;;OAGG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC,4BAA4B,CAAC;IAExD;;OAEG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC,0BAA0B,CAAC;CACrD;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EAAE,KAAK,mBAAmB,IAAI,mBAAmB,EAAE,CAAC;CAC5D"}
+49
View File
@@ -0,0 +1,49 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Sessions = void 0;
const resource_1 = require("../../../core/resource.js");
const headers_1 = require("../../../internal/headers.js");
const path_1 = require("../../../internal/utils/path.js");
class Sessions extends resource_1.APIResource {
/**
* Create a ChatKit session.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.create({
* user: 'x',
* workflow: { id: 'id' },
* });
* ```
*/
create(body, options) {
return this._client.post('/chatkit/sessions', {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Cancel an active ChatKit session and return its most recent metadata.
*
* Cancelling prevents new requests from using the issued client secret.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.cancel('cksess_123');
* ```
*/
cancel(sessionID, options) {
return this._client.post((0, path_1.path) `/chatkit/sessions/${sessionID}/cancel`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
exports.Sessions = Sessions;
//# sourceMappingURL=sessions.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/sessions.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wDAAqD;AAGrD,0DAAyD;AAEzD,0DAAoD;AAEpD,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAyB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAC5C,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,SAAiB,EAAE,OAAwB;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,qBAAqB,SAAS,SAAS,EAAE;YACpE,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AAxCD,4BAwCC"}
+45
View File
@@ -0,0 +1,45 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { buildHeaders } from "../../../internal/headers.mjs";
import { path } from "../../../internal/utils/path.mjs";
export class Sessions extends APIResource {
/**
* Create a ChatKit session.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.create({
* user: 'x',
* workflow: { id: 'id' },
* });
* ```
*/
create(body, options) {
return this._client.post('/chatkit/sessions', {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Cancel an active ChatKit session and return its most recent metadata.
*
* Cancelling prevents new requests from using the issued client secret.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.cancel('cksess_123');
* ```
*/
cancel(sessionID, options) {
return this._client.post(path `/chatkit/sessions/${sessionID}/cancel`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
//# sourceMappingURL=sessions.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"sessions.mjs","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/sessions.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AAGrD,OAAO,EAAE,YAAY,EAAE,sCAAkC;AAEzD,OAAO,EAAE,IAAI,EAAE,yCAAqC;AAEpD,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAyB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAC5C,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,SAAiB,EAAE,OAAwB;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,qBAAqB,SAAS,SAAS,EAAE;YACpE,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
+811
View File
@@ -0,0 +1,811 @@
import { APIResource } from "../../../core/resource.mjs";
import * as ChatKitAPI from "./chatkit.mjs";
import { APIPromise } from "../../../core/api-promise.mjs";
import { ConversationCursorPage, type ConversationCursorPageParams, PagePromise } from "../../../core/pagination.mjs";
import { RequestOptions } from "../../../internal/request-options.mjs";
export declare class Threads extends APIResource {
/**
* Retrieve a ChatKit thread by its identifier.
*
* @example
* ```ts
* const chatkitThread =
* await client.beta.chatkit.threads.retrieve('cthr_123');
* ```
*/
retrieve(threadID: string, options?: RequestOptions): APIPromise<ChatKitThread>;
/**
* List ChatKit threads with optional pagination and user filters.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const chatkitThread of client.beta.chatkit.threads.list()) {
* // ...
* }
* ```
*/
list(query?: ThreadListParams | null | undefined, options?: RequestOptions): PagePromise<ChatKitThreadsPage, ChatKitThread>;
/**
* Delete a ChatKit thread along with its items and stored attachments.
*
* @example
* ```ts
* const thread = await client.beta.chatkit.threads.delete(
* 'cthr_123',
* );
* ```
*/
delete(threadID: string, options?: RequestOptions): APIPromise<ThreadDeleteResponse>;
/**
* List items that belong to a ChatKit thread.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const thread of client.beta.chatkit.threads.listItems(
* 'cthr_123',
* )) {
* // ...
* }
* ```
*/
listItems(threadID: string, query?: ThreadListItemsParams | null | undefined, options?: RequestOptions): PagePromise<ChatKitThreadItemListDataPage, ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
}
export type ChatKitThreadsPage = ConversationCursorPage<ChatKitThread>;
export type ChatKitThreadItemListDataPage = ConversationCursorPage<ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
/**
* Represents a ChatKit session and its resolved configuration.
*/
export interface ChatSession {
/**
* Identifier for the ChatKit session.
*/
id: string;
/**
* Resolved ChatKit feature configuration for the session.
*/
chatkit_configuration: ChatSessionChatKitConfiguration;
/**
* Ephemeral client secret that authenticates session requests.
*/
client_secret: string;
/**
* Unix timestamp (in seconds) for when the session expires.
*/
expires_at: number;
/**
* Convenience copy of the per-minute request limit.
*/
max_requests_per_1_minute: number;
/**
* Type discriminator that is always `chatkit.session`.
*/
object: 'chatkit.session';
/**
* Resolved rate limit values.
*/
rate_limits: ChatSessionRateLimits;
/**
* Current lifecycle state of the session.
*/
status: ChatSessionStatus;
/**
* User identifier associated with the session.
*/
user: string;
/**
* Workflow metadata for the session.
*/
workflow: ChatKitAPI.ChatKitWorkflow;
}
/**
* Automatic thread title preferences for the session.
*/
export interface ChatSessionAutomaticThreadTitling {
/**
* Whether automatic thread titling is enabled.
*/
enabled: boolean;
}
/**
* ChatKit configuration for the session.
*/
export interface ChatSessionChatKitConfiguration {
/**
* Automatic thread titling preferences.
*/
automatic_thread_titling: ChatSessionAutomaticThreadTitling;
/**
* Upload settings for the session.
*/
file_upload: ChatSessionFileUpload;
/**
* History retention configuration.
*/
history: ChatSessionHistory;
}
/**
* Optional per-session configuration settings for ChatKit behavior.
*/
export interface ChatSessionChatKitConfigurationParam {
/**
* Configuration for automatic thread titling. When omitted, automatic thread
* titling is enabled by default.
*/
automatic_thread_titling?: ChatSessionChatKitConfigurationParam.AutomaticThreadTitling;
/**
* Configuration for upload enablement and limits. When omitted, uploads are
* disabled by default (max_files 10, max_file_size 512 MB).
*/
file_upload?: ChatSessionChatKitConfigurationParam.FileUpload;
/**
* Configuration for chat history retention. When omitted, history is enabled by
* default with no limit on recent_threads (null).
*/
history?: ChatSessionChatKitConfigurationParam.History;
}
export declare namespace ChatSessionChatKitConfigurationParam {
/**
* Configuration for automatic thread titling. When omitted, automatic thread
* titling is enabled by default.
*/
interface AutomaticThreadTitling {
/**
* Enable automatic thread title generation. Defaults to true.
*/
enabled?: boolean;
}
/**
* Configuration for upload enablement and limits. When omitted, uploads are
* disabled by default (max_files 10, max_file_size 512 MB).
*/
interface FileUpload {
/**
* Enable uploads for this session. Defaults to false.
*/
enabled?: boolean;
/**
* Maximum size in megabytes for each uploaded file. Defaults to 512 MB, which is
* the maximum allowable size.
*/
max_file_size?: number;
/**
* Maximum number of files that can be uploaded to the session. Defaults to 10.
*/
max_files?: number;
}
/**
* Configuration for chat history retention. When omitted, history is enabled by
* default with no limit on recent_threads (null).
*/
interface History {
/**
* Enables chat users to access previous ChatKit threads. Defaults to true.
*/
enabled?: boolean;
/**
* Number of recent ChatKit threads users have access to. Defaults to unlimited
* when unset.
*/
recent_threads?: number;
}
}
/**
* Controls when the session expires relative to an anchor timestamp.
*/
export interface ChatSessionExpiresAfterParam {
/**
* Base timestamp used to calculate expiration. Currently fixed to `created_at`.
*/
anchor: 'created_at';
/**
* Number of seconds after the anchor when the session expires.
*/
seconds: number;
}
/**
* Upload permissions and limits applied to the session.
*/
export interface ChatSessionFileUpload {
/**
* Indicates if uploads are enabled for the session.
*/
enabled: boolean;
/**
* Maximum upload size in megabytes.
*/
max_file_size: number | null;
/**
* Maximum number of uploads allowed during the session.
*/
max_files: number | null;
}
/**
* History retention preferences returned for the session.
*/
export interface ChatSessionHistory {
/**
* Indicates if chat history is persisted for the session.
*/
enabled: boolean;
/**
* Number of prior threads surfaced in history views. Defaults to null when all
* history is retained.
*/
recent_threads: number | null;
}
/**
* Active per-minute request limit for the session.
*/
export interface ChatSessionRateLimits {
/**
* Maximum allowed requests per one-minute window.
*/
max_requests_per_1_minute: number;
}
/**
* Controls request rate limits for the session.
*/
export interface ChatSessionRateLimitsParam {
/**
* Maximum number of requests allowed per minute for the session. Defaults to 10.
*/
max_requests_per_1_minute?: number;
}
export type ChatSessionStatus = 'active' | 'expired' | 'cancelled';
/**
* Workflow reference and overrides applied to the chat session.
*/
export interface ChatSessionWorkflowParam {
/**
* Identifier for the workflow invoked by the session.
*/
id: string;
/**
* State variables forwarded to the workflow. Keys may be up to 64 characters,
* values must be primitive types, and the map defaults to an empty object.
*/
state_variables?: {
[key: string]: string | boolean | number;
};
/**
* Optional tracing overrides for the workflow invocation. When omitted, tracing is
* enabled by default.
*/
tracing?: ChatSessionWorkflowParam.Tracing;
/**
* Specific workflow version to run. Defaults to the latest deployed version.
*/
version?: string;
}
export declare namespace ChatSessionWorkflowParam {
/**
* Optional tracing overrides for the workflow invocation. When omitted, tracing is
* enabled by default.
*/
interface Tracing {
/**
* Whether tracing is enabled during the session. Defaults to true.
*/
enabled?: boolean;
}
}
/**
* Attachment metadata included on thread items.
*/
export interface ChatKitAttachment {
/**
* Identifier for the attachment.
*/
id: string;
/**
* MIME type of the attachment.
*/
mime_type: string;
/**
* Original display name for the attachment.
*/
name: string;
/**
* Preview URL for rendering the attachment inline.
*/
preview_url: string | null;
/**
* Attachment discriminator.
*/
type: 'image' | 'file';
}
/**
* Assistant response text accompanied by optional annotations.
*/
export interface ChatKitResponseOutputText {
/**
* Ordered list of annotations attached to the response text.
*/
annotations: Array<ChatKitResponseOutputText.File | ChatKitResponseOutputText.URL>;
/**
* Assistant generated text.
*/
text: string;
/**
* Type discriminator that is always `output_text`.
*/
type: 'output_text';
}
export declare namespace ChatKitResponseOutputText {
/**
* Annotation that references an uploaded file.
*/
interface File {
/**
* File attachment referenced by the annotation.
*/
source: File.Source;
/**
* Type discriminator that is always `file` for this annotation.
*/
type: 'file';
}
namespace File {
/**
* File attachment referenced by the annotation.
*/
interface Source {
/**
* Filename referenced by the annotation.
*/
filename: string;
/**
* Type discriminator that is always `file`.
*/
type: 'file';
}
}
/**
* Annotation that references a URL.
*/
interface URL {
/**
* URL referenced by the annotation.
*/
source: URL.Source;
/**
* Type discriminator that is always `url` for this annotation.
*/
type: 'url';
}
namespace URL {
/**
* URL referenced by the annotation.
*/
interface Source {
/**
* Type discriminator that is always `url`.
*/
type: 'url';
/**
* URL referenced by the annotation.
*/
url: string;
}
}
}
/**
* Represents a ChatKit thread and its current status.
*/
export interface ChatKitThread {
/**
* Identifier of the thread.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the thread was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread`.
*/
object: 'chatkit.thread';
/**
* Current status for the thread. Defaults to `active` for newly created threads.
*/
status: ChatKitThread.Active | ChatKitThread.Locked | ChatKitThread.Closed;
/**
* Optional human-readable title for the thread. Defaults to null when no title has
* been generated.
*/
title: string | null;
/**
* Free-form string that identifies your end user who owns the thread.
*/
user: string;
}
export declare namespace ChatKitThread {
/**
* Indicates that a thread is active.
*/
interface Active {
/**
* Status discriminator that is always `active`.
*/
type: 'active';
}
/**
* Indicates that a thread is locked and cannot accept new input.
*/
interface Locked {
/**
* Reason that the thread was locked. Defaults to null when no reason is recorded.
*/
reason: string | null;
/**
* Status discriminator that is always `locked`.
*/
type: 'locked';
}
/**
* Indicates that a thread has been closed.
*/
interface Closed {
/**
* Reason that the thread was closed. Defaults to null when no reason is recorded.
*/
reason: string | null;
/**
* Status discriminator that is always `closed`.
*/
type: 'closed';
}
}
/**
* Assistant-authored message within a thread.
*/
export interface ChatKitThreadAssistantMessageItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Ordered assistant response segments.
*/
content: Array<ChatKitResponseOutputText>;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.assistant_message`.
*/
type: 'chatkit.assistant_message';
}
/**
* A paginated list of thread items rendered for the ChatKit API.
*/
export interface ChatKitThreadItemList {
/**
* A list of items
*/
data: Array<ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
/**
* The ID of the first item in the list.
*/
first_id: string | null;
/**
* Whether there are more items available.
*/
has_more: boolean;
/**
* The ID of the last item in the list.
*/
last_id: string | null;
/**
* The type of object returned, must be `list`.
*/
object: 'list';
}
export declare namespace ChatKitThreadItemList {
/**
* Record of a client side tool invocation initiated by the assistant.
*/
interface ChatKitClientToolCall {
/**
* Identifier of the thread item.
*/
id: string;
/**
* JSON-encoded arguments that were sent to the tool.
*/
arguments: string;
/**
* Identifier for the client tool call.
*/
call_id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Tool name that was invoked.
*/
name: string;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* JSON-encoded output captured from the tool. Defaults to null while execution is
* in progress.
*/
output: string | null;
/**
* Execution status for the tool call.
*/
status: 'in_progress' | 'completed';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.client_tool_call`.
*/
type: 'chatkit.client_tool_call';
}
/**
* Task emitted by the workflow to show progress and status updates.
*/
interface ChatKitTask {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Optional heading for the task. Defaults to null when not provided.
*/
heading: string | null;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Optional summary that describes the task. Defaults to null when omitted.
*/
summary: string | null;
/**
* Subtype for the task.
*/
task_type: 'custom' | 'thought';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.task`.
*/
type: 'chatkit.task';
}
/**
* Collection of workflow tasks grouped together in the thread.
*/
interface ChatKitTaskGroup {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Tasks included in the group.
*/
tasks: Array<ChatKitTaskGroup.Task>;
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.task_group`.
*/
type: 'chatkit.task_group';
}
namespace ChatKitTaskGroup {
/**
* Task entry that appears within a TaskGroup.
*/
interface Task {
/**
* Optional heading for the grouped task. Defaults to null when not provided.
*/
heading: string | null;
/**
* Optional summary that describes the grouped task. Defaults to null when omitted.
*/
summary: string | null;
/**
* Subtype for the grouped task.
*/
type: 'custom' | 'thought';
}
}
}
/**
* User-authored messages within a thread.
*/
export interface ChatKitThreadUserMessageItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Attachments associated with the user message. Defaults to an empty list.
*/
attachments: Array<ChatKitAttachment>;
/**
* Ordered content elements supplied by the user.
*/
content: Array<ChatKitThreadUserMessageItem.InputText | ChatKitThreadUserMessageItem.QuotedText>;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Inference overrides applied to the message. Defaults to null when unset.
*/
inference_options: ChatKitThreadUserMessageItem.InferenceOptions | null;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
type: 'chatkit.user_message';
}
export declare namespace ChatKitThreadUserMessageItem {
/**
* Text block that a user contributed to the thread.
*/
interface InputText {
/**
* Plain-text content supplied by the user.
*/
text: string;
/**
* Type discriminator that is always `input_text`.
*/
type: 'input_text';
}
/**
* Quoted snippet that the user referenced in their message.
*/
interface QuotedText {
/**
* Quoted text content.
*/
text: string;
/**
* Type discriminator that is always `quoted_text`.
*/
type: 'quoted_text';
}
/**
* Inference overrides applied to the message. Defaults to null when unset.
*/
interface InferenceOptions {
/**
* Model name that generated the response. Defaults to null when using the session
* default.
*/
model: string | null;
/**
* Preferred tool to invoke. Defaults to null when ChatKit should auto-select.
*/
tool_choice: InferenceOptions.ToolChoice | null;
}
namespace InferenceOptions {
/**
* Preferred tool to invoke. Defaults to null when ChatKit should auto-select.
*/
interface ToolChoice {
/**
* Identifier of the requested tool.
*/
id: string;
}
}
}
/**
* Thread item that renders a widget payload.
*/
export interface ChatKitWidgetItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.widget`.
*/
type: 'chatkit.widget';
/**
* Serialized widget payload rendered in the UI.
*/
widget: string;
}
/**
* Confirmation payload returned after deleting a thread.
*/
export interface ThreadDeleteResponse {
/**
* Identifier of the deleted thread.
*/
id: string;
/**
* Indicates that the thread has been deleted.
*/
deleted: boolean;
/**
* Type discriminator that is always `chatkit.thread.deleted`.
*/
object: 'chatkit.thread.deleted';
}
export interface ThreadListParams extends ConversationCursorPageParams {
/**
* List items created before this thread item ID. Defaults to null for the newest
* results.
*/
before?: string;
/**
* Sort order for results by creation time. Defaults to `desc`.
*/
order?: 'asc' | 'desc';
/**
* Filter threads that belong to this user identifier. Defaults to null to return
* all users.
*/
user?: string;
}
export interface ThreadListItemsParams extends ConversationCursorPageParams {
/**
* List items created before this thread item ID. Defaults to null for the newest
* results.
*/
before?: string;
/**
* Sort order for results by creation time. Defaults to `desc`.
*/
order?: 'asc' | 'desc';
}
export declare namespace Threads {
export { type ChatSession as ChatSession, type ChatSessionAutomaticThreadTitling as ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration as ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam as ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam as ChatSessionExpiresAfterParam, type ChatSessionFileUpload as ChatSessionFileUpload, type ChatSessionHistory as ChatSessionHistory, type ChatSessionRateLimits as ChatSessionRateLimits, type ChatSessionRateLimitsParam as ChatSessionRateLimitsParam, type ChatSessionStatus as ChatSessionStatus, type ChatSessionWorkflowParam as ChatSessionWorkflowParam, type ChatKitAttachment as ChatKitAttachment, type ChatKitResponseOutputText as ChatKitResponseOutputText, type ChatKitThread as ChatKitThread, type ChatKitThreadAssistantMessageItem as ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList as ChatKitThreadItemList, type ChatKitThreadUserMessageItem as ChatKitThreadUserMessageItem, type ChatKitWidgetItem as ChatKitWidgetItem, type ThreadDeleteResponse as ThreadDeleteResponse, type ChatKitThreadsPage as ChatKitThreadsPage, type ChatKitThreadItemListDataPage as ChatKitThreadItemListDataPage, type ThreadListParams as ThreadListParams, type ThreadListItemsParams as ThreadListItemsParams, };
}
//# sourceMappingURL=threads.d.mts.map
File diff suppressed because one or more lines are too long
+811
View File
@@ -0,0 +1,811 @@
import { APIResource } from "../../../core/resource.js";
import * as ChatKitAPI from "./chatkit.js";
import { APIPromise } from "../../../core/api-promise.js";
import { ConversationCursorPage, type ConversationCursorPageParams, PagePromise } from "../../../core/pagination.js";
import { RequestOptions } from "../../../internal/request-options.js";
export declare class Threads extends APIResource {
/**
* Retrieve a ChatKit thread by its identifier.
*
* @example
* ```ts
* const chatkitThread =
* await client.beta.chatkit.threads.retrieve('cthr_123');
* ```
*/
retrieve(threadID: string, options?: RequestOptions): APIPromise<ChatKitThread>;
/**
* List ChatKit threads with optional pagination and user filters.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const chatkitThread of client.beta.chatkit.threads.list()) {
* // ...
* }
* ```
*/
list(query?: ThreadListParams | null | undefined, options?: RequestOptions): PagePromise<ChatKitThreadsPage, ChatKitThread>;
/**
* Delete a ChatKit thread along with its items and stored attachments.
*
* @example
* ```ts
* const thread = await client.beta.chatkit.threads.delete(
* 'cthr_123',
* );
* ```
*/
delete(threadID: string, options?: RequestOptions): APIPromise<ThreadDeleteResponse>;
/**
* List items that belong to a ChatKit thread.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const thread of client.beta.chatkit.threads.listItems(
* 'cthr_123',
* )) {
* // ...
* }
* ```
*/
listItems(threadID: string, query?: ThreadListItemsParams | null | undefined, options?: RequestOptions): PagePromise<ChatKitThreadItemListDataPage, ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
}
export type ChatKitThreadsPage = ConversationCursorPage<ChatKitThread>;
export type ChatKitThreadItemListDataPage = ConversationCursorPage<ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
/**
* Represents a ChatKit session and its resolved configuration.
*/
export interface ChatSession {
/**
* Identifier for the ChatKit session.
*/
id: string;
/**
* Resolved ChatKit feature configuration for the session.
*/
chatkit_configuration: ChatSessionChatKitConfiguration;
/**
* Ephemeral client secret that authenticates session requests.
*/
client_secret: string;
/**
* Unix timestamp (in seconds) for when the session expires.
*/
expires_at: number;
/**
* Convenience copy of the per-minute request limit.
*/
max_requests_per_1_minute: number;
/**
* Type discriminator that is always `chatkit.session`.
*/
object: 'chatkit.session';
/**
* Resolved rate limit values.
*/
rate_limits: ChatSessionRateLimits;
/**
* Current lifecycle state of the session.
*/
status: ChatSessionStatus;
/**
* User identifier associated with the session.
*/
user: string;
/**
* Workflow metadata for the session.
*/
workflow: ChatKitAPI.ChatKitWorkflow;
}
/**
* Automatic thread title preferences for the session.
*/
export interface ChatSessionAutomaticThreadTitling {
/**
* Whether automatic thread titling is enabled.
*/
enabled: boolean;
}
/**
* ChatKit configuration for the session.
*/
export interface ChatSessionChatKitConfiguration {
/**
* Automatic thread titling preferences.
*/
automatic_thread_titling: ChatSessionAutomaticThreadTitling;
/**
* Upload settings for the session.
*/
file_upload: ChatSessionFileUpload;
/**
* History retention configuration.
*/
history: ChatSessionHistory;
}
/**
* Optional per-session configuration settings for ChatKit behavior.
*/
export interface ChatSessionChatKitConfigurationParam {
/**
* Configuration for automatic thread titling. When omitted, automatic thread
* titling is enabled by default.
*/
automatic_thread_titling?: ChatSessionChatKitConfigurationParam.AutomaticThreadTitling;
/**
* Configuration for upload enablement and limits. When omitted, uploads are
* disabled by default (max_files 10, max_file_size 512 MB).
*/
file_upload?: ChatSessionChatKitConfigurationParam.FileUpload;
/**
* Configuration for chat history retention. When omitted, history is enabled by
* default with no limit on recent_threads (null).
*/
history?: ChatSessionChatKitConfigurationParam.History;
}
export declare namespace ChatSessionChatKitConfigurationParam {
/**
* Configuration for automatic thread titling. When omitted, automatic thread
* titling is enabled by default.
*/
interface AutomaticThreadTitling {
/**
* Enable automatic thread title generation. Defaults to true.
*/
enabled?: boolean;
}
/**
* Configuration for upload enablement and limits. When omitted, uploads are
* disabled by default (max_files 10, max_file_size 512 MB).
*/
interface FileUpload {
/**
* Enable uploads for this session. Defaults to false.
*/
enabled?: boolean;
/**
* Maximum size in megabytes for each uploaded file. Defaults to 512 MB, which is
* the maximum allowable size.
*/
max_file_size?: number;
/**
* Maximum number of files that can be uploaded to the session. Defaults to 10.
*/
max_files?: number;
}
/**
* Configuration for chat history retention. When omitted, history is enabled by
* default with no limit on recent_threads (null).
*/
interface History {
/**
* Enables chat users to access previous ChatKit threads. Defaults to true.
*/
enabled?: boolean;
/**
* Number of recent ChatKit threads users have access to. Defaults to unlimited
* when unset.
*/
recent_threads?: number;
}
}
/**
* Controls when the session expires relative to an anchor timestamp.
*/
export interface ChatSessionExpiresAfterParam {
/**
* Base timestamp used to calculate expiration. Currently fixed to `created_at`.
*/
anchor: 'created_at';
/**
* Number of seconds after the anchor when the session expires.
*/
seconds: number;
}
/**
* Upload permissions and limits applied to the session.
*/
export interface ChatSessionFileUpload {
/**
* Indicates if uploads are enabled for the session.
*/
enabled: boolean;
/**
* Maximum upload size in megabytes.
*/
max_file_size: number | null;
/**
* Maximum number of uploads allowed during the session.
*/
max_files: number | null;
}
/**
* History retention preferences returned for the session.
*/
export interface ChatSessionHistory {
/**
* Indicates if chat history is persisted for the session.
*/
enabled: boolean;
/**
* Number of prior threads surfaced in history views. Defaults to null when all
* history is retained.
*/
recent_threads: number | null;
}
/**
* Active per-minute request limit for the session.
*/
export interface ChatSessionRateLimits {
/**
* Maximum allowed requests per one-minute window.
*/
max_requests_per_1_minute: number;
}
/**
* Controls request rate limits for the session.
*/
export interface ChatSessionRateLimitsParam {
/**
* Maximum number of requests allowed per minute for the session. Defaults to 10.
*/
max_requests_per_1_minute?: number;
}
export type ChatSessionStatus = 'active' | 'expired' | 'cancelled';
/**
* Workflow reference and overrides applied to the chat session.
*/
export interface ChatSessionWorkflowParam {
/**
* Identifier for the workflow invoked by the session.
*/
id: string;
/**
* State variables forwarded to the workflow. Keys may be up to 64 characters,
* values must be primitive types, and the map defaults to an empty object.
*/
state_variables?: {
[key: string]: string | boolean | number;
};
/**
* Optional tracing overrides for the workflow invocation. When omitted, tracing is
* enabled by default.
*/
tracing?: ChatSessionWorkflowParam.Tracing;
/**
* Specific workflow version to run. Defaults to the latest deployed version.
*/
version?: string;
}
export declare namespace ChatSessionWorkflowParam {
/**
* Optional tracing overrides for the workflow invocation. When omitted, tracing is
* enabled by default.
*/
interface Tracing {
/**
* Whether tracing is enabled during the session. Defaults to true.
*/
enabled?: boolean;
}
}
/**
* Attachment metadata included on thread items.
*/
export interface ChatKitAttachment {
/**
* Identifier for the attachment.
*/
id: string;
/**
* MIME type of the attachment.
*/
mime_type: string;
/**
* Original display name for the attachment.
*/
name: string;
/**
* Preview URL for rendering the attachment inline.
*/
preview_url: string | null;
/**
* Attachment discriminator.
*/
type: 'image' | 'file';
}
/**
* Assistant response text accompanied by optional annotations.
*/
export interface ChatKitResponseOutputText {
/**
* Ordered list of annotations attached to the response text.
*/
annotations: Array<ChatKitResponseOutputText.File | ChatKitResponseOutputText.URL>;
/**
* Assistant generated text.
*/
text: string;
/**
* Type discriminator that is always `output_text`.
*/
type: 'output_text';
}
export declare namespace ChatKitResponseOutputText {
/**
* Annotation that references an uploaded file.
*/
interface File {
/**
* File attachment referenced by the annotation.
*/
source: File.Source;
/**
* Type discriminator that is always `file` for this annotation.
*/
type: 'file';
}
namespace File {
/**
* File attachment referenced by the annotation.
*/
interface Source {
/**
* Filename referenced by the annotation.
*/
filename: string;
/**
* Type discriminator that is always `file`.
*/
type: 'file';
}
}
/**
* Annotation that references a URL.
*/
interface URL {
/**
* URL referenced by the annotation.
*/
source: URL.Source;
/**
* Type discriminator that is always `url` for this annotation.
*/
type: 'url';
}
namespace URL {
/**
* URL referenced by the annotation.
*/
interface Source {
/**
* Type discriminator that is always `url`.
*/
type: 'url';
/**
* URL referenced by the annotation.
*/
url: string;
}
}
}
/**
* Represents a ChatKit thread and its current status.
*/
export interface ChatKitThread {
/**
* Identifier of the thread.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the thread was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread`.
*/
object: 'chatkit.thread';
/**
* Current status for the thread. Defaults to `active` for newly created threads.
*/
status: ChatKitThread.Active | ChatKitThread.Locked | ChatKitThread.Closed;
/**
* Optional human-readable title for the thread. Defaults to null when no title has
* been generated.
*/
title: string | null;
/**
* Free-form string that identifies your end user who owns the thread.
*/
user: string;
}
export declare namespace ChatKitThread {
/**
* Indicates that a thread is active.
*/
interface Active {
/**
* Status discriminator that is always `active`.
*/
type: 'active';
}
/**
* Indicates that a thread is locked and cannot accept new input.
*/
interface Locked {
/**
* Reason that the thread was locked. Defaults to null when no reason is recorded.
*/
reason: string | null;
/**
* Status discriminator that is always `locked`.
*/
type: 'locked';
}
/**
* Indicates that a thread has been closed.
*/
interface Closed {
/**
* Reason that the thread was closed. Defaults to null when no reason is recorded.
*/
reason: string | null;
/**
* Status discriminator that is always `closed`.
*/
type: 'closed';
}
}
/**
* Assistant-authored message within a thread.
*/
export interface ChatKitThreadAssistantMessageItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Ordered assistant response segments.
*/
content: Array<ChatKitResponseOutputText>;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.assistant_message`.
*/
type: 'chatkit.assistant_message';
}
/**
* A paginated list of thread items rendered for the ChatKit API.
*/
export interface ChatKitThreadItemList {
/**
* A list of items
*/
data: Array<ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
/**
* The ID of the first item in the list.
*/
first_id: string | null;
/**
* Whether there are more items available.
*/
has_more: boolean;
/**
* The ID of the last item in the list.
*/
last_id: string | null;
/**
* The type of object returned, must be `list`.
*/
object: 'list';
}
export declare namespace ChatKitThreadItemList {
/**
* Record of a client side tool invocation initiated by the assistant.
*/
interface ChatKitClientToolCall {
/**
* Identifier of the thread item.
*/
id: string;
/**
* JSON-encoded arguments that were sent to the tool.
*/
arguments: string;
/**
* Identifier for the client tool call.
*/
call_id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Tool name that was invoked.
*/
name: string;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* JSON-encoded output captured from the tool. Defaults to null while execution is
* in progress.
*/
output: string | null;
/**
* Execution status for the tool call.
*/
status: 'in_progress' | 'completed';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.client_tool_call`.
*/
type: 'chatkit.client_tool_call';
}
/**
* Task emitted by the workflow to show progress and status updates.
*/
interface ChatKitTask {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Optional heading for the task. Defaults to null when not provided.
*/
heading: string | null;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Optional summary that describes the task. Defaults to null when omitted.
*/
summary: string | null;
/**
* Subtype for the task.
*/
task_type: 'custom' | 'thought';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.task`.
*/
type: 'chatkit.task';
}
/**
* Collection of workflow tasks grouped together in the thread.
*/
interface ChatKitTaskGroup {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Tasks included in the group.
*/
tasks: Array<ChatKitTaskGroup.Task>;
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.task_group`.
*/
type: 'chatkit.task_group';
}
namespace ChatKitTaskGroup {
/**
* Task entry that appears within a TaskGroup.
*/
interface Task {
/**
* Optional heading for the grouped task. Defaults to null when not provided.
*/
heading: string | null;
/**
* Optional summary that describes the grouped task. Defaults to null when omitted.
*/
summary: string | null;
/**
* Subtype for the grouped task.
*/
type: 'custom' | 'thought';
}
}
}
/**
* User-authored messages within a thread.
*/
export interface ChatKitThreadUserMessageItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Attachments associated with the user message. Defaults to an empty list.
*/
attachments: Array<ChatKitAttachment>;
/**
* Ordered content elements supplied by the user.
*/
content: Array<ChatKitThreadUserMessageItem.InputText | ChatKitThreadUserMessageItem.QuotedText>;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Inference overrides applied to the message. Defaults to null when unset.
*/
inference_options: ChatKitThreadUserMessageItem.InferenceOptions | null;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
type: 'chatkit.user_message';
}
export declare namespace ChatKitThreadUserMessageItem {
/**
* Text block that a user contributed to the thread.
*/
interface InputText {
/**
* Plain-text content supplied by the user.
*/
text: string;
/**
* Type discriminator that is always `input_text`.
*/
type: 'input_text';
}
/**
* Quoted snippet that the user referenced in their message.
*/
interface QuotedText {
/**
* Quoted text content.
*/
text: string;
/**
* Type discriminator that is always `quoted_text`.
*/
type: 'quoted_text';
}
/**
* Inference overrides applied to the message. Defaults to null when unset.
*/
interface InferenceOptions {
/**
* Model name that generated the response. Defaults to null when using the session
* default.
*/
model: string | null;
/**
* Preferred tool to invoke. Defaults to null when ChatKit should auto-select.
*/
tool_choice: InferenceOptions.ToolChoice | null;
}
namespace InferenceOptions {
/**
* Preferred tool to invoke. Defaults to null when ChatKit should auto-select.
*/
interface ToolChoice {
/**
* Identifier of the requested tool.
*/
id: string;
}
}
}
/**
* Thread item that renders a widget payload.
*/
export interface ChatKitWidgetItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.widget`.
*/
type: 'chatkit.widget';
/**
* Serialized widget payload rendered in the UI.
*/
widget: string;
}
/**
* Confirmation payload returned after deleting a thread.
*/
export interface ThreadDeleteResponse {
/**
* Identifier of the deleted thread.
*/
id: string;
/**
* Indicates that the thread has been deleted.
*/
deleted: boolean;
/**
* Type discriminator that is always `chatkit.thread.deleted`.
*/
object: 'chatkit.thread.deleted';
}
export interface ThreadListParams extends ConversationCursorPageParams {
/**
* List items created before this thread item ID. Defaults to null for the newest
* results.
*/
before?: string;
/**
* Sort order for results by creation time. Defaults to `desc`.
*/
order?: 'asc' | 'desc';
/**
* Filter threads that belong to this user identifier. Defaults to null to return
* all users.
*/
user?: string;
}
export interface ThreadListItemsParams extends ConversationCursorPageParams {
/**
* List items created before this thread item ID. Defaults to null for the newest
* results.
*/
before?: string;
/**
* Sort order for results by creation time. Defaults to `desc`.
*/
order?: 'asc' | 'desc';
}
export declare namespace Threads {
export { type ChatSession as ChatSession, type ChatSessionAutomaticThreadTitling as ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration as ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam as ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam as ChatSessionExpiresAfterParam, type ChatSessionFileUpload as ChatSessionFileUpload, type ChatSessionHistory as ChatSessionHistory, type ChatSessionRateLimits as ChatSessionRateLimits, type ChatSessionRateLimitsParam as ChatSessionRateLimitsParam, type ChatSessionStatus as ChatSessionStatus, type ChatSessionWorkflowParam as ChatSessionWorkflowParam, type ChatKitAttachment as ChatKitAttachment, type ChatKitResponseOutputText as ChatKitResponseOutputText, type ChatKitThread as ChatKitThread, type ChatKitThreadAssistantMessageItem as ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList as ChatKitThreadItemList, type ChatKitThreadUserMessageItem as ChatKitThreadUserMessageItem, type ChatKitWidgetItem as ChatKitWidgetItem, type ThreadDeleteResponse as ThreadDeleteResponse, type ChatKitThreadsPage as ChatKitThreadsPage, type ChatKitThreadItemListDataPage as ChatKitThreadItemListDataPage, type ThreadListParams as ThreadListParams, type ThreadListItemsParams as ThreadListItemsParams, };
}
//# sourceMappingURL=threads.d.ts.map
File diff suppressed because one or more lines are too long
+85
View File
@@ -0,0 +1,85 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Threads = void 0;
const resource_1 = require("../../../core/resource.js");
const pagination_1 = require("../../../core/pagination.js");
const headers_1 = require("../../../internal/headers.js");
const path_1 = require("../../../internal/utils/path.js");
class Threads extends resource_1.APIResource {
/**
* Retrieve a ChatKit thread by its identifier.
*
* @example
* ```ts
* const chatkitThread =
* await client.beta.chatkit.threads.retrieve('cthr_123');
* ```
*/
retrieve(threadID, options) {
return this._client.get((0, path_1.path) `/chatkit/threads/${threadID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* List ChatKit threads with optional pagination and user filters.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const chatkitThread of client.beta.chatkit.threads.list()) {
* // ...
* }
* ```
*/
list(query = {}, options) {
return this._client.getAPIList('/chatkit/threads', (pagination_1.ConversationCursorPage), {
query,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Delete a ChatKit thread along with its items and stored attachments.
*
* @example
* ```ts
* const thread = await client.beta.chatkit.threads.delete(
* 'cthr_123',
* );
* ```
*/
delete(threadID, options) {
return this._client.delete((0, path_1.path) `/chatkit/threads/${threadID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* List items that belong to a ChatKit thread.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const thread of client.beta.chatkit.threads.listItems(
* 'cthr_123',
* )) {
* // ...
* }
* ```
*/
listItems(threadID, query = {}, options) {
return this._client.getAPIList((0, path_1.path) `/chatkit/threads/${threadID}/items`, (pagination_1.ConversationCursorPage), {
query,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
exports.Threads = Threads;
//# sourceMappingURL=threads.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/threads.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wDAAqD;AAGrD,4DAIkC;AAClC,0DAAyD;AAEzD,0DAAoD;AAEpD,MAAa,OAAQ,SAAQ,sBAAW;IACtC;;;;;;;;OAQG;IACH,QAAQ,CAAC,QAAgB,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,oBAAoB,QAAQ,EAAE,EAAE;YAC1D,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,CACF,QAA6C,EAAE,EAC/C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAA,mCAAqC,CAAA,EAAE;YACxF,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,QAAgB,EAAE,OAAwB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAA,WAAI,EAAA,oBAAoB,QAAQ,EAAE,EAAE;YAC7D,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,SAAS,CACP,QAAgB,EAChB,QAAkD,EAAE,EACpD,OAAwB;QAUxB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAC5B,IAAA,WAAI,EAAA,oBAAoB,QAAQ,QAAQ,EACxC,CAAA,mCAOC,CAAA,EACD;YACE,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CACF,CAAC;IACJ,CAAC;CACF;AAvGD,0BAuGC"}
+81
View File
@@ -0,0 +1,81 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { ConversationCursorPage, } from "../../../core/pagination.mjs";
import { buildHeaders } from "../../../internal/headers.mjs";
import { path } from "../../../internal/utils/path.mjs";
export class Threads extends APIResource {
/**
* Retrieve a ChatKit thread by its identifier.
*
* @example
* ```ts
* const chatkitThread =
* await client.beta.chatkit.threads.retrieve('cthr_123');
* ```
*/
retrieve(threadID, options) {
return this._client.get(path `/chatkit/threads/${threadID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* List ChatKit threads with optional pagination and user filters.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const chatkitThread of client.beta.chatkit.threads.list()) {
* // ...
* }
* ```
*/
list(query = {}, options) {
return this._client.getAPIList('/chatkit/threads', (ConversationCursorPage), {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Delete a ChatKit thread along with its items and stored attachments.
*
* @example
* ```ts
* const thread = await client.beta.chatkit.threads.delete(
* 'cthr_123',
* );
* ```
*/
delete(threadID, options) {
return this._client.delete(path `/chatkit/threads/${threadID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* List items that belong to a ChatKit thread.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const thread of client.beta.chatkit.threads.listItems(
* 'cthr_123',
* )) {
* // ...
* }
* ```
*/
listItems(threadID, query = {}, options) {
return this._client.getAPIList(path `/chatkit/threads/${threadID}/items`, (ConversationCursorPage), {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
//# sourceMappingURL=threads.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"threads.mjs","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/threads.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AAGrD,OAAO,EACL,sBAAsB,GAGvB,qCAAiC;AAClC,OAAO,EAAE,YAAY,EAAE,sCAAkC;AAEzD,OAAO,EAAE,IAAI,EAAE,yCAAqC;AAEpD,MAAM,OAAO,OAAQ,SAAQ,WAAW;IACtC;;;;;;;;OAQG;IACH,QAAQ,CAAC,QAAgB,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,oBAAoB,QAAQ,EAAE,EAAE;YAC1D,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,CACF,QAA6C,EAAE,EAC/C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAA,sBAAqC,CAAA,EAAE;YACxF,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,QAAgB,EAAE,OAAwB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,oBAAoB,QAAQ,EAAE,EAAE;YAC7D,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,SAAS,CACP,QAAgB,EAChB,QAAkD,EAAE,EACpD,OAAwB;QAUxB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAC5B,IAAI,CAAA,oBAAoB,QAAQ,QAAQ,EACxC,CAAA,sBAOC,CAAA,EACD;YACE,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CACF,CAAC;IACJ,CAAC;CACF"}
+6
View File
@@ -0,0 +1,6 @@
export { Assistants, type Assistant, type AssistantDeleted, type AssistantStreamEvent, type AssistantTool, type CodeInterpreterTool, type FileSearchTool, type FunctionTool, type MessageStreamEvent, type RunStepStreamEvent, type RunStreamEvent, type ThreadStreamEvent, type AssistantCreateParams, type AssistantUpdateParams, type AssistantListParams, type AssistantsPage, } from "./assistants.mjs";
export { Beta } from "./beta.mjs";
export { Realtime } from "./realtime/index.mjs";
export { ChatKit, type ChatKitWorkflow } from "./chatkit/index.mjs";
export { Threads, type AssistantResponseFormatOption, type AssistantToolChoice, type AssistantToolChoiceFunction, type AssistantToolChoiceOption, type Thread, type ThreadDeleted, type ThreadCreateParams, type ThreadUpdateParams, type ThreadCreateAndRunParams, type ThreadCreateAndRunParamsNonStreaming, type ThreadCreateAndRunParamsStreaming, type ThreadCreateAndRunPollParams, type ThreadCreateAndRunStreamParams, } from "./threads/index.mjs";
//# sourceMappingURL=index.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/resources/beta/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,yBAAqB;AACtB,OAAO,EAAE,IAAI,EAAE,mBAAe;AAC9B,OAAO,EAAE,QAAQ,EAAE,6BAAyB;AAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,eAAe,EAAE,4BAAwB;AAChE,OAAO,EACL,OAAO,EACP,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,oCAAoC,EACzC,KAAK,iCAAiC,EACtC,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,GACpC,4BAAwB"}
+6
View File
@@ -0,0 +1,6 @@
export { Assistants, type Assistant, type AssistantDeleted, type AssistantStreamEvent, type AssistantTool, type CodeInterpreterTool, type FileSearchTool, type FunctionTool, type MessageStreamEvent, type RunStepStreamEvent, type RunStreamEvent, type ThreadStreamEvent, type AssistantCreateParams, type AssistantUpdateParams, type AssistantListParams, type AssistantsPage, } from "./assistants.js";
export { Beta } from "./beta.js";
export { Realtime } from "./realtime/index.js";
export { ChatKit, type ChatKitWorkflow } from "./chatkit/index.js";
export { Threads, type AssistantResponseFormatOption, type AssistantToolChoice, type AssistantToolChoiceFunction, type AssistantToolChoiceOption, type Thread, type ThreadDeleted, type ThreadCreateParams, type ThreadUpdateParams, type ThreadCreateAndRunParams, type ThreadCreateAndRunParamsNonStreaming, type ThreadCreateAndRunParamsStreaming, type ThreadCreateAndRunPollParams, type ThreadCreateAndRunStreamParams, } from "./threads/index.js";
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/beta/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,wBAAqB;AACtB,OAAO,EAAE,IAAI,EAAE,kBAAe;AAC9B,OAAO,EAAE,QAAQ,EAAE,4BAAyB;AAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,eAAe,EAAE,2BAAwB;AAChE,OAAO,EACL,OAAO,EACP,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,oCAAoC,EACzC,KAAK,iCAAiC,EACtC,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,GACpC,2BAAwB"}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Threads = exports.ChatKit = exports.Realtime = exports.Beta = exports.Assistants = void 0;
var assistants_1 = require("./assistants.js");
Object.defineProperty(exports, "Assistants", { enumerable: true, get: function () { return assistants_1.Assistants; } });
var beta_1 = require("./beta.js");
Object.defineProperty(exports, "Beta", { enumerable: true, get: function () { return beta_1.Beta; } });
var index_1 = require("./realtime/index.js");
Object.defineProperty(exports, "Realtime", { enumerable: true, get: function () { return index_1.Realtime; } });
var index_2 = require("./chatkit/index.js");
Object.defineProperty(exports, "ChatKit", { enumerable: true, get: function () { return index_2.ChatKit; } });
var index_3 = require("./threads/index.js");
Object.defineProperty(exports, "Threads", { enumerable: true, get: function () { return index_3.Threads; } });
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/beta/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,8CAiBsB;AAhBpB,wGAAA,UAAU,OAAA;AAiBZ,kCAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,6CAA4C;AAAnC,iGAAA,QAAQ,OAAA;AACjB,4CAAgE;AAAvD,gGAAA,OAAO,OAAA;AAChB,4CAeyB;AAdvB,gGAAA,OAAO,OAAA"}
+7
View File
@@ -0,0 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export { Assistants, } from "./assistants.mjs";
export { Beta } from "./beta.mjs";
export { Realtime } from "./realtime/index.mjs";
export { ChatKit } from "./chatkit/index.mjs";
export { Threads, } from "./threads/index.mjs";
//# sourceMappingURL=index.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/resources/beta/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EACL,UAAU,GAgBX,yBAAqB;AACtB,OAAO,EAAE,IAAI,EAAE,mBAAe;AAC9B,OAAO,EAAE,QAAQ,EAAE,6BAAyB;AAC5C,OAAO,EAAE,OAAO,EAAwB,4BAAwB;AAChE,OAAO,EACL,OAAO,GAcR,4BAAwB"}
+2
View File
@@ -0,0 +1,2 @@
export * from "./realtime/index.mjs";
//# sourceMappingURL=realtime.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"realtime.d.mts","sourceRoot":"","sources":["../../src/resources/beta/realtime.ts"],"names":[],"mappings":"AAEA,qCAAiC"}
+2
View File
@@ -0,0 +1,2 @@
export * from "./realtime/index.js";
//# sourceMappingURL=realtime.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../../src/resources/beta/realtime.ts"],"names":[],"mappings":"AAEA,oCAAiC"}
+6
View File
@@ -0,0 +1,6 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("../../internal/tslib.js");
tslib_1.__exportStar(require("./realtime/index.js"), exports);
//# sourceMappingURL=realtime.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"realtime.js","sourceRoot":"","sources":["../../src/resources/beta/realtime.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,8DAAiC"}
+3
View File
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export * from "./realtime/index.mjs";
//# sourceMappingURL=realtime.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"realtime.mjs","sourceRoot":"","sources":["../../src/resources/beta/realtime.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,qCAAiC"}
+4
View File
@@ -0,0 +1,4 @@
export { Realtime } from "./realtime.mjs";
export { Sessions, type Session, type SessionCreateResponse, type SessionCreateParams } from "./sessions.mjs";
export { TranscriptionSessions, type TranscriptionSession, type TranscriptionSessionCreateParams, } from "./transcription-sessions.mjs";
//# sourceMappingURL=index.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/realtime/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,uBAAmB;AACtC,OAAO,EAAE,QAAQ,EAAE,KAAK,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,mBAAmB,EAAE,uBAAmB;AAC1G,OAAO,EACL,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,GACtC,qCAAiC"}
+4
View File
@@ -0,0 +1,4 @@
export { Realtime } from "./realtime.js";
export { Sessions, type Session, type SessionCreateResponse, type SessionCreateParams } from "./sessions.js";
export { TranscriptionSessions, type TranscriptionSession, type TranscriptionSessionCreateParams, } from "./transcription-sessions.js";
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/realtime/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,sBAAmB;AACtC,OAAO,EAAE,QAAQ,EAAE,KAAK,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,mBAAmB,EAAE,sBAAmB;AAC1G,OAAO,EACL,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,GACtC,oCAAiC"}
+11
View File
@@ -0,0 +1,11 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TranscriptionSessions = exports.Sessions = exports.Realtime = void 0;
var realtime_1 = require("./realtime.js");
Object.defineProperty(exports, "Realtime", { enumerable: true, get: function () { return realtime_1.Realtime; } });
var sessions_1 = require("./sessions.js");
Object.defineProperty(exports, "Sessions", { enumerable: true, get: function () { return sessions_1.Sessions; } });
var transcription_sessions_1 = require("./transcription-sessions.js");
Object.defineProperty(exports, "TranscriptionSessions", { enumerable: true, get: function () { return transcription_sessions_1.TranscriptionSessions; } });
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/beta/realtime/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,0CAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,0CAA0G;AAAjG,oGAAA,QAAQ,OAAA;AACjB,sEAIkC;AAHhC,+HAAA,qBAAqB,OAAA"}
+5
View File
@@ -0,0 +1,5 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export { Realtime } from "./realtime.mjs";
export { Sessions } from "./sessions.mjs";
export { TranscriptionSessions, } from "./transcription-sessions.mjs";
//# sourceMappingURL=index.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/resources/beta/realtime/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,QAAQ,EAAE,uBAAmB;AACtC,OAAO,EAAE,QAAQ,EAAsE,uBAAmB;AAC1G,OAAO,EACL,qBAAqB,GAGtB,qCAAiC"}
+2332
View File
@@ -0,0 +1,2332 @@
import { APIResource } from "../../../core/resource.mjs";
import * as RealtimeAPI from "./realtime.mjs";
import * as Shared from "../../shared.mjs";
import * as SessionsAPI from "./sessions.mjs";
import { Session as SessionsAPISession, SessionCreateParams, SessionCreateResponse, Sessions } from "./sessions.mjs";
import * as TranscriptionSessionsAPI from "./transcription-sessions.mjs";
import { TranscriptionSession, TranscriptionSessionCreateParams, TranscriptionSessions } from "./transcription-sessions.mjs";
/**
* @deprecated Realtime has now launched and is generally available. The old beta API is now deprecated.
*/
export declare class Realtime extends APIResource {
sessions: SessionsAPI.Sessions;
transcriptionSessions: TranscriptionSessionsAPI.TranscriptionSessions;
}
/**
* Returned when a conversation is created. Emitted right after session creation.
*/
export interface ConversationCreatedEvent {
/**
* The conversation resource.
*/
conversation: ConversationCreatedEvent.Conversation;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The event type, must be `conversation.created`.
*/
type: 'conversation.created';
}
export declare namespace ConversationCreatedEvent {
/**
* The conversation resource.
*/
interface Conversation {
/**
* The unique ID of the conversation.
*/
id?: string;
/**
* The object type, must be `realtime.conversation`.
*/
object?: 'realtime.conversation';
}
}
/**
* The item to add to the conversation.
*/
export interface ConversationItem {
/**
* The unique ID of the item, this can be generated by the client to help manage
* server-side context, but is not required because the server will generate one if
* not provided.
*/
id?: string;
/**
* The arguments of the function call (for `function_call` items).
*/
arguments?: string;
/**
* The ID of the function call (for `function_call` and `function_call_output`
* items). If passed on a `function_call_output` item, the server will check that a
* `function_call` item with the same ID exists in the conversation history.
*/
call_id?: string;
/**
* The content of the message, applicable for `message` items.
*
* - Message items of role `system` support only `input_text` content
* - Message items of role `user` support `input_text` and `input_audio` content
* - Message items of role `assistant` support `text` content.
*/
content?: Array<ConversationItemContent>;
/**
* The name of the function being called (for `function_call` items).
*/
name?: string;
/**
* Identifier for the API object being returned - always `realtime.item`.
*/
object?: 'realtime.item';
/**
* The output of the function call (for `function_call_output` items).
*/
output?: string;
/**
* The role of the message sender (`user`, `assistant`, `system`), only applicable
* for `message` items.
*/
role?: 'user' | 'assistant' | 'system';
/**
* The status of the item (`completed`, `incomplete`, `in_progress`). These have no
* effect on the conversation, but are accepted for consistency with the
* `conversation.item.created` event.
*/
status?: 'completed' | 'incomplete' | 'in_progress';
/**
* The type of the item (`message`, `function_call`, `function_call_output`).
*/
type?: 'message' | 'function_call' | 'function_call_output';
}
export interface ConversationItemContent {
/**
* ID of a previous conversation item to reference (for `item_reference` content
* types in `response.create` events). These can reference both client and server
* created items.
*/
id?: string;
/**
* Base64-encoded audio bytes, used for `input_audio` content type.
*/
audio?: string;
/**
* The text content, used for `input_text` and `text` content types.
*/
text?: string;
/**
* The transcript of the audio, used for `input_audio` and `audio` content types.
*/
transcript?: string;
/**
* The content type (`input_text`, `input_audio`, `item_reference`, `text`,
* `audio`).
*/
type?: 'input_text' | 'input_audio' | 'item_reference' | 'text' | 'audio';
}
/**
* Add a new Item to the Conversation's context, including messages, function
* calls, and function call responses. This event can be used both to populate a
* "history" of the conversation and to add new items mid-stream, but has the
* current limitation that it cannot populate assistant audio messages.
*
* If successful, the server will respond with a `conversation.item.created` event,
* otherwise an `error` event will be sent.
*/
export interface ConversationItemCreateEvent {
/**
* The item to add to the conversation.
*/
item: ConversationItem;
/**
* The event type, must be `conversation.item.create`.
*/
type: 'conversation.item.create';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
/**
* The ID of the preceding item after which the new item will be inserted. If not
* set, the new item will be appended to the end of the conversation. If set to
* `root`, the new item will be added to the beginning of the conversation. If set
* to an existing ID, it allows an item to be inserted mid-conversation. If the ID
* cannot be found, an error will be returned and the item will not be added.
*/
previous_item_id?: string;
}
/**
* Returned when a conversation item is created. There are several scenarios that
* produce this event:
*
* - The server is generating a Response, which if successful will produce either
* one or two Items, which will be of type `message` (role `assistant`) or type
* `function_call`.
* - The input audio buffer has been committed, either by the client or the server
* (in `server_vad` mode). The server will take the content of the input audio
* buffer and add it to a new user message Item.
* - The client has sent a `conversation.item.create` event to add a new Item to
* the Conversation.
*/
export interface ConversationItemCreatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The item to add to the conversation.
*/
item: ConversationItem;
/**
* The event type, must be `conversation.item.created`.
*/
type: 'conversation.item.created';
/**
* The ID of the preceding item in the Conversation context, allows the client to
* understand the order of the conversation. Can be `null` if the item has no
* predecessor.
*/
previous_item_id?: string | null;
}
/**
* Send this event when you want to remove any item from the conversation history.
* The server will respond with a `conversation.item.deleted` event, unless the
* item does not exist in the conversation history, in which case the server will
* respond with an error.
*/
export interface ConversationItemDeleteEvent {
/**
* The ID of the item to delete.
*/
item_id: string;
/**
* The event type, must be `conversation.item.delete`.
*/
type: 'conversation.item.delete';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Returned when an item in the conversation is deleted by the client with a
* `conversation.item.delete` event. This event is used to synchronize the server's
* understanding of the conversation history with the client's view.
*/
export interface ConversationItemDeletedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item that was deleted.
*/
item_id: string;
/**
* The event type, must be `conversation.item.deleted`.
*/
type: 'conversation.item.deleted';
}
/**
* This event is the output of audio transcription for user audio written to the
* user audio buffer. Transcription begins when the input audio buffer is committed
* by the client or server (in `server_vad` mode). Transcription runs
* asynchronously with Response creation, so this event may come before or after
* the Response events.
*
* Realtime API models accept audio natively, and thus input transcription is a
* separate process run on a separate ASR (Automatic Speech Recognition) model. The
* transcript may diverge somewhat from the model's interpretation, and should be
* treated as a rough guide.
*/
export interface ConversationItemInputAudioTranscriptionCompletedEvent {
/**
* The index of the content part containing the audio.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the user message item containing the audio.
*/
item_id: string;
/**
* The transcribed text.
*/
transcript: string;
/**
* The event type, must be `conversation.item.input_audio_transcription.completed`.
*/
type: 'conversation.item.input_audio_transcription.completed';
/**
* Usage statistics for the transcription.
*/
usage: ConversationItemInputAudioTranscriptionCompletedEvent.TranscriptTextUsageTokens | ConversationItemInputAudioTranscriptionCompletedEvent.TranscriptTextUsageDuration;
/**
* The log probabilities of the transcription.
*/
logprobs?: Array<ConversationItemInputAudioTranscriptionCompletedEvent.Logprob> | null;
}
export declare namespace ConversationItemInputAudioTranscriptionCompletedEvent {
/**
* Usage statistics for models billed by token usage.
*/
interface TranscriptTextUsageTokens {
/**
* Number of input tokens billed for this request.
*/
input_tokens: number;
/**
* Number of output tokens generated.
*/
output_tokens: number;
/**
* Total number of tokens used (input + output).
*/
total_tokens: number;
/**
* The type of the usage object. Always `tokens` for this variant.
*/
type: 'tokens';
/**
* Details about the input tokens billed for this request.
*/
input_token_details?: TranscriptTextUsageTokens.InputTokenDetails;
}
namespace TranscriptTextUsageTokens {
/**
* Details about the input tokens billed for this request.
*/
interface InputTokenDetails {
/**
* Number of audio tokens billed for this request.
*/
audio_tokens?: number;
/**
* Number of text tokens billed for this request.
*/
text_tokens?: number;
}
}
/**
* Usage statistics for models billed by audio input duration.
*/
interface TranscriptTextUsageDuration {
/**
* Duration of the input audio in seconds.
*/
seconds: number;
/**
* The type of the usage object. Always `duration` for this variant.
*/
type: 'duration';
}
/**
* A log probability object.
*/
interface Logprob {
/**
* The token that was used to generate the log probability.
*/
token: string;
/**
* The bytes that were used to generate the log probability.
*/
bytes: Array<number>;
/**
* The log probability of the token.
*/
logprob: number;
}
}
/**
* Returned when the text value of an input audio transcription content part is
* updated.
*/
export interface ConversationItemInputAudioTranscriptionDeltaEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The event type, must be `conversation.item.input_audio_transcription.delta`.
*/
type: 'conversation.item.input_audio_transcription.delta';
/**
* The index of the content part in the item's content array.
*/
content_index?: number;
/**
* The text delta.
*/
delta?: string;
/**
* The log probabilities of the transcription.
*/
logprobs?: Array<ConversationItemInputAudioTranscriptionDeltaEvent.Logprob> | null;
}
export declare namespace ConversationItemInputAudioTranscriptionDeltaEvent {
/**
* A log probability object.
*/
interface Logprob {
/**
* The token that was used to generate the log probability.
*/
token: string;
/**
* The bytes that were used to generate the log probability.
*/
bytes: Array<number>;
/**
* The log probability of the token.
*/
logprob: number;
}
}
/**
* Returned when input audio transcription is configured, and a transcription
* request for a user message failed. These events are separate from other `error`
* events so that the client can identify the related Item.
*/
export interface ConversationItemInputAudioTranscriptionFailedEvent {
/**
* The index of the content part containing the audio.
*/
content_index: number;
/**
* Details of the transcription error.
*/
error: ConversationItemInputAudioTranscriptionFailedEvent.Error;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the user message item.
*/
item_id: string;
/**
* The event type, must be `conversation.item.input_audio_transcription.failed`.
*/
type: 'conversation.item.input_audio_transcription.failed';
}
export declare namespace ConversationItemInputAudioTranscriptionFailedEvent {
/**
* Details of the transcription error.
*/
interface Error {
/**
* Error code, if any.
*/
code?: string;
/**
* A human-readable error message.
*/
message?: string;
/**
* Parameter related to the error, if any.
*/
param?: string;
/**
* The type of error.
*/
type?: string;
}
}
/**
* Send this event when you want to retrieve the server's representation of a
* specific item in the conversation history. This is useful, for example, to
* inspect user audio after noise cancellation and VAD. The server will respond
* with a `conversation.item.retrieved` event, unless the item does not exist in
* the conversation history, in which case the server will respond with an error.
*/
export interface ConversationItemRetrieveEvent {
/**
* The ID of the item to retrieve.
*/
item_id: string;
/**
* The event type, must be `conversation.item.retrieve`.
*/
type: 'conversation.item.retrieve';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Send this event to truncate a previous assistant messages audio. The server
* will produce audio faster than realtime, so this event is useful when the user
* interrupts to truncate audio that has already been sent to the client but not
* yet played. This will synchronize the server's understanding of the audio with
* the client's playback.
*
* Truncating audio will delete the server-side text transcript to ensure there is
* not text in the context that hasn't been heard by the user.
*
* If successful, the server will respond with a `conversation.item.truncated`
* event.
*/
export interface ConversationItemTruncateEvent {
/**
* Inclusive duration up to which audio is truncated, in milliseconds. If the
* audio_end_ms is greater than the actual audio duration, the server will respond
* with an error.
*/
audio_end_ms: number;
/**
* The index of the content part to truncate. Set this to 0.
*/
content_index: number;
/**
* The ID of the assistant message item to truncate. Only assistant message items
* can be truncated.
*/
item_id: string;
/**
* The event type, must be `conversation.item.truncate`.
*/
type: 'conversation.item.truncate';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Returned when an earlier assistant audio message item is truncated by the client
* with a `conversation.item.truncate` event. This event is used to synchronize the
* server's understanding of the audio with the client's playback.
*
* This action will truncate the audio and remove the server-side text transcript
* to ensure there is no text in the context that hasn't been heard by the user.
*/
export interface ConversationItemTruncatedEvent {
/**
* The duration up to which the audio was truncated, in milliseconds.
*/
audio_end_ms: number;
/**
* The index of the content part that was truncated.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the assistant message item that was truncated.
*/
item_id: string;
/**
* The event type, must be `conversation.item.truncated`.
*/
type: 'conversation.item.truncated';
}
/**
* The item to add to the conversation.
*/
export interface ConversationItemWithReference {
/**
* For an item of type (`message` | `function_call` | `function_call_output`) this
* field allows the client to assign the unique ID of the item. It is not required
* because the server will generate one if not provided.
*
* For an item of type `item_reference`, this field is required and is a reference
* to any item that has previously existed in the conversation.
*/
id?: string;
/**
* The arguments of the function call (for `function_call` items).
*/
arguments?: string;
/**
* The ID of the function call (for `function_call` and `function_call_output`
* items). If passed on a `function_call_output` item, the server will check that a
* `function_call` item with the same ID exists in the conversation history.
*/
call_id?: string;
/**
* The content of the message, applicable for `message` items.
*
* - Message items of role `system` support only `input_text` content
* - Message items of role `user` support `input_text` and `input_audio` content
* - Message items of role `assistant` support `text` content.
*/
content?: Array<ConversationItemWithReference.Content>;
/**
* The name of the function being called (for `function_call` items).
*/
name?: string;
/**
* Identifier for the API object being returned - always `realtime.item`.
*/
object?: 'realtime.item';
/**
* The output of the function call (for `function_call_output` items).
*/
output?: string;
/**
* The role of the message sender (`user`, `assistant`, `system`), only applicable
* for `message` items.
*/
role?: 'user' | 'assistant' | 'system';
/**
* The status of the item (`completed`, `incomplete`, `in_progress`). These have no
* effect on the conversation, but are accepted for consistency with the
* `conversation.item.created` event.
*/
status?: 'completed' | 'incomplete' | 'in_progress';
/**
* The type of the item (`message`, `function_call`, `function_call_output`,
* `item_reference`).
*/
type?: 'message' | 'function_call' | 'function_call_output' | 'item_reference';
}
export declare namespace ConversationItemWithReference {
interface Content {
/**
* ID of a previous conversation item to reference (for `item_reference` content
* types in `response.create` events). These can reference both client and server
* created items.
*/
id?: string;
/**
* Base64-encoded audio bytes, used for `input_audio` content type.
*/
audio?: string;
/**
* The text content, used for `input_text` and `text` content types.
*/
text?: string;
/**
* The transcript of the audio, used for `input_audio` content type.
*/
transcript?: string;
/**
* The content type (`input_text`, `input_audio`, `item_reference`, `text`).
*/
type?: 'input_text' | 'input_audio' | 'item_reference' | 'text';
}
}
/**
* Returned when an error occurs, which could be a client problem or a server
* problem. Most errors are recoverable and the session will stay open, we
* recommend to implementors to monitor and log error messages by default.
*/
export interface ErrorEvent {
/**
* Details of the error.
*/
error: ErrorEvent.Error;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The event type, must be `error`.
*/
type: 'error';
}
export declare namespace ErrorEvent {
/**
* Details of the error.
*/
interface Error {
/**
* A human-readable error message.
*/
message: string;
/**
* The type of error (e.g., "invalid_request_error", "server_error").
*/
type: string;
/**
* Error code, if any.
*/
code?: string | null;
/**
* The event_id of the client event that caused the error, if applicable.
*/
event_id?: string | null;
/**
* Parameter related to the error, if any.
*/
param?: string | null;
}
}
/**
* Send this event to append audio bytes to the input audio buffer. The audio
* buffer is temporary storage you can write to and later commit. In Server VAD
* mode, the audio buffer is used to detect speech and the server will decide when
* to commit. When Server VAD is disabled, you must commit the audio buffer
* manually.
*
* The client may choose how much audio to place in each event up to a maximum of
* 15 MiB, for example streaming smaller chunks from the client may allow the VAD
* to be more responsive. Unlike made other client events, the server will not send
* a confirmation response to this event.
*/
export interface InputAudioBufferAppendEvent {
/**
* Base64-encoded audio bytes. This must be in the format specified by the
* `input_audio_format` field in the session configuration.
*/
audio: string;
/**
* The event type, must be `input_audio_buffer.append`.
*/
type: 'input_audio_buffer.append';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Send this event to clear the audio bytes in the buffer. The server will respond
* with an `input_audio_buffer.cleared` event.
*/
export interface InputAudioBufferClearEvent {
/**
* The event type, must be `input_audio_buffer.clear`.
*/
type: 'input_audio_buffer.clear';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Returned when the input audio buffer is cleared by the client with a
* `input_audio_buffer.clear` event.
*/
export interface InputAudioBufferClearedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The event type, must be `input_audio_buffer.cleared`.
*/
type: 'input_audio_buffer.cleared';
}
/**
* Send this event to commit the user input audio buffer, which will create a new
* user message item in the conversation. This event will produce an error if the
* input audio buffer is empty. When in Server VAD mode, the client does not need
* to send this event, the server will commit the audio buffer automatically.
*
* Committing the input audio buffer will trigger input audio transcription (if
* enabled in session configuration), but it will not create a response from the
* model. The server will respond with an `input_audio_buffer.committed` event.
*/
export interface InputAudioBufferCommitEvent {
/**
* The event type, must be `input_audio_buffer.commit`.
*/
type: 'input_audio_buffer.commit';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Returned when an input audio buffer is committed, either by the client or
* automatically in server VAD mode. The `item_id` property is the ID of the user
* message item that will be created, thus a `conversation.item.created` event will
* also be sent to the client.
*/
export interface InputAudioBufferCommittedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the user message item that will be created.
*/
item_id: string;
/**
* The event type, must be `input_audio_buffer.committed`.
*/
type: 'input_audio_buffer.committed';
/**
* The ID of the preceding item after which the new item will be inserted. Can be
* `null` if the item has no predecessor.
*/
previous_item_id?: string | null;
}
/**
* Sent by the server when in `server_vad` mode to indicate that speech has been
* detected in the audio buffer. This can happen any time audio is added to the
* buffer (unless speech is already detected). The client may want to use this
* event to interrupt audio playback or provide visual feedback to the user.
*
* The client should expect to receive a `input_audio_buffer.speech_stopped` event
* when speech stops. The `item_id` property is the ID of the user message item
* that will be created when speech stops and will also be included in the
* `input_audio_buffer.speech_stopped` event (unless the client manually commits
* the audio buffer during VAD activation).
*/
export interface InputAudioBufferSpeechStartedEvent {
/**
* Milliseconds from the start of all audio written to the buffer during the
* session when speech was first detected. This will correspond to the beginning of
* audio sent to the model, and thus includes the `prefix_padding_ms` configured in
* the Session.
*/
audio_start_ms: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the user message item that will be created when speech stops.
*/
item_id: string;
/**
* The event type, must be `input_audio_buffer.speech_started`.
*/
type: 'input_audio_buffer.speech_started';
}
/**
* Returned in `server_vad` mode when the server detects the end of speech in the
* audio buffer. The server will also send an `conversation.item.created` event
* with the user message item that is created from the audio buffer.
*/
export interface InputAudioBufferSpeechStoppedEvent {
/**
* Milliseconds since the session started when speech stopped. This will correspond
* to the end of audio sent to the model, and thus includes the
* `min_silence_duration_ms` configured in the Session.
*/
audio_end_ms: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the user message item that will be created.
*/
item_id: string;
/**
* The event type, must be `input_audio_buffer.speech_stopped`.
*/
type: 'input_audio_buffer.speech_stopped';
}
/**
* Emitted at the beginning of a Response to indicate the updated rate limits. When
* a Response is created some tokens will be "reserved" for the output tokens, the
* rate limits shown here reflect that reservation, which is then adjusted
* accordingly once the Response is completed.
*/
export interface RateLimitsUpdatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* List of rate limit information.
*/
rate_limits: Array<RateLimitsUpdatedEvent.RateLimit>;
/**
* The event type, must be `rate_limits.updated`.
*/
type: 'rate_limits.updated';
}
export declare namespace RateLimitsUpdatedEvent {
interface RateLimit {
/**
* The maximum allowed value for the rate limit.
*/
limit?: number;
/**
* The name of the rate limit (`requests`, `tokens`).
*/
name?: 'requests' | 'tokens';
/**
* The remaining value before the limit is reached.
*/
remaining?: number;
/**
* Seconds until the rate limit resets.
*/
reset_seconds?: number;
}
}
/**
* A realtime client event.
*/
export type RealtimeClientEvent = ConversationItemCreateEvent | ConversationItemDeleteEvent | ConversationItemRetrieveEvent | ConversationItemTruncateEvent | InputAudioBufferAppendEvent | InputAudioBufferClearEvent | RealtimeClientEvent.OutputAudioBufferClear | InputAudioBufferCommitEvent | ResponseCancelEvent | ResponseCreateEvent | SessionUpdateEvent | TranscriptionSessionUpdate;
export declare namespace RealtimeClientEvent {
/**
* **WebRTC Only:** Emit to cut off the current audio response. This will trigger
* the server to stop generating audio and emit a `output_audio_buffer.cleared`
* event. This event should be preceded by a `response.cancel` client event to stop
* the generation of the current response.
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
*/
interface OutputAudioBufferClear {
/**
* The event type, must be `output_audio_buffer.clear`.
*/
type: 'output_audio_buffer.clear';
/**
* The unique ID of the client event used for error handling.
*/
event_id?: string;
}
}
/**
* The response resource.
*/
export interface RealtimeResponse {
/**
* The unique ID of the response.
*/
id?: string;
/**
* Which conversation the response is added to, determined by the `conversation`
* field in the `response.create` event. If `auto`, the response will be added to
* the default conversation and the value of `conversation_id` will be an id like
* `conv_1234`. If `none`, the response will not be added to any conversation and
* the value of `conversation_id` will be `null`. If responses are being triggered
* by server VAD, the response will be added to the default conversation, thus the
* `conversation_id` will be an id like `conv_1234`.
*/
conversation_id?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls, that was used in this response.
*/
max_output_tokens?: number | 'inf';
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* The set of modalities the model used to respond. If there are multiple
* modalities, the model will pick one, for example if `modalities` is
* `["text", "audio"]`, the model could be responding in either text or audio.
*/
modalities?: Array<'text' | 'audio'>;
/**
* The object type, must be `realtime.response`.
*/
object?: 'realtime.response';
/**
* The list of output items generated by the response.
*/
output?: Array<ConversationItem>;
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
*/
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* The final status of the response (`completed`, `cancelled`, `failed`, or
* `incomplete`, `in_progress`).
*/
status?: 'completed' | 'cancelled' | 'failed' | 'incomplete' | 'in_progress';
/**
* Additional details about the status.
*/
status_details?: RealtimeResponseStatus;
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
*/
temperature?: number;
/**
* Usage statistics for the Response, this will correspond to billing. A Realtime
* API session will maintain a conversation context and append new Items to the
* Conversation, thus output from previous turns (text and audio tokens) will
* become the input for later turns.
*/
usage?: RealtimeResponseUsage;
/**
* The voice the model used to respond. Current voice options are `alloy`, `ash`,
* `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
/**
* Additional details about the status.
*/
export interface RealtimeResponseStatus {
/**
* A description of the error that caused the response to fail, populated when the
* `status` is `failed`.
*/
error?: RealtimeResponseStatus.Error;
/**
* The reason the Response did not complete. For a `cancelled` Response, one of
* `turn_detected` (the server VAD detected a new start of speech) or
* `client_cancelled` (the client sent a cancel event). For an `incomplete`
* Response, one of `max_output_tokens` or `content_filter` (the server-side safety
* filter activated and cut off the response).
*/
reason?: 'turn_detected' | 'client_cancelled' | 'max_output_tokens' | 'content_filter';
/**
* The type of error that caused the response to fail, corresponding with the
* `status` field (`completed`, `cancelled`, `incomplete`, `failed`).
*/
type?: 'completed' | 'cancelled' | 'incomplete' | 'failed';
}
export declare namespace RealtimeResponseStatus {
/**
* A description of the error that caused the response to fail, populated when the
* `status` is `failed`.
*/
interface Error {
/**
* Error code, if any.
*/
code?: string;
/**
* The type of error.
*/
type?: string;
}
}
/**
* Usage statistics for the Response, this will correspond to billing. A Realtime
* API session will maintain a conversation context and append new Items to the
* Conversation, thus output from previous turns (text and audio tokens) will
* become the input for later turns.
*/
export interface RealtimeResponseUsage {
/**
* Details about the input tokens used in the Response.
*/
input_token_details?: RealtimeResponseUsage.InputTokenDetails;
/**
* The number of input tokens used in the Response, including text and audio
* tokens.
*/
input_tokens?: number;
/**
* Details about the output tokens used in the Response.
*/
output_token_details?: RealtimeResponseUsage.OutputTokenDetails;
/**
* The number of output tokens sent in the Response, including text and audio
* tokens.
*/
output_tokens?: number;
/**
* The total number of tokens in the Response including input and output text and
* audio tokens.
*/
total_tokens?: number;
}
export declare namespace RealtimeResponseUsage {
/**
* Details about the input tokens used in the Response.
*/
interface InputTokenDetails {
/**
* The number of audio tokens used in the Response.
*/
audio_tokens?: number;
/**
* The number of cached tokens used in the Response.
*/
cached_tokens?: number;
/**
* The number of text tokens used in the Response.
*/
text_tokens?: number;
}
/**
* Details about the output tokens used in the Response.
*/
interface OutputTokenDetails {
/**
* The number of audio tokens used in the Response.
*/
audio_tokens?: number;
/**
* The number of text tokens used in the Response.
*/
text_tokens?: number;
}
}
/**
* A realtime server event.
*/
export type RealtimeServerEvent = ConversationCreatedEvent | ConversationItemCreatedEvent | ConversationItemDeletedEvent | ConversationItemInputAudioTranscriptionCompletedEvent | ConversationItemInputAudioTranscriptionDeltaEvent | ConversationItemInputAudioTranscriptionFailedEvent | RealtimeServerEvent.ConversationItemRetrieved | ConversationItemTruncatedEvent | ErrorEvent | InputAudioBufferClearedEvent | InputAudioBufferCommittedEvent | InputAudioBufferSpeechStartedEvent | InputAudioBufferSpeechStoppedEvent | RateLimitsUpdatedEvent | ResponseAudioDeltaEvent | ResponseAudioDoneEvent | ResponseAudioTranscriptDeltaEvent | ResponseAudioTranscriptDoneEvent | ResponseContentPartAddedEvent | ResponseContentPartDoneEvent | ResponseCreatedEvent | ResponseDoneEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseFunctionCallArgumentsDoneEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseTextDeltaEvent | ResponseTextDoneEvent | SessionCreatedEvent | SessionUpdatedEvent | TranscriptionSessionUpdatedEvent | RealtimeServerEvent.OutputAudioBufferStarted | RealtimeServerEvent.OutputAudioBufferStopped | RealtimeServerEvent.OutputAudioBufferCleared;
export declare namespace RealtimeServerEvent {
/**
* Returned when a conversation item is retrieved with
* `conversation.item.retrieve`.
*/
interface ConversationItemRetrieved {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The item to add to the conversation.
*/
item: RealtimeAPI.ConversationItem;
/**
* The event type, must be `conversation.item.retrieved`.
*/
type: 'conversation.item.retrieved';
}
/**
* **WebRTC Only:** Emitted when the server begins streaming audio to the client.
* This event is emitted after an audio content part has been added
* (`response.content_part.added`) to the response.
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
*/
interface OutputAudioBufferStarted {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The unique ID of the response that produced the audio.
*/
response_id: string;
/**
* The event type, must be `output_audio_buffer.started`.
*/
type: 'output_audio_buffer.started';
}
/**
* **WebRTC Only:** Emitted when the output audio buffer has been completely
* drained on the server, and no more audio is forthcoming. This event is emitted
* after the full response data has been sent to the client (`response.done`).
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
*/
interface OutputAudioBufferStopped {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The unique ID of the response that produced the audio.
*/
response_id: string;
/**
* The event type, must be `output_audio_buffer.stopped`.
*/
type: 'output_audio_buffer.stopped';
}
/**
* **WebRTC Only:** Emitted when the output audio buffer is cleared. This happens
* either in VAD mode when the user has interrupted
* (`input_audio_buffer.speech_started`), or when the client has emitted the
* `output_audio_buffer.clear` event to manually cut off the current audio
* response.
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
*/
interface OutputAudioBufferCleared {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The unique ID of the response that produced the audio.
*/
response_id: string;
/**
* The event type, must be `output_audio_buffer.cleared`.
*/
type: 'output_audio_buffer.cleared';
}
}
/**
* Returned when the model-generated audio is updated.
*/
export interface ResponseAudioDeltaEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* Base64-encoded audio data delta.
*/
delta: string;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.audio.delta`.
*/
type: 'response.audio.delta';
}
/**
* Returned when the model-generated audio is done. Also emitted when a Response is
* interrupted, incomplete, or cancelled.
*/
export interface ResponseAudioDoneEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.audio.done`.
*/
type: 'response.audio.done';
}
/**
* Returned when the model-generated transcription of audio output is updated.
*/
export interface ResponseAudioTranscriptDeltaEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The transcript delta.
*/
delta: string;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.audio_transcript.delta`.
*/
type: 'response.audio_transcript.delta';
}
/**
* Returned when the model-generated transcription of audio output is done
* streaming. Also emitted when a Response is interrupted, incomplete, or
* cancelled.
*/
export interface ResponseAudioTranscriptDoneEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The final transcript of the audio.
*/
transcript: string;
/**
* The event type, must be `response.audio_transcript.done`.
*/
type: 'response.audio_transcript.done';
}
/**
* Send this event to cancel an in-progress response. The server will respond with
* a `response.done` event with a status of `response.status=cancelled`. If there
* is no response to cancel, the server will respond with an error.
*/
export interface ResponseCancelEvent {
/**
* The event type, must be `response.cancel`.
*/
type: 'response.cancel';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
/**
* A specific response ID to cancel - if not provided, will cancel an in-progress
* response in the default conversation.
*/
response_id?: string;
}
/**
* Returned when a new content part is added to an assistant message item during
* response generation.
*/
export interface ResponseContentPartAddedEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item to which the content part was added.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The content part that was added.
*/
part: ResponseContentPartAddedEvent.Part;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.content_part.added`.
*/
type: 'response.content_part.added';
}
export declare namespace ResponseContentPartAddedEvent {
/**
* The content part that was added.
*/
interface Part {
/**
* Base64-encoded audio data (if type is "audio").
*/
audio?: string;
/**
* The text content (if type is "text").
*/
text?: string;
/**
* The transcript of the audio (if type is "audio").
*/
transcript?: string;
/**
* The content type ("text", "audio").
*/
type?: 'text' | 'audio';
}
}
/**
* Returned when a content part is done streaming in an assistant message item.
* Also emitted when a Response is interrupted, incomplete, or cancelled.
*/
export interface ResponseContentPartDoneEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The content part that is done.
*/
part: ResponseContentPartDoneEvent.Part;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.content_part.done`.
*/
type: 'response.content_part.done';
}
export declare namespace ResponseContentPartDoneEvent {
/**
* The content part that is done.
*/
interface Part {
/**
* Base64-encoded audio data (if type is "audio").
*/
audio?: string;
/**
* The text content (if type is "text").
*/
text?: string;
/**
* The transcript of the audio (if type is "audio").
*/
transcript?: string;
/**
* The content type ("text", "audio").
*/
type?: 'text' | 'audio';
}
}
/**
* This event instructs the server to create a Response, which means triggering
* model inference. When in Server VAD mode, the server will create Responses
* automatically.
*
* A Response will include at least one Item, and may have two, in which case the
* second will be a function call. These Items will be appended to the conversation
* history.
*
* The server will respond with a `response.created` event, events for Items and
* content created, and finally a `response.done` event to indicate the Response is
* complete.
*
* The `response.create` event includes inference configuration like
* `instructions`, and `temperature`. These fields will override the Session's
* configuration for this Response only.
*/
export interface ResponseCreateEvent {
/**
* The event type, must be `response.create`.
*/
type: 'response.create';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
/**
* Create a new Realtime response with these parameters
*/
response?: ResponseCreateEvent.Response;
}
export declare namespace ResponseCreateEvent {
/**
* Create a new Realtime response with these parameters
*/
interface Response {
/**
* Controls which conversation the response is added to. Currently supports `auto`
* and `none`, with `auto` as the default value. The `auto` value means that the
* contents of the response will be added to the default conversation. Set this to
* `none` to create an out-of-band response which will not add items to default
* conversation.
*/
conversation?: (string & {}) | 'auto' | 'none';
/**
* Input items to include in the prompt for the model. Using this field creates a
* new context for this Response instead of using the default conversation. An
* empty array `[]` will clear the context for this Response. Note that this can
* include references to items from the default conversation.
*/
input?: Array<RealtimeAPI.ConversationItemWithReference>;
/**
* The default system instructions (i.e. system message) prepended to model calls.
* This field allows the client to guide the model on desired responses. The model
* can be instructed on response content and format, (e.g. "be extremely succinct",
* "act friendly", "here are examples of good responses") and on audio behavior
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
* instructions are not guaranteed to be followed by the model, but they provide
* guidance to the model on the desired behavior.
*
* Note that the server sets default instructions which will be used if this field
* is not set and are visible in the `session.created` event at the start of the
* session.
*/
instructions?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
*/
max_response_output_tokens?: number | 'inf';
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
*/
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
*/
temperature?: number;
/**
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
* a function, like `{"type": "function", "function": {"name": "my_function"}}`.
*/
tool_choice?: string;
/**
* Tools (functions) available to the model.
*/
tools?: Array<Response.Tool>;
/**
* The voice the model uses to respond. Voice cannot be changed during the session
* once the model has responded with audio at least once. Current voice options are
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
namespace Response {
interface Tool {
/**
* The description of the function, including guidance on when and how to call it,
* and guidance about what to tell the user when calling (if anything).
*/
description?: string;
/**
* The name of the function.
*/
name?: string;
/**
* Parameters of the function in JSON Schema.
*/
parameters?: unknown;
/**
* The type of the tool, i.e. `function`.
*/
type?: 'function';
}
}
}
/**
* Returned when a new Response is created. The first event of response creation,
* where the response is in an initial state of `in_progress`.
*/
export interface ResponseCreatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The response resource.
*/
response: RealtimeResponse;
/**
* The event type, must be `response.created`.
*/
type: 'response.created';
}
/**
* Returned when a Response is done streaming. Always emitted, no matter the final
* state. The Response object included in the `response.done` event will include
* all output Items in the Response but will omit the raw audio data.
*/
export interface ResponseDoneEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The response resource.
*/
response: RealtimeResponse;
/**
* The event type, must be `response.done`.
*/
type: 'response.done';
}
/**
* Returned when the model-generated function call arguments are updated.
*/
export interface ResponseFunctionCallArgumentsDeltaEvent {
/**
* The ID of the function call.
*/
call_id: string;
/**
* The arguments delta as a JSON string.
*/
delta: string;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the function call item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.function_call_arguments.delta`.
*/
type: 'response.function_call_arguments.delta';
}
/**
* Returned when the model-generated function call arguments are done streaming.
* Also emitted when a Response is interrupted, incomplete, or cancelled.
*/
export interface ResponseFunctionCallArgumentsDoneEvent {
/**
* The final arguments as a JSON string.
*/
arguments: string;
/**
* The ID of the function call.
*/
call_id: string;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the function call item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.function_call_arguments.done`.
*/
type: 'response.function_call_arguments.done';
}
/**
* Returned when a new Item is created during Response generation.
*/
export interface ResponseOutputItemAddedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The item to add to the conversation.
*/
item: ConversationItem;
/**
* The index of the output item in the Response.
*/
output_index: number;
/**
* The ID of the Response to which the item belongs.
*/
response_id: string;
/**
* The event type, must be `response.output_item.added`.
*/
type: 'response.output_item.added';
}
/**
* Returned when an Item is done streaming. Also emitted when a Response is
* interrupted, incomplete, or cancelled.
*/
export interface ResponseOutputItemDoneEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The item to add to the conversation.
*/
item: ConversationItem;
/**
* The index of the output item in the Response.
*/
output_index: number;
/**
* The ID of the Response to which the item belongs.
*/
response_id: string;
/**
* The event type, must be `response.output_item.done`.
*/
type: 'response.output_item.done';
}
/**
* Returned when the text value of a "text" content part is updated.
*/
export interface ResponseTextDeltaEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The text delta.
*/
delta: string;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.text.delta`.
*/
type: 'response.text.delta';
}
/**
* Returned when the text value of a "text" content part is done streaming. Also
* emitted when a Response is interrupted, incomplete, or cancelled.
*/
export interface ResponseTextDoneEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The final text content.
*/
text: string;
/**
* The event type, must be `response.text.done`.
*/
type: 'response.text.done';
}
/**
* Returned when a Session is created. Emitted automatically when a new connection
* is established as the first server event. This event will contain the default
* Session configuration.
*/
export interface SessionCreatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* Realtime session object configuration.
*/
session: SessionsAPI.Session;
/**
* The event type, must be `session.created`.
*/
type: 'session.created';
}
/**
* Send this event to update the sessions default configuration. The client may
* send this event at any time to update any field, except for `voice`. However,
* note that once a session has been initialized with a particular `model`, it
* cant be changed to another model using `session.update`.
*
* When the server receives a `session.update`, it will respond with a
* `session.updated` event showing the full, effective configuration. Only the
* fields that are present are updated. To clear a field like `instructions`, pass
* an empty string.
*/
export interface SessionUpdateEvent {
/**
* Realtime session object configuration.
*/
session: SessionUpdateEvent.Session;
/**
* The event type, must be `session.update`.
*/
type: 'session.update';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
export declare namespace SessionUpdateEvent {
/**
* Realtime session object configuration.
*/
interface Session {
/**
* Configuration options for the generated client secret.
*/
client_secret?: Session.ClientSecret;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
* (mono), and little-endian byte order.
*/
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
input_audio_noise_reduction?: Session.InputAudioNoiseReduction;
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
input_audio_transcription?: Session.InputAudioTranscription;
/**
* The default system instructions (i.e. system message) prepended to model calls.
* This field allows the client to guide the model on desired responses. The model
* can be instructed on response content and format, (e.g. "be extremely succinct",
* "act friendly", "here are examples of good responses") and on audio behavior
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
* instructions are not guaranteed to be followed by the model, but they provide
* guidance to the model on the desired behavior.
*
* Note that the server sets default instructions which will be used if this field
* is not set and are visible in the `session.created` event at the start of the
* session.
*/
instructions?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
*/
max_response_output_tokens?: number | 'inf';
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* The Realtime model used for this session.
*/
model?: 'gpt-4o-realtime-preview' | 'gpt-4o-realtime-preview-2024-10-01' | 'gpt-4o-realtime-preview-2024-12-17' | 'gpt-4o-realtime-preview-2025-06-03' | 'gpt-4o-mini-realtime-preview' | 'gpt-4o-mini-realtime-preview-2024-12-17';
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
* For `pcm16`, output audio is sampled at a rate of 24kHz.
*/
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the
* minimum speed. 1.5 is the maximum speed. This value can only be changed in
* between model turns, not while a response is in progress.
*/
speed?: number;
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a
* temperature of 0.8 is highly recommended for best performance.
*/
temperature?: number;
/**
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
* a function.
*/
tool_choice?: string;
/**
* Tools (functions) available to the model.
*/
tools?: Array<Session.Tool>;
/**
* Configuration options for tracing. Set to null to disable tracing. Once tracing
* is enabled for a session, the configuration cannot be modified.
*
* `auto` will create a trace for the session with default values for the workflow
* name, group id, and metadata.
*/
tracing?: 'auto' | Session.TracingConfiguration;
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
turn_detection?: Session.TurnDetection;
/**
* The voice the model uses to respond. Voice cannot be changed during the session
* once the model has responded with audio at least once. Current voice options are
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
namespace Session {
/**
* Configuration options for the generated client secret.
*/
interface ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
expires_after?: ClientSecret.ExpiresAfter;
}
namespace ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
interface ExpiresAfter {
/**
* The anchor point for the ephemeral token expiration. Only `created_at` is
* currently supported.
*/
anchor: 'created_at';
/**
* The number of seconds from the anchor point to the expiration. Select a value
* between `10` and `7200`.
*/
seconds?: number;
}
}
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
interface InputAudioNoiseReduction {
/**
* Type of noise reduction. `near_field` is for close-talking microphones such as
* headphones, `far_field` is for far-field microphones such as laptop or
* conference room microphones.
*/
type?: 'near_field' | 'far_field';
}
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription, current options are `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, and `whisper-1`.
*/
model?: string;
/**
* An optional text to guide the model's style or continue a previous audio
* segment. For `whisper-1`, the
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
* "expect words related to technology".
*/
prompt?: string;
}
interface Tool {
/**
* The description of the function, including guidance on when and how to call it,
* and guidance about what to tell the user when calling (if anything).
*/
description?: string;
/**
* The name of the function.
*/
name?: string;
/**
* Parameters of the function in JSON Schema.
*/
parameters?: unknown;
/**
* The type of the tool, i.e. `function`.
*/
type?: 'function';
}
/**
* Granular configuration for tracing.
*/
interface TracingConfiguration {
/**
* The group id to attach to this trace to enable filtering and grouping in the
* traces dashboard.
*/
group_id?: string;
/**
* The arbitrary metadata to attach to this trace to enable filtering in the traces
* dashboard.
*/
metadata?: unknown;
/**
* The name of the workflow to attach to this trace. This is used to name the trace
* in the traces dashboard.
*/
workflow_name?: string;
}
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
interface TurnDetection {
/**
* Whether or not to automatically generate a response when a VAD stop event
* occurs.
*/
create_response?: boolean;
/**
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
* will wait longer for the user to continue speaking, `high` will respond more
* quickly. `auto` is the default and is equivalent to `medium`.
*/
eagerness?: 'low' | 'medium' | 'high' | 'auto';
/**
* Whether or not to automatically interrupt any ongoing response with output to
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
* occurs.
*/
interrupt_response?: boolean;
/**
* Used only for `server_vad` mode. Amount of audio to include before the VAD
* detected speech (in milliseconds). Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
* milliseconds). Defaults to 500ms. With shorter values the model will respond
* more quickly, but may jump in on short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
* defaults to 0.5. A higher threshold will require louder audio to activate the
* model, and thus might perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection.
*/
type?: 'server_vad' | 'semantic_vad';
}
}
}
/**
* Returned when a session is updated with a `session.update` event, unless there
* is an error.
*/
export interface SessionUpdatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* Realtime session object configuration.
*/
session: SessionsAPI.Session;
/**
* The event type, must be `session.updated`.
*/
type: 'session.updated';
}
/**
* Send this event to update a transcription session.
*/
export interface TranscriptionSessionUpdate {
/**
* Realtime transcription session object configuration.
*/
session: TranscriptionSessionUpdate.Session;
/**
* The event type, must be `transcription_session.update`.
*/
type: 'transcription_session.update';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
export declare namespace TranscriptionSessionUpdate {
/**
* Realtime transcription session object configuration.
*/
interface Session {
/**
* Configuration options for the generated client secret.
*/
client_secret?: Session.ClientSecret;
/**
* The set of items to include in the transcription. Current available items are:
*
* - `item.input_audio_transcription.logprobs`
*/
include?: Array<string>;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
* (mono), and little-endian byte order.
*/
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
input_audio_noise_reduction?: Session.InputAudioNoiseReduction;
/**
* Configuration for input audio transcription. The client can optionally set the
* language and prompt for transcription, these offer additional guidance to the
* transcription service.
*/
input_audio_transcription?: Session.InputAudioTranscription;
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
turn_detection?: Session.TurnDetection;
}
namespace Session {
/**
* Configuration options for the generated client secret.
*/
interface ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
expires_at?: ClientSecret.ExpiresAt;
}
namespace ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
interface ExpiresAt {
/**
* The anchor point for the ephemeral token expiration. Only `created_at` is
* currently supported.
*/
anchor?: 'created_at';
/**
* The number of seconds from the anchor point to the expiration. Select a value
* between `10` and `7200`.
*/
seconds?: number;
}
}
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
interface InputAudioNoiseReduction {
/**
* Type of noise reduction. `near_field` is for close-talking microphones such as
* headphones, `far_field` is for far-field microphones such as laptop or
* conference room microphones.
*/
type?: 'near_field' | 'far_field';
}
/**
* Configuration for input audio transcription. The client can optionally set the
* language and prompt for transcription, these offer additional guidance to the
* transcription service.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription, current options are `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, and `whisper-1`.
*/
model?: 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe' | 'whisper-1';
/**
* An optional text to guide the model's style or continue a previous audio
* segment. For `whisper-1`, the
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
* "expect words related to technology".
*/
prompt?: string;
}
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
interface TurnDetection {
/**
* Whether or not to automatically generate a response when a VAD stop event
* occurs. Not available for transcription sessions.
*/
create_response?: boolean;
/**
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
* will wait longer for the user to continue speaking, `high` will respond more
* quickly. `auto` is the default and is equivalent to `medium`.
*/
eagerness?: 'low' | 'medium' | 'high' | 'auto';
/**
* Whether or not to automatically interrupt any ongoing response with output to
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
* occurs. Not available for transcription sessions.
*/
interrupt_response?: boolean;
/**
* Used only for `server_vad` mode. Amount of audio to include before the VAD
* detected speech (in milliseconds). Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
* milliseconds). Defaults to 500ms. With shorter values the model will respond
* more quickly, but may jump in on short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
* defaults to 0.5. A higher threshold will require louder audio to activate the
* model, and thus might perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection.
*/
type?: 'server_vad' | 'semantic_vad';
}
}
}
/**
* Returned when a transcription session is updated with a
* `transcription_session.update` event, unless there is an error.
*/
export interface TranscriptionSessionUpdatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* A new Realtime transcription session configuration.
*
* When a session is created on the server via REST API, the session object also
* contains an ephemeral key. Default TTL for keys is 10 minutes. This property is
* not present when a session is updated via the WebSocket API.
*/
session: TranscriptionSessionsAPI.TranscriptionSession;
/**
* The event type, must be `transcription_session.updated`.
*/
type: 'transcription_session.updated';
}
export declare namespace Realtime {
export { type ConversationCreatedEvent as ConversationCreatedEvent, type ConversationItem as ConversationItem, type ConversationItemContent as ConversationItemContent, type ConversationItemCreateEvent as ConversationItemCreateEvent, type ConversationItemCreatedEvent as ConversationItemCreatedEvent, type ConversationItemDeleteEvent as ConversationItemDeleteEvent, type ConversationItemDeletedEvent as ConversationItemDeletedEvent, type ConversationItemInputAudioTranscriptionCompletedEvent as ConversationItemInputAudioTranscriptionCompletedEvent, type ConversationItemInputAudioTranscriptionDeltaEvent as ConversationItemInputAudioTranscriptionDeltaEvent, type ConversationItemInputAudioTranscriptionFailedEvent as ConversationItemInputAudioTranscriptionFailedEvent, type ConversationItemRetrieveEvent as ConversationItemRetrieveEvent, type ConversationItemTruncateEvent as ConversationItemTruncateEvent, type ConversationItemTruncatedEvent as ConversationItemTruncatedEvent, type ConversationItemWithReference as ConversationItemWithReference, type ErrorEvent as ErrorEvent, type InputAudioBufferAppendEvent as InputAudioBufferAppendEvent, type InputAudioBufferClearEvent as InputAudioBufferClearEvent, type InputAudioBufferClearedEvent as InputAudioBufferClearedEvent, type InputAudioBufferCommitEvent as InputAudioBufferCommitEvent, type InputAudioBufferCommittedEvent as InputAudioBufferCommittedEvent, type InputAudioBufferSpeechStartedEvent as InputAudioBufferSpeechStartedEvent, type InputAudioBufferSpeechStoppedEvent as InputAudioBufferSpeechStoppedEvent, type RateLimitsUpdatedEvent as RateLimitsUpdatedEvent, type RealtimeClientEvent as RealtimeClientEvent, type RealtimeResponse as RealtimeResponse, type RealtimeResponseStatus as RealtimeResponseStatus, type RealtimeResponseUsage as RealtimeResponseUsage, type RealtimeServerEvent as RealtimeServerEvent, type ResponseAudioDeltaEvent as ResponseAudioDeltaEvent, type ResponseAudioDoneEvent as ResponseAudioDoneEvent, type ResponseAudioTranscriptDeltaEvent as ResponseAudioTranscriptDeltaEvent, type ResponseAudioTranscriptDoneEvent as ResponseAudioTranscriptDoneEvent, type ResponseCancelEvent as ResponseCancelEvent, type ResponseContentPartAddedEvent as ResponseContentPartAddedEvent, type ResponseContentPartDoneEvent as ResponseContentPartDoneEvent, type ResponseCreateEvent as ResponseCreateEvent, type ResponseCreatedEvent as ResponseCreatedEvent, type ResponseDoneEvent as ResponseDoneEvent, type ResponseFunctionCallArgumentsDeltaEvent as ResponseFunctionCallArgumentsDeltaEvent, type ResponseFunctionCallArgumentsDoneEvent as ResponseFunctionCallArgumentsDoneEvent, type ResponseOutputItemAddedEvent as ResponseOutputItemAddedEvent, type ResponseOutputItemDoneEvent as ResponseOutputItemDoneEvent, type ResponseTextDeltaEvent as ResponseTextDeltaEvent, type ResponseTextDoneEvent as ResponseTextDoneEvent, type SessionCreatedEvent as SessionCreatedEvent, type SessionUpdateEvent as SessionUpdateEvent, type SessionUpdatedEvent as SessionUpdatedEvent, type TranscriptionSessionUpdate as TranscriptionSessionUpdate, type TranscriptionSessionUpdatedEvent as TranscriptionSessionUpdatedEvent, };
export { Sessions as Sessions, type SessionsAPISession as Session, type SessionCreateResponse as SessionCreateResponse, type SessionCreateParams as SessionCreateParams, };
export { TranscriptionSessions as TranscriptionSessions, type TranscriptionSession as TranscriptionSession, type TranscriptionSessionCreateParams as TranscriptionSessionCreateParams, };
}
//# sourceMappingURL=realtime.d.mts.map
File diff suppressed because one or more lines are too long
+2332
View File
@@ -0,0 +1,2332 @@
import { APIResource } from "../../../core/resource.js";
import * as RealtimeAPI from "./realtime.js";
import * as Shared from "../../shared.js";
import * as SessionsAPI from "./sessions.js";
import { Session as SessionsAPISession, SessionCreateParams, SessionCreateResponse, Sessions } from "./sessions.js";
import * as TranscriptionSessionsAPI from "./transcription-sessions.js";
import { TranscriptionSession, TranscriptionSessionCreateParams, TranscriptionSessions } from "./transcription-sessions.js";
/**
* @deprecated Realtime has now launched and is generally available. The old beta API is now deprecated.
*/
export declare class Realtime extends APIResource {
sessions: SessionsAPI.Sessions;
transcriptionSessions: TranscriptionSessionsAPI.TranscriptionSessions;
}
/**
* Returned when a conversation is created. Emitted right after session creation.
*/
export interface ConversationCreatedEvent {
/**
* The conversation resource.
*/
conversation: ConversationCreatedEvent.Conversation;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The event type, must be `conversation.created`.
*/
type: 'conversation.created';
}
export declare namespace ConversationCreatedEvent {
/**
* The conversation resource.
*/
interface Conversation {
/**
* The unique ID of the conversation.
*/
id?: string;
/**
* The object type, must be `realtime.conversation`.
*/
object?: 'realtime.conversation';
}
}
/**
* The item to add to the conversation.
*/
export interface ConversationItem {
/**
* The unique ID of the item, this can be generated by the client to help manage
* server-side context, but is not required because the server will generate one if
* not provided.
*/
id?: string;
/**
* The arguments of the function call (for `function_call` items).
*/
arguments?: string;
/**
* The ID of the function call (for `function_call` and `function_call_output`
* items). If passed on a `function_call_output` item, the server will check that a
* `function_call` item with the same ID exists in the conversation history.
*/
call_id?: string;
/**
* The content of the message, applicable for `message` items.
*
* - Message items of role `system` support only `input_text` content
* - Message items of role `user` support `input_text` and `input_audio` content
* - Message items of role `assistant` support `text` content.
*/
content?: Array<ConversationItemContent>;
/**
* The name of the function being called (for `function_call` items).
*/
name?: string;
/**
* Identifier for the API object being returned - always `realtime.item`.
*/
object?: 'realtime.item';
/**
* The output of the function call (for `function_call_output` items).
*/
output?: string;
/**
* The role of the message sender (`user`, `assistant`, `system`), only applicable
* for `message` items.
*/
role?: 'user' | 'assistant' | 'system';
/**
* The status of the item (`completed`, `incomplete`, `in_progress`). These have no
* effect on the conversation, but are accepted for consistency with the
* `conversation.item.created` event.
*/
status?: 'completed' | 'incomplete' | 'in_progress';
/**
* The type of the item (`message`, `function_call`, `function_call_output`).
*/
type?: 'message' | 'function_call' | 'function_call_output';
}
export interface ConversationItemContent {
/**
* ID of a previous conversation item to reference (for `item_reference` content
* types in `response.create` events). These can reference both client and server
* created items.
*/
id?: string;
/**
* Base64-encoded audio bytes, used for `input_audio` content type.
*/
audio?: string;
/**
* The text content, used for `input_text` and `text` content types.
*/
text?: string;
/**
* The transcript of the audio, used for `input_audio` and `audio` content types.
*/
transcript?: string;
/**
* The content type (`input_text`, `input_audio`, `item_reference`, `text`,
* `audio`).
*/
type?: 'input_text' | 'input_audio' | 'item_reference' | 'text' | 'audio';
}
/**
* Add a new Item to the Conversation's context, including messages, function
* calls, and function call responses. This event can be used both to populate a
* "history" of the conversation and to add new items mid-stream, but has the
* current limitation that it cannot populate assistant audio messages.
*
* If successful, the server will respond with a `conversation.item.created` event,
* otherwise an `error` event will be sent.
*/
export interface ConversationItemCreateEvent {
/**
* The item to add to the conversation.
*/
item: ConversationItem;
/**
* The event type, must be `conversation.item.create`.
*/
type: 'conversation.item.create';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
/**
* The ID of the preceding item after which the new item will be inserted. If not
* set, the new item will be appended to the end of the conversation. If set to
* `root`, the new item will be added to the beginning of the conversation. If set
* to an existing ID, it allows an item to be inserted mid-conversation. If the ID
* cannot be found, an error will be returned and the item will not be added.
*/
previous_item_id?: string;
}
/**
* Returned when a conversation item is created. There are several scenarios that
* produce this event:
*
* - The server is generating a Response, which if successful will produce either
* one or two Items, which will be of type `message` (role `assistant`) or type
* `function_call`.
* - The input audio buffer has been committed, either by the client or the server
* (in `server_vad` mode). The server will take the content of the input audio
* buffer and add it to a new user message Item.
* - The client has sent a `conversation.item.create` event to add a new Item to
* the Conversation.
*/
export interface ConversationItemCreatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The item to add to the conversation.
*/
item: ConversationItem;
/**
* The event type, must be `conversation.item.created`.
*/
type: 'conversation.item.created';
/**
* The ID of the preceding item in the Conversation context, allows the client to
* understand the order of the conversation. Can be `null` if the item has no
* predecessor.
*/
previous_item_id?: string | null;
}
/**
* Send this event when you want to remove any item from the conversation history.
* The server will respond with a `conversation.item.deleted` event, unless the
* item does not exist in the conversation history, in which case the server will
* respond with an error.
*/
export interface ConversationItemDeleteEvent {
/**
* The ID of the item to delete.
*/
item_id: string;
/**
* The event type, must be `conversation.item.delete`.
*/
type: 'conversation.item.delete';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Returned when an item in the conversation is deleted by the client with a
* `conversation.item.delete` event. This event is used to synchronize the server's
* understanding of the conversation history with the client's view.
*/
export interface ConversationItemDeletedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item that was deleted.
*/
item_id: string;
/**
* The event type, must be `conversation.item.deleted`.
*/
type: 'conversation.item.deleted';
}
/**
* This event is the output of audio transcription for user audio written to the
* user audio buffer. Transcription begins when the input audio buffer is committed
* by the client or server (in `server_vad` mode). Transcription runs
* asynchronously with Response creation, so this event may come before or after
* the Response events.
*
* Realtime API models accept audio natively, and thus input transcription is a
* separate process run on a separate ASR (Automatic Speech Recognition) model. The
* transcript may diverge somewhat from the model's interpretation, and should be
* treated as a rough guide.
*/
export interface ConversationItemInputAudioTranscriptionCompletedEvent {
/**
* The index of the content part containing the audio.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the user message item containing the audio.
*/
item_id: string;
/**
* The transcribed text.
*/
transcript: string;
/**
* The event type, must be `conversation.item.input_audio_transcription.completed`.
*/
type: 'conversation.item.input_audio_transcription.completed';
/**
* Usage statistics for the transcription.
*/
usage: ConversationItemInputAudioTranscriptionCompletedEvent.TranscriptTextUsageTokens | ConversationItemInputAudioTranscriptionCompletedEvent.TranscriptTextUsageDuration;
/**
* The log probabilities of the transcription.
*/
logprobs?: Array<ConversationItemInputAudioTranscriptionCompletedEvent.Logprob> | null;
}
export declare namespace ConversationItemInputAudioTranscriptionCompletedEvent {
/**
* Usage statistics for models billed by token usage.
*/
interface TranscriptTextUsageTokens {
/**
* Number of input tokens billed for this request.
*/
input_tokens: number;
/**
* Number of output tokens generated.
*/
output_tokens: number;
/**
* Total number of tokens used (input + output).
*/
total_tokens: number;
/**
* The type of the usage object. Always `tokens` for this variant.
*/
type: 'tokens';
/**
* Details about the input tokens billed for this request.
*/
input_token_details?: TranscriptTextUsageTokens.InputTokenDetails;
}
namespace TranscriptTextUsageTokens {
/**
* Details about the input tokens billed for this request.
*/
interface InputTokenDetails {
/**
* Number of audio tokens billed for this request.
*/
audio_tokens?: number;
/**
* Number of text tokens billed for this request.
*/
text_tokens?: number;
}
}
/**
* Usage statistics for models billed by audio input duration.
*/
interface TranscriptTextUsageDuration {
/**
* Duration of the input audio in seconds.
*/
seconds: number;
/**
* The type of the usage object. Always `duration` for this variant.
*/
type: 'duration';
}
/**
* A log probability object.
*/
interface Logprob {
/**
* The token that was used to generate the log probability.
*/
token: string;
/**
* The bytes that were used to generate the log probability.
*/
bytes: Array<number>;
/**
* The log probability of the token.
*/
logprob: number;
}
}
/**
* Returned when the text value of an input audio transcription content part is
* updated.
*/
export interface ConversationItemInputAudioTranscriptionDeltaEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The event type, must be `conversation.item.input_audio_transcription.delta`.
*/
type: 'conversation.item.input_audio_transcription.delta';
/**
* The index of the content part in the item's content array.
*/
content_index?: number;
/**
* The text delta.
*/
delta?: string;
/**
* The log probabilities of the transcription.
*/
logprobs?: Array<ConversationItemInputAudioTranscriptionDeltaEvent.Logprob> | null;
}
export declare namespace ConversationItemInputAudioTranscriptionDeltaEvent {
/**
* A log probability object.
*/
interface Logprob {
/**
* The token that was used to generate the log probability.
*/
token: string;
/**
* The bytes that were used to generate the log probability.
*/
bytes: Array<number>;
/**
* The log probability of the token.
*/
logprob: number;
}
}
/**
* Returned when input audio transcription is configured, and a transcription
* request for a user message failed. These events are separate from other `error`
* events so that the client can identify the related Item.
*/
export interface ConversationItemInputAudioTranscriptionFailedEvent {
/**
* The index of the content part containing the audio.
*/
content_index: number;
/**
* Details of the transcription error.
*/
error: ConversationItemInputAudioTranscriptionFailedEvent.Error;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the user message item.
*/
item_id: string;
/**
* The event type, must be `conversation.item.input_audio_transcription.failed`.
*/
type: 'conversation.item.input_audio_transcription.failed';
}
export declare namespace ConversationItemInputAudioTranscriptionFailedEvent {
/**
* Details of the transcription error.
*/
interface Error {
/**
* Error code, if any.
*/
code?: string;
/**
* A human-readable error message.
*/
message?: string;
/**
* Parameter related to the error, if any.
*/
param?: string;
/**
* The type of error.
*/
type?: string;
}
}
/**
* Send this event when you want to retrieve the server's representation of a
* specific item in the conversation history. This is useful, for example, to
* inspect user audio after noise cancellation and VAD. The server will respond
* with a `conversation.item.retrieved` event, unless the item does not exist in
* the conversation history, in which case the server will respond with an error.
*/
export interface ConversationItemRetrieveEvent {
/**
* The ID of the item to retrieve.
*/
item_id: string;
/**
* The event type, must be `conversation.item.retrieve`.
*/
type: 'conversation.item.retrieve';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Send this event to truncate a previous assistant messages audio. The server
* will produce audio faster than realtime, so this event is useful when the user
* interrupts to truncate audio that has already been sent to the client but not
* yet played. This will synchronize the server's understanding of the audio with
* the client's playback.
*
* Truncating audio will delete the server-side text transcript to ensure there is
* not text in the context that hasn't been heard by the user.
*
* If successful, the server will respond with a `conversation.item.truncated`
* event.
*/
export interface ConversationItemTruncateEvent {
/**
* Inclusive duration up to which audio is truncated, in milliseconds. If the
* audio_end_ms is greater than the actual audio duration, the server will respond
* with an error.
*/
audio_end_ms: number;
/**
* The index of the content part to truncate. Set this to 0.
*/
content_index: number;
/**
* The ID of the assistant message item to truncate. Only assistant message items
* can be truncated.
*/
item_id: string;
/**
* The event type, must be `conversation.item.truncate`.
*/
type: 'conversation.item.truncate';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Returned when an earlier assistant audio message item is truncated by the client
* with a `conversation.item.truncate` event. This event is used to synchronize the
* server's understanding of the audio with the client's playback.
*
* This action will truncate the audio and remove the server-side text transcript
* to ensure there is no text in the context that hasn't been heard by the user.
*/
export interface ConversationItemTruncatedEvent {
/**
* The duration up to which the audio was truncated, in milliseconds.
*/
audio_end_ms: number;
/**
* The index of the content part that was truncated.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the assistant message item that was truncated.
*/
item_id: string;
/**
* The event type, must be `conversation.item.truncated`.
*/
type: 'conversation.item.truncated';
}
/**
* The item to add to the conversation.
*/
export interface ConversationItemWithReference {
/**
* For an item of type (`message` | `function_call` | `function_call_output`) this
* field allows the client to assign the unique ID of the item. It is not required
* because the server will generate one if not provided.
*
* For an item of type `item_reference`, this field is required and is a reference
* to any item that has previously existed in the conversation.
*/
id?: string;
/**
* The arguments of the function call (for `function_call` items).
*/
arguments?: string;
/**
* The ID of the function call (for `function_call` and `function_call_output`
* items). If passed on a `function_call_output` item, the server will check that a
* `function_call` item with the same ID exists in the conversation history.
*/
call_id?: string;
/**
* The content of the message, applicable for `message` items.
*
* - Message items of role `system` support only `input_text` content
* - Message items of role `user` support `input_text` and `input_audio` content
* - Message items of role `assistant` support `text` content.
*/
content?: Array<ConversationItemWithReference.Content>;
/**
* The name of the function being called (for `function_call` items).
*/
name?: string;
/**
* Identifier for the API object being returned - always `realtime.item`.
*/
object?: 'realtime.item';
/**
* The output of the function call (for `function_call_output` items).
*/
output?: string;
/**
* The role of the message sender (`user`, `assistant`, `system`), only applicable
* for `message` items.
*/
role?: 'user' | 'assistant' | 'system';
/**
* The status of the item (`completed`, `incomplete`, `in_progress`). These have no
* effect on the conversation, but are accepted for consistency with the
* `conversation.item.created` event.
*/
status?: 'completed' | 'incomplete' | 'in_progress';
/**
* The type of the item (`message`, `function_call`, `function_call_output`,
* `item_reference`).
*/
type?: 'message' | 'function_call' | 'function_call_output' | 'item_reference';
}
export declare namespace ConversationItemWithReference {
interface Content {
/**
* ID of a previous conversation item to reference (for `item_reference` content
* types in `response.create` events). These can reference both client and server
* created items.
*/
id?: string;
/**
* Base64-encoded audio bytes, used for `input_audio` content type.
*/
audio?: string;
/**
* The text content, used for `input_text` and `text` content types.
*/
text?: string;
/**
* The transcript of the audio, used for `input_audio` content type.
*/
transcript?: string;
/**
* The content type (`input_text`, `input_audio`, `item_reference`, `text`).
*/
type?: 'input_text' | 'input_audio' | 'item_reference' | 'text';
}
}
/**
* Returned when an error occurs, which could be a client problem or a server
* problem. Most errors are recoverable and the session will stay open, we
* recommend to implementors to monitor and log error messages by default.
*/
export interface ErrorEvent {
/**
* Details of the error.
*/
error: ErrorEvent.Error;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The event type, must be `error`.
*/
type: 'error';
}
export declare namespace ErrorEvent {
/**
* Details of the error.
*/
interface Error {
/**
* A human-readable error message.
*/
message: string;
/**
* The type of error (e.g., "invalid_request_error", "server_error").
*/
type: string;
/**
* Error code, if any.
*/
code?: string | null;
/**
* The event_id of the client event that caused the error, if applicable.
*/
event_id?: string | null;
/**
* Parameter related to the error, if any.
*/
param?: string | null;
}
}
/**
* Send this event to append audio bytes to the input audio buffer. The audio
* buffer is temporary storage you can write to and later commit. In Server VAD
* mode, the audio buffer is used to detect speech and the server will decide when
* to commit. When Server VAD is disabled, you must commit the audio buffer
* manually.
*
* The client may choose how much audio to place in each event up to a maximum of
* 15 MiB, for example streaming smaller chunks from the client may allow the VAD
* to be more responsive. Unlike made other client events, the server will not send
* a confirmation response to this event.
*/
export interface InputAudioBufferAppendEvent {
/**
* Base64-encoded audio bytes. This must be in the format specified by the
* `input_audio_format` field in the session configuration.
*/
audio: string;
/**
* The event type, must be `input_audio_buffer.append`.
*/
type: 'input_audio_buffer.append';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Send this event to clear the audio bytes in the buffer. The server will respond
* with an `input_audio_buffer.cleared` event.
*/
export interface InputAudioBufferClearEvent {
/**
* The event type, must be `input_audio_buffer.clear`.
*/
type: 'input_audio_buffer.clear';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Returned when the input audio buffer is cleared by the client with a
* `input_audio_buffer.clear` event.
*/
export interface InputAudioBufferClearedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The event type, must be `input_audio_buffer.cleared`.
*/
type: 'input_audio_buffer.cleared';
}
/**
* Send this event to commit the user input audio buffer, which will create a new
* user message item in the conversation. This event will produce an error if the
* input audio buffer is empty. When in Server VAD mode, the client does not need
* to send this event, the server will commit the audio buffer automatically.
*
* Committing the input audio buffer will trigger input audio transcription (if
* enabled in session configuration), but it will not create a response from the
* model. The server will respond with an `input_audio_buffer.committed` event.
*/
export interface InputAudioBufferCommitEvent {
/**
* The event type, must be `input_audio_buffer.commit`.
*/
type: 'input_audio_buffer.commit';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
/**
* Returned when an input audio buffer is committed, either by the client or
* automatically in server VAD mode. The `item_id` property is the ID of the user
* message item that will be created, thus a `conversation.item.created` event will
* also be sent to the client.
*/
export interface InputAudioBufferCommittedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the user message item that will be created.
*/
item_id: string;
/**
* The event type, must be `input_audio_buffer.committed`.
*/
type: 'input_audio_buffer.committed';
/**
* The ID of the preceding item after which the new item will be inserted. Can be
* `null` if the item has no predecessor.
*/
previous_item_id?: string | null;
}
/**
* Sent by the server when in `server_vad` mode to indicate that speech has been
* detected in the audio buffer. This can happen any time audio is added to the
* buffer (unless speech is already detected). The client may want to use this
* event to interrupt audio playback or provide visual feedback to the user.
*
* The client should expect to receive a `input_audio_buffer.speech_stopped` event
* when speech stops. The `item_id` property is the ID of the user message item
* that will be created when speech stops and will also be included in the
* `input_audio_buffer.speech_stopped` event (unless the client manually commits
* the audio buffer during VAD activation).
*/
export interface InputAudioBufferSpeechStartedEvent {
/**
* Milliseconds from the start of all audio written to the buffer during the
* session when speech was first detected. This will correspond to the beginning of
* audio sent to the model, and thus includes the `prefix_padding_ms` configured in
* the Session.
*/
audio_start_ms: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the user message item that will be created when speech stops.
*/
item_id: string;
/**
* The event type, must be `input_audio_buffer.speech_started`.
*/
type: 'input_audio_buffer.speech_started';
}
/**
* Returned in `server_vad` mode when the server detects the end of speech in the
* audio buffer. The server will also send an `conversation.item.created` event
* with the user message item that is created from the audio buffer.
*/
export interface InputAudioBufferSpeechStoppedEvent {
/**
* Milliseconds since the session started when speech stopped. This will correspond
* to the end of audio sent to the model, and thus includes the
* `min_silence_duration_ms` configured in the Session.
*/
audio_end_ms: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the user message item that will be created.
*/
item_id: string;
/**
* The event type, must be `input_audio_buffer.speech_stopped`.
*/
type: 'input_audio_buffer.speech_stopped';
}
/**
* Emitted at the beginning of a Response to indicate the updated rate limits. When
* a Response is created some tokens will be "reserved" for the output tokens, the
* rate limits shown here reflect that reservation, which is then adjusted
* accordingly once the Response is completed.
*/
export interface RateLimitsUpdatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* List of rate limit information.
*/
rate_limits: Array<RateLimitsUpdatedEvent.RateLimit>;
/**
* The event type, must be `rate_limits.updated`.
*/
type: 'rate_limits.updated';
}
export declare namespace RateLimitsUpdatedEvent {
interface RateLimit {
/**
* The maximum allowed value for the rate limit.
*/
limit?: number;
/**
* The name of the rate limit (`requests`, `tokens`).
*/
name?: 'requests' | 'tokens';
/**
* The remaining value before the limit is reached.
*/
remaining?: number;
/**
* Seconds until the rate limit resets.
*/
reset_seconds?: number;
}
}
/**
* A realtime client event.
*/
export type RealtimeClientEvent = ConversationItemCreateEvent | ConversationItemDeleteEvent | ConversationItemRetrieveEvent | ConversationItemTruncateEvent | InputAudioBufferAppendEvent | InputAudioBufferClearEvent | RealtimeClientEvent.OutputAudioBufferClear | InputAudioBufferCommitEvent | ResponseCancelEvent | ResponseCreateEvent | SessionUpdateEvent | TranscriptionSessionUpdate;
export declare namespace RealtimeClientEvent {
/**
* **WebRTC Only:** Emit to cut off the current audio response. This will trigger
* the server to stop generating audio and emit a `output_audio_buffer.cleared`
* event. This event should be preceded by a `response.cancel` client event to stop
* the generation of the current response.
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
*/
interface OutputAudioBufferClear {
/**
* The event type, must be `output_audio_buffer.clear`.
*/
type: 'output_audio_buffer.clear';
/**
* The unique ID of the client event used for error handling.
*/
event_id?: string;
}
}
/**
* The response resource.
*/
export interface RealtimeResponse {
/**
* The unique ID of the response.
*/
id?: string;
/**
* Which conversation the response is added to, determined by the `conversation`
* field in the `response.create` event. If `auto`, the response will be added to
* the default conversation and the value of `conversation_id` will be an id like
* `conv_1234`. If `none`, the response will not be added to any conversation and
* the value of `conversation_id` will be `null`. If responses are being triggered
* by server VAD, the response will be added to the default conversation, thus the
* `conversation_id` will be an id like `conv_1234`.
*/
conversation_id?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls, that was used in this response.
*/
max_output_tokens?: number | 'inf';
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* The set of modalities the model used to respond. If there are multiple
* modalities, the model will pick one, for example if `modalities` is
* `["text", "audio"]`, the model could be responding in either text or audio.
*/
modalities?: Array<'text' | 'audio'>;
/**
* The object type, must be `realtime.response`.
*/
object?: 'realtime.response';
/**
* The list of output items generated by the response.
*/
output?: Array<ConversationItem>;
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
*/
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* The final status of the response (`completed`, `cancelled`, `failed`, or
* `incomplete`, `in_progress`).
*/
status?: 'completed' | 'cancelled' | 'failed' | 'incomplete' | 'in_progress';
/**
* Additional details about the status.
*/
status_details?: RealtimeResponseStatus;
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
*/
temperature?: number;
/**
* Usage statistics for the Response, this will correspond to billing. A Realtime
* API session will maintain a conversation context and append new Items to the
* Conversation, thus output from previous turns (text and audio tokens) will
* become the input for later turns.
*/
usage?: RealtimeResponseUsage;
/**
* The voice the model used to respond. Current voice options are `alloy`, `ash`,
* `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
/**
* Additional details about the status.
*/
export interface RealtimeResponseStatus {
/**
* A description of the error that caused the response to fail, populated when the
* `status` is `failed`.
*/
error?: RealtimeResponseStatus.Error;
/**
* The reason the Response did not complete. For a `cancelled` Response, one of
* `turn_detected` (the server VAD detected a new start of speech) or
* `client_cancelled` (the client sent a cancel event). For an `incomplete`
* Response, one of `max_output_tokens` or `content_filter` (the server-side safety
* filter activated and cut off the response).
*/
reason?: 'turn_detected' | 'client_cancelled' | 'max_output_tokens' | 'content_filter';
/**
* The type of error that caused the response to fail, corresponding with the
* `status` field (`completed`, `cancelled`, `incomplete`, `failed`).
*/
type?: 'completed' | 'cancelled' | 'incomplete' | 'failed';
}
export declare namespace RealtimeResponseStatus {
/**
* A description of the error that caused the response to fail, populated when the
* `status` is `failed`.
*/
interface Error {
/**
* Error code, if any.
*/
code?: string;
/**
* The type of error.
*/
type?: string;
}
}
/**
* Usage statistics for the Response, this will correspond to billing. A Realtime
* API session will maintain a conversation context and append new Items to the
* Conversation, thus output from previous turns (text and audio tokens) will
* become the input for later turns.
*/
export interface RealtimeResponseUsage {
/**
* Details about the input tokens used in the Response.
*/
input_token_details?: RealtimeResponseUsage.InputTokenDetails;
/**
* The number of input tokens used in the Response, including text and audio
* tokens.
*/
input_tokens?: number;
/**
* Details about the output tokens used in the Response.
*/
output_token_details?: RealtimeResponseUsage.OutputTokenDetails;
/**
* The number of output tokens sent in the Response, including text and audio
* tokens.
*/
output_tokens?: number;
/**
* The total number of tokens in the Response including input and output text and
* audio tokens.
*/
total_tokens?: number;
}
export declare namespace RealtimeResponseUsage {
/**
* Details about the input tokens used in the Response.
*/
interface InputTokenDetails {
/**
* The number of audio tokens used in the Response.
*/
audio_tokens?: number;
/**
* The number of cached tokens used in the Response.
*/
cached_tokens?: number;
/**
* The number of text tokens used in the Response.
*/
text_tokens?: number;
}
/**
* Details about the output tokens used in the Response.
*/
interface OutputTokenDetails {
/**
* The number of audio tokens used in the Response.
*/
audio_tokens?: number;
/**
* The number of text tokens used in the Response.
*/
text_tokens?: number;
}
}
/**
* A realtime server event.
*/
export type RealtimeServerEvent = ConversationCreatedEvent | ConversationItemCreatedEvent | ConversationItemDeletedEvent | ConversationItemInputAudioTranscriptionCompletedEvent | ConversationItemInputAudioTranscriptionDeltaEvent | ConversationItemInputAudioTranscriptionFailedEvent | RealtimeServerEvent.ConversationItemRetrieved | ConversationItemTruncatedEvent | ErrorEvent | InputAudioBufferClearedEvent | InputAudioBufferCommittedEvent | InputAudioBufferSpeechStartedEvent | InputAudioBufferSpeechStoppedEvent | RateLimitsUpdatedEvent | ResponseAudioDeltaEvent | ResponseAudioDoneEvent | ResponseAudioTranscriptDeltaEvent | ResponseAudioTranscriptDoneEvent | ResponseContentPartAddedEvent | ResponseContentPartDoneEvent | ResponseCreatedEvent | ResponseDoneEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseFunctionCallArgumentsDoneEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseTextDeltaEvent | ResponseTextDoneEvent | SessionCreatedEvent | SessionUpdatedEvent | TranscriptionSessionUpdatedEvent | RealtimeServerEvent.OutputAudioBufferStarted | RealtimeServerEvent.OutputAudioBufferStopped | RealtimeServerEvent.OutputAudioBufferCleared;
export declare namespace RealtimeServerEvent {
/**
* Returned when a conversation item is retrieved with
* `conversation.item.retrieve`.
*/
interface ConversationItemRetrieved {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The item to add to the conversation.
*/
item: RealtimeAPI.ConversationItem;
/**
* The event type, must be `conversation.item.retrieved`.
*/
type: 'conversation.item.retrieved';
}
/**
* **WebRTC Only:** Emitted when the server begins streaming audio to the client.
* This event is emitted after an audio content part has been added
* (`response.content_part.added`) to the response.
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
*/
interface OutputAudioBufferStarted {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The unique ID of the response that produced the audio.
*/
response_id: string;
/**
* The event type, must be `output_audio_buffer.started`.
*/
type: 'output_audio_buffer.started';
}
/**
* **WebRTC Only:** Emitted when the output audio buffer has been completely
* drained on the server, and no more audio is forthcoming. This event is emitted
* after the full response data has been sent to the client (`response.done`).
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
*/
interface OutputAudioBufferStopped {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The unique ID of the response that produced the audio.
*/
response_id: string;
/**
* The event type, must be `output_audio_buffer.stopped`.
*/
type: 'output_audio_buffer.stopped';
}
/**
* **WebRTC Only:** Emitted when the output audio buffer is cleared. This happens
* either in VAD mode when the user has interrupted
* (`input_audio_buffer.speech_started`), or when the client has emitted the
* `output_audio_buffer.clear` event to manually cut off the current audio
* response.
* [Learn more](https://platform.openai.com/docs/guides/realtime-conversations#client-and-server-events-for-audio-in-webrtc).
*/
interface OutputAudioBufferCleared {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The unique ID of the response that produced the audio.
*/
response_id: string;
/**
* The event type, must be `output_audio_buffer.cleared`.
*/
type: 'output_audio_buffer.cleared';
}
}
/**
* Returned when the model-generated audio is updated.
*/
export interface ResponseAudioDeltaEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* Base64-encoded audio data delta.
*/
delta: string;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.audio.delta`.
*/
type: 'response.audio.delta';
}
/**
* Returned when the model-generated audio is done. Also emitted when a Response is
* interrupted, incomplete, or cancelled.
*/
export interface ResponseAudioDoneEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.audio.done`.
*/
type: 'response.audio.done';
}
/**
* Returned when the model-generated transcription of audio output is updated.
*/
export interface ResponseAudioTranscriptDeltaEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The transcript delta.
*/
delta: string;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.audio_transcript.delta`.
*/
type: 'response.audio_transcript.delta';
}
/**
* Returned when the model-generated transcription of audio output is done
* streaming. Also emitted when a Response is interrupted, incomplete, or
* cancelled.
*/
export interface ResponseAudioTranscriptDoneEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The final transcript of the audio.
*/
transcript: string;
/**
* The event type, must be `response.audio_transcript.done`.
*/
type: 'response.audio_transcript.done';
}
/**
* Send this event to cancel an in-progress response. The server will respond with
* a `response.done` event with a status of `response.status=cancelled`. If there
* is no response to cancel, the server will respond with an error.
*/
export interface ResponseCancelEvent {
/**
* The event type, must be `response.cancel`.
*/
type: 'response.cancel';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
/**
* A specific response ID to cancel - if not provided, will cancel an in-progress
* response in the default conversation.
*/
response_id?: string;
}
/**
* Returned when a new content part is added to an assistant message item during
* response generation.
*/
export interface ResponseContentPartAddedEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item to which the content part was added.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The content part that was added.
*/
part: ResponseContentPartAddedEvent.Part;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.content_part.added`.
*/
type: 'response.content_part.added';
}
export declare namespace ResponseContentPartAddedEvent {
/**
* The content part that was added.
*/
interface Part {
/**
* Base64-encoded audio data (if type is "audio").
*/
audio?: string;
/**
* The text content (if type is "text").
*/
text?: string;
/**
* The transcript of the audio (if type is "audio").
*/
transcript?: string;
/**
* The content type ("text", "audio").
*/
type?: 'text' | 'audio';
}
}
/**
* Returned when a content part is done streaming in an assistant message item.
* Also emitted when a Response is interrupted, incomplete, or cancelled.
*/
export interface ResponseContentPartDoneEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The content part that is done.
*/
part: ResponseContentPartDoneEvent.Part;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.content_part.done`.
*/
type: 'response.content_part.done';
}
export declare namespace ResponseContentPartDoneEvent {
/**
* The content part that is done.
*/
interface Part {
/**
* Base64-encoded audio data (if type is "audio").
*/
audio?: string;
/**
* The text content (if type is "text").
*/
text?: string;
/**
* The transcript of the audio (if type is "audio").
*/
transcript?: string;
/**
* The content type ("text", "audio").
*/
type?: 'text' | 'audio';
}
}
/**
* This event instructs the server to create a Response, which means triggering
* model inference. When in Server VAD mode, the server will create Responses
* automatically.
*
* A Response will include at least one Item, and may have two, in which case the
* second will be a function call. These Items will be appended to the conversation
* history.
*
* The server will respond with a `response.created` event, events for Items and
* content created, and finally a `response.done` event to indicate the Response is
* complete.
*
* The `response.create` event includes inference configuration like
* `instructions`, and `temperature`. These fields will override the Session's
* configuration for this Response only.
*/
export interface ResponseCreateEvent {
/**
* The event type, must be `response.create`.
*/
type: 'response.create';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
/**
* Create a new Realtime response with these parameters
*/
response?: ResponseCreateEvent.Response;
}
export declare namespace ResponseCreateEvent {
/**
* Create a new Realtime response with these parameters
*/
interface Response {
/**
* Controls which conversation the response is added to. Currently supports `auto`
* and `none`, with `auto` as the default value. The `auto` value means that the
* contents of the response will be added to the default conversation. Set this to
* `none` to create an out-of-band response which will not add items to default
* conversation.
*/
conversation?: (string & {}) | 'auto' | 'none';
/**
* Input items to include in the prompt for the model. Using this field creates a
* new context for this Response instead of using the default conversation. An
* empty array `[]` will clear the context for this Response. Note that this can
* include references to items from the default conversation.
*/
input?: Array<RealtimeAPI.ConversationItemWithReference>;
/**
* The default system instructions (i.e. system message) prepended to model calls.
* This field allows the client to guide the model on desired responses. The model
* can be instructed on response content and format, (e.g. "be extremely succinct",
* "act friendly", "here are examples of good responses") and on audio behavior
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
* instructions are not guaranteed to be followed by the model, but they provide
* guidance to the model on the desired behavior.
*
* Note that the server sets default instructions which will be used if this field
* is not set and are visible in the `session.created` event at the start of the
* session.
*/
instructions?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
*/
max_response_output_tokens?: number | 'inf';
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
*/
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
*/
temperature?: number;
/**
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
* a function, like `{"type": "function", "function": {"name": "my_function"}}`.
*/
tool_choice?: string;
/**
* Tools (functions) available to the model.
*/
tools?: Array<Response.Tool>;
/**
* The voice the model uses to respond. Voice cannot be changed during the session
* once the model has responded with audio at least once. Current voice options are
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
namespace Response {
interface Tool {
/**
* The description of the function, including guidance on when and how to call it,
* and guidance about what to tell the user when calling (if anything).
*/
description?: string;
/**
* The name of the function.
*/
name?: string;
/**
* Parameters of the function in JSON Schema.
*/
parameters?: unknown;
/**
* The type of the tool, i.e. `function`.
*/
type?: 'function';
}
}
}
/**
* Returned when a new Response is created. The first event of response creation,
* where the response is in an initial state of `in_progress`.
*/
export interface ResponseCreatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The response resource.
*/
response: RealtimeResponse;
/**
* The event type, must be `response.created`.
*/
type: 'response.created';
}
/**
* Returned when a Response is done streaming. Always emitted, no matter the final
* state. The Response object included in the `response.done` event will include
* all output Items in the Response but will omit the raw audio data.
*/
export interface ResponseDoneEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The response resource.
*/
response: RealtimeResponse;
/**
* The event type, must be `response.done`.
*/
type: 'response.done';
}
/**
* Returned when the model-generated function call arguments are updated.
*/
export interface ResponseFunctionCallArgumentsDeltaEvent {
/**
* The ID of the function call.
*/
call_id: string;
/**
* The arguments delta as a JSON string.
*/
delta: string;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the function call item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.function_call_arguments.delta`.
*/
type: 'response.function_call_arguments.delta';
}
/**
* Returned when the model-generated function call arguments are done streaming.
* Also emitted when a Response is interrupted, incomplete, or cancelled.
*/
export interface ResponseFunctionCallArgumentsDoneEvent {
/**
* The final arguments as a JSON string.
*/
arguments: string;
/**
* The ID of the function call.
*/
call_id: string;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the function call item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.function_call_arguments.done`.
*/
type: 'response.function_call_arguments.done';
}
/**
* Returned when a new Item is created during Response generation.
*/
export interface ResponseOutputItemAddedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The item to add to the conversation.
*/
item: ConversationItem;
/**
* The index of the output item in the Response.
*/
output_index: number;
/**
* The ID of the Response to which the item belongs.
*/
response_id: string;
/**
* The event type, must be `response.output_item.added`.
*/
type: 'response.output_item.added';
}
/**
* Returned when an Item is done streaming. Also emitted when a Response is
* interrupted, incomplete, or cancelled.
*/
export interface ResponseOutputItemDoneEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The item to add to the conversation.
*/
item: ConversationItem;
/**
* The index of the output item in the Response.
*/
output_index: number;
/**
* The ID of the Response to which the item belongs.
*/
response_id: string;
/**
* The event type, must be `response.output_item.done`.
*/
type: 'response.output_item.done';
}
/**
* Returned when the text value of a "text" content part is updated.
*/
export interface ResponseTextDeltaEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The text delta.
*/
delta: string;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The event type, must be `response.text.delta`.
*/
type: 'response.text.delta';
}
/**
* Returned when the text value of a "text" content part is done streaming. Also
* emitted when a Response is interrupted, incomplete, or cancelled.
*/
export interface ResponseTextDoneEvent {
/**
* The index of the content part in the item's content array.
*/
content_index: number;
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* The ID of the item.
*/
item_id: string;
/**
* The index of the output item in the response.
*/
output_index: number;
/**
* The ID of the response.
*/
response_id: string;
/**
* The final text content.
*/
text: string;
/**
* The event type, must be `response.text.done`.
*/
type: 'response.text.done';
}
/**
* Returned when a Session is created. Emitted automatically when a new connection
* is established as the first server event. This event will contain the default
* Session configuration.
*/
export interface SessionCreatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* Realtime session object configuration.
*/
session: SessionsAPI.Session;
/**
* The event type, must be `session.created`.
*/
type: 'session.created';
}
/**
* Send this event to update the sessions default configuration. The client may
* send this event at any time to update any field, except for `voice`. However,
* note that once a session has been initialized with a particular `model`, it
* cant be changed to another model using `session.update`.
*
* When the server receives a `session.update`, it will respond with a
* `session.updated` event showing the full, effective configuration. Only the
* fields that are present are updated. To clear a field like `instructions`, pass
* an empty string.
*/
export interface SessionUpdateEvent {
/**
* Realtime session object configuration.
*/
session: SessionUpdateEvent.Session;
/**
* The event type, must be `session.update`.
*/
type: 'session.update';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
export declare namespace SessionUpdateEvent {
/**
* Realtime session object configuration.
*/
interface Session {
/**
* Configuration options for the generated client secret.
*/
client_secret?: Session.ClientSecret;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
* (mono), and little-endian byte order.
*/
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
input_audio_noise_reduction?: Session.InputAudioNoiseReduction;
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
input_audio_transcription?: Session.InputAudioTranscription;
/**
* The default system instructions (i.e. system message) prepended to model calls.
* This field allows the client to guide the model on desired responses. The model
* can be instructed on response content and format, (e.g. "be extremely succinct",
* "act friendly", "here are examples of good responses") and on audio behavior
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
* instructions are not guaranteed to be followed by the model, but they provide
* guidance to the model on the desired behavior.
*
* Note that the server sets default instructions which will be used if this field
* is not set and are visible in the `session.created` event at the start of the
* session.
*/
instructions?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
*/
max_response_output_tokens?: number | 'inf';
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* The Realtime model used for this session.
*/
model?: 'gpt-4o-realtime-preview' | 'gpt-4o-realtime-preview-2024-10-01' | 'gpt-4o-realtime-preview-2024-12-17' | 'gpt-4o-realtime-preview-2025-06-03' | 'gpt-4o-mini-realtime-preview' | 'gpt-4o-mini-realtime-preview-2024-12-17';
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
* For `pcm16`, output audio is sampled at a rate of 24kHz.
*/
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the
* minimum speed. 1.5 is the maximum speed. This value can only be changed in
* between model turns, not while a response is in progress.
*/
speed?: number;
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a
* temperature of 0.8 is highly recommended for best performance.
*/
temperature?: number;
/**
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
* a function.
*/
tool_choice?: string;
/**
* Tools (functions) available to the model.
*/
tools?: Array<Session.Tool>;
/**
* Configuration options for tracing. Set to null to disable tracing. Once tracing
* is enabled for a session, the configuration cannot be modified.
*
* `auto` will create a trace for the session with default values for the workflow
* name, group id, and metadata.
*/
tracing?: 'auto' | Session.TracingConfiguration;
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
turn_detection?: Session.TurnDetection;
/**
* The voice the model uses to respond. Voice cannot be changed during the session
* once the model has responded with audio at least once. Current voice options are
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
namespace Session {
/**
* Configuration options for the generated client secret.
*/
interface ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
expires_after?: ClientSecret.ExpiresAfter;
}
namespace ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
interface ExpiresAfter {
/**
* The anchor point for the ephemeral token expiration. Only `created_at` is
* currently supported.
*/
anchor: 'created_at';
/**
* The number of seconds from the anchor point to the expiration. Select a value
* between `10` and `7200`.
*/
seconds?: number;
}
}
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
interface InputAudioNoiseReduction {
/**
* Type of noise reduction. `near_field` is for close-talking microphones such as
* headphones, `far_field` is for far-field microphones such as laptop or
* conference room microphones.
*/
type?: 'near_field' | 'far_field';
}
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription, current options are `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, and `whisper-1`.
*/
model?: string;
/**
* An optional text to guide the model's style or continue a previous audio
* segment. For `whisper-1`, the
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
* "expect words related to technology".
*/
prompt?: string;
}
interface Tool {
/**
* The description of the function, including guidance on when and how to call it,
* and guidance about what to tell the user when calling (if anything).
*/
description?: string;
/**
* The name of the function.
*/
name?: string;
/**
* Parameters of the function in JSON Schema.
*/
parameters?: unknown;
/**
* The type of the tool, i.e. `function`.
*/
type?: 'function';
}
/**
* Granular configuration for tracing.
*/
interface TracingConfiguration {
/**
* The group id to attach to this trace to enable filtering and grouping in the
* traces dashboard.
*/
group_id?: string;
/**
* The arbitrary metadata to attach to this trace to enable filtering in the traces
* dashboard.
*/
metadata?: unknown;
/**
* The name of the workflow to attach to this trace. This is used to name the trace
* in the traces dashboard.
*/
workflow_name?: string;
}
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
interface TurnDetection {
/**
* Whether or not to automatically generate a response when a VAD stop event
* occurs.
*/
create_response?: boolean;
/**
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
* will wait longer for the user to continue speaking, `high` will respond more
* quickly. `auto` is the default and is equivalent to `medium`.
*/
eagerness?: 'low' | 'medium' | 'high' | 'auto';
/**
* Whether or not to automatically interrupt any ongoing response with output to
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
* occurs.
*/
interrupt_response?: boolean;
/**
* Used only for `server_vad` mode. Amount of audio to include before the VAD
* detected speech (in milliseconds). Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
* milliseconds). Defaults to 500ms. With shorter values the model will respond
* more quickly, but may jump in on short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
* defaults to 0.5. A higher threshold will require louder audio to activate the
* model, and thus might perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection.
*/
type?: 'server_vad' | 'semantic_vad';
}
}
}
/**
* Returned when a session is updated with a `session.update` event, unless there
* is an error.
*/
export interface SessionUpdatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* Realtime session object configuration.
*/
session: SessionsAPI.Session;
/**
* The event type, must be `session.updated`.
*/
type: 'session.updated';
}
/**
* Send this event to update a transcription session.
*/
export interface TranscriptionSessionUpdate {
/**
* Realtime transcription session object configuration.
*/
session: TranscriptionSessionUpdate.Session;
/**
* The event type, must be `transcription_session.update`.
*/
type: 'transcription_session.update';
/**
* Optional client-generated ID used to identify this event.
*/
event_id?: string;
}
export declare namespace TranscriptionSessionUpdate {
/**
* Realtime transcription session object configuration.
*/
interface Session {
/**
* Configuration options for the generated client secret.
*/
client_secret?: Session.ClientSecret;
/**
* The set of items to include in the transcription. Current available items are:
*
* - `item.input_audio_transcription.logprobs`
*/
include?: Array<string>;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
* (mono), and little-endian byte order.
*/
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
input_audio_noise_reduction?: Session.InputAudioNoiseReduction;
/**
* Configuration for input audio transcription. The client can optionally set the
* language and prompt for transcription, these offer additional guidance to the
* transcription service.
*/
input_audio_transcription?: Session.InputAudioTranscription;
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
turn_detection?: Session.TurnDetection;
}
namespace Session {
/**
* Configuration options for the generated client secret.
*/
interface ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
expires_at?: ClientSecret.ExpiresAt;
}
namespace ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
interface ExpiresAt {
/**
* The anchor point for the ephemeral token expiration. Only `created_at` is
* currently supported.
*/
anchor?: 'created_at';
/**
* The number of seconds from the anchor point to the expiration. Select a value
* between `10` and `7200`.
*/
seconds?: number;
}
}
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
interface InputAudioNoiseReduction {
/**
* Type of noise reduction. `near_field` is for close-talking microphones such as
* headphones, `far_field` is for far-field microphones such as laptop or
* conference room microphones.
*/
type?: 'near_field' | 'far_field';
}
/**
* Configuration for input audio transcription. The client can optionally set the
* language and prompt for transcription, these offer additional guidance to the
* transcription service.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription, current options are `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, and `whisper-1`.
*/
model?: 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe' | 'whisper-1';
/**
* An optional text to guide the model's style or continue a previous audio
* segment. For `whisper-1`, the
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
* "expect words related to technology".
*/
prompt?: string;
}
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
interface TurnDetection {
/**
* Whether or not to automatically generate a response when a VAD stop event
* occurs. Not available for transcription sessions.
*/
create_response?: boolean;
/**
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
* will wait longer for the user to continue speaking, `high` will respond more
* quickly. `auto` is the default and is equivalent to `medium`.
*/
eagerness?: 'low' | 'medium' | 'high' | 'auto';
/**
* Whether or not to automatically interrupt any ongoing response with output to
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
* occurs. Not available for transcription sessions.
*/
interrupt_response?: boolean;
/**
* Used only for `server_vad` mode. Amount of audio to include before the VAD
* detected speech (in milliseconds). Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
* milliseconds). Defaults to 500ms. With shorter values the model will respond
* more quickly, but may jump in on short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
* defaults to 0.5. A higher threshold will require louder audio to activate the
* model, and thus might perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection.
*/
type?: 'server_vad' | 'semantic_vad';
}
}
}
/**
* Returned when a transcription session is updated with a
* `transcription_session.update` event, unless there is an error.
*/
export interface TranscriptionSessionUpdatedEvent {
/**
* The unique ID of the server event.
*/
event_id: string;
/**
* A new Realtime transcription session configuration.
*
* When a session is created on the server via REST API, the session object also
* contains an ephemeral key. Default TTL for keys is 10 minutes. This property is
* not present when a session is updated via the WebSocket API.
*/
session: TranscriptionSessionsAPI.TranscriptionSession;
/**
* The event type, must be `transcription_session.updated`.
*/
type: 'transcription_session.updated';
}
export declare namespace Realtime {
export { type ConversationCreatedEvent as ConversationCreatedEvent, type ConversationItem as ConversationItem, type ConversationItemContent as ConversationItemContent, type ConversationItemCreateEvent as ConversationItemCreateEvent, type ConversationItemCreatedEvent as ConversationItemCreatedEvent, type ConversationItemDeleteEvent as ConversationItemDeleteEvent, type ConversationItemDeletedEvent as ConversationItemDeletedEvent, type ConversationItemInputAudioTranscriptionCompletedEvent as ConversationItemInputAudioTranscriptionCompletedEvent, type ConversationItemInputAudioTranscriptionDeltaEvent as ConversationItemInputAudioTranscriptionDeltaEvent, type ConversationItemInputAudioTranscriptionFailedEvent as ConversationItemInputAudioTranscriptionFailedEvent, type ConversationItemRetrieveEvent as ConversationItemRetrieveEvent, type ConversationItemTruncateEvent as ConversationItemTruncateEvent, type ConversationItemTruncatedEvent as ConversationItemTruncatedEvent, type ConversationItemWithReference as ConversationItemWithReference, type ErrorEvent as ErrorEvent, type InputAudioBufferAppendEvent as InputAudioBufferAppendEvent, type InputAudioBufferClearEvent as InputAudioBufferClearEvent, type InputAudioBufferClearedEvent as InputAudioBufferClearedEvent, type InputAudioBufferCommitEvent as InputAudioBufferCommitEvent, type InputAudioBufferCommittedEvent as InputAudioBufferCommittedEvent, type InputAudioBufferSpeechStartedEvent as InputAudioBufferSpeechStartedEvent, type InputAudioBufferSpeechStoppedEvent as InputAudioBufferSpeechStoppedEvent, type RateLimitsUpdatedEvent as RateLimitsUpdatedEvent, type RealtimeClientEvent as RealtimeClientEvent, type RealtimeResponse as RealtimeResponse, type RealtimeResponseStatus as RealtimeResponseStatus, type RealtimeResponseUsage as RealtimeResponseUsage, type RealtimeServerEvent as RealtimeServerEvent, type ResponseAudioDeltaEvent as ResponseAudioDeltaEvent, type ResponseAudioDoneEvent as ResponseAudioDoneEvent, type ResponseAudioTranscriptDeltaEvent as ResponseAudioTranscriptDeltaEvent, type ResponseAudioTranscriptDoneEvent as ResponseAudioTranscriptDoneEvent, type ResponseCancelEvent as ResponseCancelEvent, type ResponseContentPartAddedEvent as ResponseContentPartAddedEvent, type ResponseContentPartDoneEvent as ResponseContentPartDoneEvent, type ResponseCreateEvent as ResponseCreateEvent, type ResponseCreatedEvent as ResponseCreatedEvent, type ResponseDoneEvent as ResponseDoneEvent, type ResponseFunctionCallArgumentsDeltaEvent as ResponseFunctionCallArgumentsDeltaEvent, type ResponseFunctionCallArgumentsDoneEvent as ResponseFunctionCallArgumentsDoneEvent, type ResponseOutputItemAddedEvent as ResponseOutputItemAddedEvent, type ResponseOutputItemDoneEvent as ResponseOutputItemDoneEvent, type ResponseTextDeltaEvent as ResponseTextDeltaEvent, type ResponseTextDoneEvent as ResponseTextDoneEvent, type SessionCreatedEvent as SessionCreatedEvent, type SessionUpdateEvent as SessionUpdateEvent, type SessionUpdatedEvent as SessionUpdatedEvent, type TranscriptionSessionUpdate as TranscriptionSessionUpdate, type TranscriptionSessionUpdatedEvent as TranscriptionSessionUpdatedEvent, };
export { Sessions as Sessions, type SessionsAPISession as Session, type SessionCreateResponse as SessionCreateResponse, type SessionCreateParams as SessionCreateParams, };
export { TranscriptionSessions as TranscriptionSessions, type TranscriptionSession as TranscriptionSession, type TranscriptionSessionCreateParams as TranscriptionSessionCreateParams, };
}
//# sourceMappingURL=realtime.d.ts.map
File diff suppressed because one or more lines are too long
+24
View File
@@ -0,0 +1,24 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Realtime = void 0;
const tslib_1 = require("../../../internal/tslib.js");
const resource_1 = require("../../../core/resource.js");
const SessionsAPI = tslib_1.__importStar(require("./sessions.js"));
const sessions_1 = require("./sessions.js");
const TranscriptionSessionsAPI = tslib_1.__importStar(require("./transcription-sessions.js"));
const transcription_sessions_1 = require("./transcription-sessions.js");
/**
* @deprecated Realtime has now launched and is generally available. The old beta API is now deprecated.
*/
class Realtime extends resource_1.APIResource {
constructor() {
super(...arguments);
this.sessions = new SessionsAPI.Sessions(this._client);
this.transcriptionSessions = new TranscriptionSessionsAPI.TranscriptionSessions(this._client);
}
}
exports.Realtime = Realtime;
Realtime.Sessions = sessions_1.Sessions;
Realtime.TranscriptionSessions = transcription_sessions_1.TranscriptionSessions;
//# sourceMappingURL=realtime.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"realtime.js","sourceRoot":"","sources":["../../../src/resources/beta/realtime/realtime.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,wDAAqD;AAGrD,mEAA0C;AAC1C,4CAKoB;AACpB,8FAAqE;AACrE,wEAIkC;AAElC;;GAEG;AACH,MAAa,QAAS,SAAQ,sBAAW;IAAzC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxE,0BAAqB,GACnB,IAAI,wBAAwB,CAAC,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CAAA;AAJD,4BAIC;AA8qFD,QAAQ,CAAC,QAAQ,GAAG,mBAAQ,CAAC;AAC7B,QAAQ,CAAC,qBAAqB,GAAG,8CAAqB,CAAC"}
+19
View File
@@ -0,0 +1,19 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as SessionsAPI from "./sessions.mjs";
import { Sessions, } from "./sessions.mjs";
import * as TranscriptionSessionsAPI from "./transcription-sessions.mjs";
import { TranscriptionSessions, } from "./transcription-sessions.mjs";
/**
* @deprecated Realtime has now launched and is generally available. The old beta API is now deprecated.
*/
export class Realtime extends APIResource {
constructor() {
super(...arguments);
this.sessions = new SessionsAPI.Sessions(this._client);
this.transcriptionSessions = new TranscriptionSessionsAPI.TranscriptionSessions(this._client);
}
}
Realtime.Sessions = Sessions;
Realtime.TranscriptionSessions = TranscriptionSessions;
//# sourceMappingURL=realtime.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"realtime.mjs","sourceRoot":"","sources":["../../../src/resources/beta/realtime/realtime.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AAGrD,OAAO,KAAK,WAAW,uBAAmB;AAC1C,OAAO,EAIL,QAAQ,GACT,uBAAmB;AACpB,OAAO,KAAK,wBAAwB,qCAAiC;AACrE,OAAO,EAGL,qBAAqB,GACtB,qCAAiC;AAElC;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,WAAW;IAAzC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxE,0BAAqB,GACnB,IAAI,wBAAwB,CAAC,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CAAA;AA8qFD,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC7B,QAAQ,CAAC,qBAAqB,GAAG,qBAAqB,CAAC"}
+744
View File
@@ -0,0 +1,744 @@
import { APIResource } from "../../../core/resource.mjs";
import { APIPromise } from "../../../core/api-promise.mjs";
import { RequestOptions } from "../../../internal/request-options.mjs";
export declare class Sessions extends APIResource {
/**
* Create an ephemeral API token for use in client-side applications with the
* Realtime API. Can be configured with the same session parameters as the
* `session.update` client event.
*
* It responds with a session object, plus a `client_secret` key which contains a
* usable ephemeral API token that can be used to authenticate browser clients for
* the Realtime API.
*
* @example
* ```ts
* const session =
* await client.beta.realtime.sessions.create();
* ```
*/
create(body: SessionCreateParams, options?: RequestOptions): APIPromise<SessionCreateResponse>;
}
/**
* Realtime session object configuration.
*/
export interface Session {
/**
* Unique identifier for the session that looks like `sess_1234567890abcdef`.
*/
id?: string;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
* (mono), and little-endian byte order.
*/
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
input_audio_noise_reduction?: Session.InputAudioNoiseReduction;
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
input_audio_transcription?: Session.InputAudioTranscription;
/**
* The default system instructions (i.e. system message) prepended to model calls.
* This field allows the client to guide the model on desired responses. The model
* can be instructed on response content and format, (e.g. "be extremely succinct",
* "act friendly", "here are examples of good responses") and on audio behavior
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
* instructions are not guaranteed to be followed by the model, but they provide
* guidance to the model on the desired behavior.
*
* Note that the server sets default instructions which will be used if this field
* is not set and are visible in the `session.created` event at the start of the
* session.
*/
instructions?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
*/
max_response_output_tokens?: number | 'inf';
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* The Realtime model used for this session.
*/
model?: 'gpt-4o-realtime-preview' | 'gpt-4o-realtime-preview-2024-10-01' | 'gpt-4o-realtime-preview-2024-12-17' | 'gpt-4o-realtime-preview-2025-06-03' | 'gpt-4o-mini-realtime-preview' | 'gpt-4o-mini-realtime-preview-2024-12-17';
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
* For `pcm16`, output audio is sampled at a rate of 24kHz.
*/
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the
* minimum speed. 1.5 is the maximum speed. This value can only be changed in
* between model turns, not while a response is in progress.
*/
speed?: number;
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a
* temperature of 0.8 is highly recommended for best performance.
*/
temperature?: number;
/**
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
* a function.
*/
tool_choice?: string;
/**
* Tools (functions) available to the model.
*/
tools?: Array<Session.Tool>;
/**
* Configuration options for tracing. Set to null to disable tracing. Once tracing
* is enabled for a session, the configuration cannot be modified.
*
* `auto` will create a trace for the session with default values for the workflow
* name, group id, and metadata.
*/
tracing?: 'auto' | Session.TracingConfiguration;
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
turn_detection?: Session.TurnDetection;
/**
* The voice the model uses to respond. Voice cannot be changed during the session
* once the model has responded with audio at least once. Current voice options are
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
export declare namespace Session {
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
interface InputAudioNoiseReduction {
/**
* Type of noise reduction. `near_field` is for close-talking microphones such as
* headphones, `far_field` is for far-field microphones such as laptop or
* conference room microphones.
*/
type?: 'near_field' | 'far_field';
}
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription, current options are `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, and `whisper-1`.
*/
model?: string;
/**
* An optional text to guide the model's style or continue a previous audio
* segment. For `whisper-1`, the
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
* "expect words related to technology".
*/
prompt?: string;
}
interface Tool {
/**
* The description of the function, including guidance on when and how to call it,
* and guidance about what to tell the user when calling (if anything).
*/
description?: string;
/**
* The name of the function.
*/
name?: string;
/**
* Parameters of the function in JSON Schema.
*/
parameters?: unknown;
/**
* The type of the tool, i.e. `function`.
*/
type?: 'function';
}
/**
* Granular configuration for tracing.
*/
interface TracingConfiguration {
/**
* The group id to attach to this trace to enable filtering and grouping in the
* traces dashboard.
*/
group_id?: string;
/**
* The arbitrary metadata to attach to this trace to enable filtering in the traces
* dashboard.
*/
metadata?: unknown;
/**
* The name of the workflow to attach to this trace. This is used to name the trace
* in the traces dashboard.
*/
workflow_name?: string;
}
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
interface TurnDetection {
/**
* Whether or not to automatically generate a response when a VAD stop event
* occurs.
*/
create_response?: boolean;
/**
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
* will wait longer for the user to continue speaking, `high` will respond more
* quickly. `auto` is the default and is equivalent to `medium`.
*/
eagerness?: 'low' | 'medium' | 'high' | 'auto';
/**
* Whether or not to automatically interrupt any ongoing response with output to
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
* occurs.
*/
interrupt_response?: boolean;
/**
* Used only for `server_vad` mode. Amount of audio to include before the VAD
* detected speech (in milliseconds). Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
* milliseconds). Defaults to 500ms. With shorter values the model will respond
* more quickly, but may jump in on short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
* defaults to 0.5. A higher threshold will require louder audio to activate the
* model, and thus might perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection.
*/
type?: 'server_vad' | 'semantic_vad';
}
}
/**
* A new Realtime session configuration, with an ephemeral key. Default TTL for
* keys is one minute.
*/
export interface SessionCreateResponse {
/**
* Ephemeral key returned by the API.
*/
client_secret: SessionCreateResponse.ClientSecret;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
*/
input_audio_format?: string;
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously and should be treated as rough guidance rather than the
* representation understood by the model.
*/
input_audio_transcription?: SessionCreateResponse.InputAudioTranscription;
/**
* The default system instructions (i.e. system message) prepended to model calls.
* This field allows the client to guide the model on desired responses. The model
* can be instructed on response content and format, (e.g. "be extremely succinct",
* "act friendly", "here are examples of good responses") and on audio behavior
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
* instructions are not guaranteed to be followed by the model, but they provide
* guidance to the model on the desired behavior.
*
* Note that the server sets default instructions which will be used if this field
* is not set and are visible in the `session.created` event at the start of the
* session.
*/
instructions?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
*/
max_response_output_tokens?: number | 'inf';
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
*/
output_audio_format?: string;
/**
* The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the
* minimum speed. 1.5 is the maximum speed. This value can only be changed in
* between model turns, not while a response is in progress.
*/
speed?: number;
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
*/
temperature?: number;
/**
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
* a function.
*/
tool_choice?: string;
/**
* Tools (functions) available to the model.
*/
tools?: Array<SessionCreateResponse.Tool>;
/**
* Configuration options for tracing. Set to null to disable tracing. Once tracing
* is enabled for a session, the configuration cannot be modified.
*
* `auto` will create a trace for the session with default values for the workflow
* name, group id, and metadata.
*/
tracing?: 'auto' | SessionCreateResponse.TracingConfiguration;
/**
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
* means that the model will detect the start and end of speech based on audio
* volume and respond at the end of user speech.
*/
turn_detection?: SessionCreateResponse.TurnDetection;
/**
* The voice the model uses to respond. Voice cannot be changed during the session
* once the model has responded with audio at least once. Current voice options are
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
export declare namespace SessionCreateResponse {
/**
* Ephemeral key returned by the API.
*/
interface ClientSecret {
/**
* Timestamp for when the token expires. Currently, all tokens expire after one
* minute.
*/
expires_at: number;
/**
* Ephemeral key usable in client environments to authenticate connections to the
* Realtime API. Use this in client-side environments rather than a standard API
* token, which should only be used server-side.
*/
value: string;
}
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously and should be treated as rough guidance rather than the
* representation understood by the model.
*/
interface InputAudioTranscription {
/**
* The model to use for transcription.
*/
model?: string;
}
interface Tool {
/**
* The description of the function, including guidance on when and how to call it,
* and guidance about what to tell the user when calling (if anything).
*/
description?: string;
/**
* The name of the function.
*/
name?: string;
/**
* Parameters of the function in JSON Schema.
*/
parameters?: unknown;
/**
* The type of the tool, i.e. `function`.
*/
type?: 'function';
}
/**
* Granular configuration for tracing.
*/
interface TracingConfiguration {
/**
* The group id to attach to this trace to enable filtering and grouping in the
* traces dashboard.
*/
group_id?: string;
/**
* The arbitrary metadata to attach to this trace to enable filtering in the traces
* dashboard.
*/
metadata?: unknown;
/**
* The name of the workflow to attach to this trace. This is used to name the trace
* in the traces dashboard.
*/
workflow_name?: string;
}
/**
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
* means that the model will detect the start and end of speech based on audio
* volume and respond at the end of user speech.
*/
interface TurnDetection {
/**
* Amount of audio to include before the VAD detected speech (in milliseconds).
* Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms.
* With shorter values the model will respond more quickly, but may jump in on
* short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher
* threshold will require louder audio to activate the model, and thus might
* perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection, only `server_vad` is currently supported.
*/
type?: string;
}
}
export interface SessionCreateParams {
/**
* Configuration options for the generated client secret.
*/
client_secret?: SessionCreateParams.ClientSecret;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
* (mono), and little-endian byte order.
*/
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
input_audio_noise_reduction?: SessionCreateParams.InputAudioNoiseReduction;
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
input_audio_transcription?: SessionCreateParams.InputAudioTranscription;
/**
* The default system instructions (i.e. system message) prepended to model calls.
* This field allows the client to guide the model on desired responses. The model
* can be instructed on response content and format, (e.g. "be extremely succinct",
* "act friendly", "here are examples of good responses") and on audio behavior
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
* instructions are not guaranteed to be followed by the model, but they provide
* guidance to the model on the desired behavior.
*
* Note that the server sets default instructions which will be used if this field
* is not set and are visible in the `session.created` event at the start of the
* session.
*/
instructions?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
*/
max_response_output_tokens?: number | 'inf';
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* The Realtime model used for this session.
*/
model?: 'gpt-4o-realtime-preview' | 'gpt-4o-realtime-preview-2024-10-01' | 'gpt-4o-realtime-preview-2024-12-17' | 'gpt-4o-realtime-preview-2025-06-03' | 'gpt-4o-mini-realtime-preview' | 'gpt-4o-mini-realtime-preview-2024-12-17';
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
* For `pcm16`, output audio is sampled at a rate of 24kHz.
*/
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the
* minimum speed. 1.5 is the maximum speed. This value can only be changed in
* between model turns, not while a response is in progress.
*/
speed?: number;
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a
* temperature of 0.8 is highly recommended for best performance.
*/
temperature?: number;
/**
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
* a function.
*/
tool_choice?: string;
/**
* Tools (functions) available to the model.
*/
tools?: Array<SessionCreateParams.Tool>;
/**
* Configuration options for tracing. Set to null to disable tracing. Once tracing
* is enabled for a session, the configuration cannot be modified.
*
* `auto` will create a trace for the session with default values for the workflow
* name, group id, and metadata.
*/
tracing?: 'auto' | SessionCreateParams.TracingConfiguration;
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
turn_detection?: SessionCreateParams.TurnDetection;
/**
* The voice the model uses to respond. Voice cannot be changed during the session
* once the model has responded with audio at least once. Current voice options are
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
export declare namespace SessionCreateParams {
/**
* Configuration options for the generated client secret.
*/
interface ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
expires_after?: ClientSecret.ExpiresAfter;
}
namespace ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
interface ExpiresAfter {
/**
* The anchor point for the ephemeral token expiration. Only `created_at` is
* currently supported.
*/
anchor: 'created_at';
/**
* The number of seconds from the anchor point to the expiration. Select a value
* between `10` and `7200`.
*/
seconds?: number;
}
}
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
interface InputAudioNoiseReduction {
/**
* Type of noise reduction. `near_field` is for close-talking microphones such as
* headphones, `far_field` is for far-field microphones such as laptop or
* conference room microphones.
*/
type?: 'near_field' | 'far_field';
}
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription, current options are `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, and `whisper-1`.
*/
model?: string;
/**
* An optional text to guide the model's style or continue a previous audio
* segment. For `whisper-1`, the
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
* "expect words related to technology".
*/
prompt?: string;
}
interface Tool {
/**
* The description of the function, including guidance on when and how to call it,
* and guidance about what to tell the user when calling (if anything).
*/
description?: string;
/**
* The name of the function.
*/
name?: string;
/**
* Parameters of the function in JSON Schema.
*/
parameters?: unknown;
/**
* The type of the tool, i.e. `function`.
*/
type?: 'function';
}
/**
* Granular configuration for tracing.
*/
interface TracingConfiguration {
/**
* The group id to attach to this trace to enable filtering and grouping in the
* traces dashboard.
*/
group_id?: string;
/**
* The arbitrary metadata to attach to this trace to enable filtering in the traces
* dashboard.
*/
metadata?: unknown;
/**
* The name of the workflow to attach to this trace. This is used to name the trace
* in the traces dashboard.
*/
workflow_name?: string;
}
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
interface TurnDetection {
/**
* Whether or not to automatically generate a response when a VAD stop event
* occurs.
*/
create_response?: boolean;
/**
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
* will wait longer for the user to continue speaking, `high` will respond more
* quickly. `auto` is the default and is equivalent to `medium`.
*/
eagerness?: 'low' | 'medium' | 'high' | 'auto';
/**
* Whether or not to automatically interrupt any ongoing response with output to
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
* occurs.
*/
interrupt_response?: boolean;
/**
* Used only for `server_vad` mode. Amount of audio to include before the VAD
* detected speech (in milliseconds). Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
* milliseconds). Defaults to 500ms. With shorter values the model will respond
* more quickly, but may jump in on short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
* defaults to 0.5. A higher threshold will require louder audio to activate the
* model, and thus might perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection.
*/
type?: 'server_vad' | 'semantic_vad';
}
}
export declare namespace Sessions {
export { type Session as Session, type SessionCreateResponse as SessionCreateResponse, type SessionCreateParams as SessionCreateParams, };
}
//# sourceMappingURL=sessions.d.mts.map
File diff suppressed because one or more lines are too long
+744
View File
@@ -0,0 +1,744 @@
import { APIResource } from "../../../core/resource.js";
import { APIPromise } from "../../../core/api-promise.js";
import { RequestOptions } from "../../../internal/request-options.js";
export declare class Sessions extends APIResource {
/**
* Create an ephemeral API token for use in client-side applications with the
* Realtime API. Can be configured with the same session parameters as the
* `session.update` client event.
*
* It responds with a session object, plus a `client_secret` key which contains a
* usable ephemeral API token that can be used to authenticate browser clients for
* the Realtime API.
*
* @example
* ```ts
* const session =
* await client.beta.realtime.sessions.create();
* ```
*/
create(body: SessionCreateParams, options?: RequestOptions): APIPromise<SessionCreateResponse>;
}
/**
* Realtime session object configuration.
*/
export interface Session {
/**
* Unique identifier for the session that looks like `sess_1234567890abcdef`.
*/
id?: string;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
* (mono), and little-endian byte order.
*/
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
input_audio_noise_reduction?: Session.InputAudioNoiseReduction;
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
input_audio_transcription?: Session.InputAudioTranscription;
/**
* The default system instructions (i.e. system message) prepended to model calls.
* This field allows the client to guide the model on desired responses. The model
* can be instructed on response content and format, (e.g. "be extremely succinct",
* "act friendly", "here are examples of good responses") and on audio behavior
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
* instructions are not guaranteed to be followed by the model, but they provide
* guidance to the model on the desired behavior.
*
* Note that the server sets default instructions which will be used if this field
* is not set and are visible in the `session.created` event at the start of the
* session.
*/
instructions?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
*/
max_response_output_tokens?: number | 'inf';
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* The Realtime model used for this session.
*/
model?: 'gpt-4o-realtime-preview' | 'gpt-4o-realtime-preview-2024-10-01' | 'gpt-4o-realtime-preview-2024-12-17' | 'gpt-4o-realtime-preview-2025-06-03' | 'gpt-4o-mini-realtime-preview' | 'gpt-4o-mini-realtime-preview-2024-12-17';
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
* For `pcm16`, output audio is sampled at a rate of 24kHz.
*/
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the
* minimum speed. 1.5 is the maximum speed. This value can only be changed in
* between model turns, not while a response is in progress.
*/
speed?: number;
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a
* temperature of 0.8 is highly recommended for best performance.
*/
temperature?: number;
/**
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
* a function.
*/
tool_choice?: string;
/**
* Tools (functions) available to the model.
*/
tools?: Array<Session.Tool>;
/**
* Configuration options for tracing. Set to null to disable tracing. Once tracing
* is enabled for a session, the configuration cannot be modified.
*
* `auto` will create a trace for the session with default values for the workflow
* name, group id, and metadata.
*/
tracing?: 'auto' | Session.TracingConfiguration;
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
turn_detection?: Session.TurnDetection;
/**
* The voice the model uses to respond. Voice cannot be changed during the session
* once the model has responded with audio at least once. Current voice options are
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
export declare namespace Session {
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
interface InputAudioNoiseReduction {
/**
* Type of noise reduction. `near_field` is for close-talking microphones such as
* headphones, `far_field` is for far-field microphones such as laptop or
* conference room microphones.
*/
type?: 'near_field' | 'far_field';
}
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription, current options are `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, and `whisper-1`.
*/
model?: string;
/**
* An optional text to guide the model's style or continue a previous audio
* segment. For `whisper-1`, the
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
* "expect words related to technology".
*/
prompt?: string;
}
interface Tool {
/**
* The description of the function, including guidance on when and how to call it,
* and guidance about what to tell the user when calling (if anything).
*/
description?: string;
/**
* The name of the function.
*/
name?: string;
/**
* Parameters of the function in JSON Schema.
*/
parameters?: unknown;
/**
* The type of the tool, i.e. `function`.
*/
type?: 'function';
}
/**
* Granular configuration for tracing.
*/
interface TracingConfiguration {
/**
* The group id to attach to this trace to enable filtering and grouping in the
* traces dashboard.
*/
group_id?: string;
/**
* The arbitrary metadata to attach to this trace to enable filtering in the traces
* dashboard.
*/
metadata?: unknown;
/**
* The name of the workflow to attach to this trace. This is used to name the trace
* in the traces dashboard.
*/
workflow_name?: string;
}
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
interface TurnDetection {
/**
* Whether or not to automatically generate a response when a VAD stop event
* occurs.
*/
create_response?: boolean;
/**
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
* will wait longer for the user to continue speaking, `high` will respond more
* quickly. `auto` is the default and is equivalent to `medium`.
*/
eagerness?: 'low' | 'medium' | 'high' | 'auto';
/**
* Whether or not to automatically interrupt any ongoing response with output to
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
* occurs.
*/
interrupt_response?: boolean;
/**
* Used only for `server_vad` mode. Amount of audio to include before the VAD
* detected speech (in milliseconds). Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
* milliseconds). Defaults to 500ms. With shorter values the model will respond
* more quickly, but may jump in on short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
* defaults to 0.5. A higher threshold will require louder audio to activate the
* model, and thus might perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection.
*/
type?: 'server_vad' | 'semantic_vad';
}
}
/**
* A new Realtime session configuration, with an ephemeral key. Default TTL for
* keys is one minute.
*/
export interface SessionCreateResponse {
/**
* Ephemeral key returned by the API.
*/
client_secret: SessionCreateResponse.ClientSecret;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
*/
input_audio_format?: string;
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously and should be treated as rough guidance rather than the
* representation understood by the model.
*/
input_audio_transcription?: SessionCreateResponse.InputAudioTranscription;
/**
* The default system instructions (i.e. system message) prepended to model calls.
* This field allows the client to guide the model on desired responses. The model
* can be instructed on response content and format, (e.g. "be extremely succinct",
* "act friendly", "here are examples of good responses") and on audio behavior
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
* instructions are not guaranteed to be followed by the model, but they provide
* guidance to the model on the desired behavior.
*
* Note that the server sets default instructions which will be used if this field
* is not set and are visible in the `session.created` event at the start of the
* session.
*/
instructions?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
*/
max_response_output_tokens?: number | 'inf';
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
*/
output_audio_format?: string;
/**
* The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the
* minimum speed. 1.5 is the maximum speed. This value can only be changed in
* between model turns, not while a response is in progress.
*/
speed?: number;
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
*/
temperature?: number;
/**
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
* a function.
*/
tool_choice?: string;
/**
* Tools (functions) available to the model.
*/
tools?: Array<SessionCreateResponse.Tool>;
/**
* Configuration options for tracing. Set to null to disable tracing. Once tracing
* is enabled for a session, the configuration cannot be modified.
*
* `auto` will create a trace for the session with default values for the workflow
* name, group id, and metadata.
*/
tracing?: 'auto' | SessionCreateResponse.TracingConfiguration;
/**
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
* means that the model will detect the start and end of speech based on audio
* volume and respond at the end of user speech.
*/
turn_detection?: SessionCreateResponse.TurnDetection;
/**
* The voice the model uses to respond. Voice cannot be changed during the session
* once the model has responded with audio at least once. Current voice options are
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
export declare namespace SessionCreateResponse {
/**
* Ephemeral key returned by the API.
*/
interface ClientSecret {
/**
* Timestamp for when the token expires. Currently, all tokens expire after one
* minute.
*/
expires_at: number;
/**
* Ephemeral key usable in client environments to authenticate connections to the
* Realtime API. Use this in client-side environments rather than a standard API
* token, which should only be used server-side.
*/
value: string;
}
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously and should be treated as rough guidance rather than the
* representation understood by the model.
*/
interface InputAudioTranscription {
/**
* The model to use for transcription.
*/
model?: string;
}
interface Tool {
/**
* The description of the function, including guidance on when and how to call it,
* and guidance about what to tell the user when calling (if anything).
*/
description?: string;
/**
* The name of the function.
*/
name?: string;
/**
* Parameters of the function in JSON Schema.
*/
parameters?: unknown;
/**
* The type of the tool, i.e. `function`.
*/
type?: 'function';
}
/**
* Granular configuration for tracing.
*/
interface TracingConfiguration {
/**
* The group id to attach to this trace to enable filtering and grouping in the
* traces dashboard.
*/
group_id?: string;
/**
* The arbitrary metadata to attach to this trace to enable filtering in the traces
* dashboard.
*/
metadata?: unknown;
/**
* The name of the workflow to attach to this trace. This is used to name the trace
* in the traces dashboard.
*/
workflow_name?: string;
}
/**
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
* means that the model will detect the start and end of speech based on audio
* volume and respond at the end of user speech.
*/
interface TurnDetection {
/**
* Amount of audio to include before the VAD detected speech (in milliseconds).
* Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms.
* With shorter values the model will respond more quickly, but may jump in on
* short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher
* threshold will require louder audio to activate the model, and thus might
* perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection, only `server_vad` is currently supported.
*/
type?: string;
}
}
export interface SessionCreateParams {
/**
* Configuration options for the generated client secret.
*/
client_secret?: SessionCreateParams.ClientSecret;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
* (mono), and little-endian byte order.
*/
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
input_audio_noise_reduction?: SessionCreateParams.InputAudioNoiseReduction;
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
input_audio_transcription?: SessionCreateParams.InputAudioTranscription;
/**
* The default system instructions (i.e. system message) prepended to model calls.
* This field allows the client to guide the model on desired responses. The model
* can be instructed on response content and format, (e.g. "be extremely succinct",
* "act friendly", "here are examples of good responses") and on audio behavior
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
* instructions are not guaranteed to be followed by the model, but they provide
* guidance to the model on the desired behavior.
*
* Note that the server sets default instructions which will be used if this field
* is not set and are visible in the `session.created` event at the start of the
* session.
*/
instructions?: string;
/**
* Maximum number of output tokens for a single assistant response, inclusive of
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
*/
max_response_output_tokens?: number | 'inf';
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* The Realtime model used for this session.
*/
model?: 'gpt-4o-realtime-preview' | 'gpt-4o-realtime-preview-2024-10-01' | 'gpt-4o-realtime-preview-2024-12-17' | 'gpt-4o-realtime-preview-2025-06-03' | 'gpt-4o-mini-realtime-preview' | 'gpt-4o-mini-realtime-preview-2024-12-17';
/**
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
* For `pcm16`, output audio is sampled at a rate of 24kHz.
*/
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the
* minimum speed. 1.5 is the maximum speed. This value can only be changed in
* between model turns, not while a response is in progress.
*/
speed?: number;
/**
* Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a
* temperature of 0.8 is highly recommended for best performance.
*/
temperature?: number;
/**
* How the model chooses tools. Options are `auto`, `none`, `required`, or specify
* a function.
*/
tool_choice?: string;
/**
* Tools (functions) available to the model.
*/
tools?: Array<SessionCreateParams.Tool>;
/**
* Configuration options for tracing. Set to null to disable tracing. Once tracing
* is enabled for a session, the configuration cannot be modified.
*
* `auto` will create a trace for the session with default values for the workflow
* name, group id, and metadata.
*/
tracing?: 'auto' | SessionCreateParams.TracingConfiguration;
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
turn_detection?: SessionCreateParams.TurnDetection;
/**
* The voice the model uses to respond. Voice cannot be changed during the session
* once the model has responded with audio at least once. Current voice options are
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
*/
voice?: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
}
export declare namespace SessionCreateParams {
/**
* Configuration options for the generated client secret.
*/
interface ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
expires_after?: ClientSecret.ExpiresAfter;
}
namespace ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
interface ExpiresAfter {
/**
* The anchor point for the ephemeral token expiration. Only `created_at` is
* currently supported.
*/
anchor: 'created_at';
/**
* The number of seconds from the anchor point to the expiration. Select a value
* between `10` and `7200`.
*/
seconds?: number;
}
}
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
interface InputAudioNoiseReduction {
/**
* Type of noise reduction. `near_field` is for close-talking microphones such as
* headphones, `far_field` is for far-field microphones such as laptop or
* conference room microphones.
*/
type?: 'near_field' | 'far_field';
}
/**
* Configuration for input audio transcription, defaults to off and can be set to
* `null` to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs
* asynchronously through
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
* and should be treated as guidance of input audio content rather than precisely
* what the model heard. The client can optionally set the language and prompt for
* transcription, these offer additional guidance to the transcription service.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription, current options are `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, and `whisper-1`.
*/
model?: string;
/**
* An optional text to guide the model's style or continue a previous audio
* segment. For `whisper-1`, the
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
* "expect words related to technology".
*/
prompt?: string;
}
interface Tool {
/**
* The description of the function, including guidance on when and how to call it,
* and guidance about what to tell the user when calling (if anything).
*/
description?: string;
/**
* The name of the function.
*/
name?: string;
/**
* Parameters of the function in JSON Schema.
*/
parameters?: unknown;
/**
* The type of the tool, i.e. `function`.
*/
type?: 'function';
}
/**
* Granular configuration for tracing.
*/
interface TracingConfiguration {
/**
* The group id to attach to this trace to enable filtering and grouping in the
* traces dashboard.
*/
group_id?: string;
/**
* The arbitrary metadata to attach to this trace to enable filtering in the traces
* dashboard.
*/
metadata?: unknown;
/**
* The name of the workflow to attach to this trace. This is used to name the trace
* in the traces dashboard.
*/
workflow_name?: string;
}
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
interface TurnDetection {
/**
* Whether or not to automatically generate a response when a VAD stop event
* occurs.
*/
create_response?: boolean;
/**
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
* will wait longer for the user to continue speaking, `high` will respond more
* quickly. `auto` is the default and is equivalent to `medium`.
*/
eagerness?: 'low' | 'medium' | 'high' | 'auto';
/**
* Whether or not to automatically interrupt any ongoing response with output to
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
* occurs.
*/
interrupt_response?: boolean;
/**
* Used only for `server_vad` mode. Amount of audio to include before the VAD
* detected speech (in milliseconds). Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
* milliseconds). Defaults to 500ms. With shorter values the model will respond
* more quickly, but may jump in on short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
* defaults to 0.5. A higher threshold will require louder audio to activate the
* model, and thus might perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection.
*/
type?: 'server_vad' | 'semantic_vad';
}
}
export declare namespace Sessions {
export { type Session as Session, type SessionCreateResponse as SessionCreateResponse, type SessionCreateParams as SessionCreateParams, };
}
//# sourceMappingURL=sessions.d.ts.map
File diff suppressed because one or more lines are too long
+33
View File
@@ -0,0 +1,33 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Sessions = void 0;
const resource_1 = require("../../../core/resource.js");
const headers_1 = require("../../../internal/headers.js");
class Sessions extends resource_1.APIResource {
/**
* Create an ephemeral API token for use in client-side applications with the
* Realtime API. Can be configured with the same session parameters as the
* `session.update` client event.
*
* It responds with a session object, plus a `client_secret` key which contains a
* usable ephemeral API token that can be used to authenticate browser clients for
* the Realtime API.
*
* @example
* ```ts
* const session =
* await client.beta.realtime.sessions.create();
* ```
*/
create(body, options) {
return this._client.post('/realtime/sessions', {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
exports.Sessions = Sessions;
//# sourceMappingURL=sessions.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../src/resources/beta/realtime/sessions.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wDAAqD;AAErD,0DAAyD;AAGzD,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAyB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC7C,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AAxBD,4BAwBC"}
+29
View File
@@ -0,0 +1,29 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { buildHeaders } from "../../../internal/headers.mjs";
export class Sessions extends APIResource {
/**
* Create an ephemeral API token for use in client-side applications with the
* Realtime API. Can be configured with the same session parameters as the
* `session.update` client event.
*
* It responds with a session object, plus a `client_secret` key which contains a
* usable ephemeral API token that can be used to authenticate browser clients for
* the Realtime API.
*
* @example
* ```ts
* const session =
* await client.beta.realtime.sessions.create();
* ```
*/
create(body, options) {
return this._client.post('/realtime/sessions', {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
//# sourceMappingURL=sessions.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"sessions.mjs","sourceRoot":"","sources":["../../../src/resources/beta/realtime/sessions.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AAErD,OAAO,EAAE,YAAY,EAAE,sCAAkC;AAGzD,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAyB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC7C,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,299 @@
import { APIResource } from "../../../core/resource.mjs";
import { APIPromise } from "../../../core/api-promise.mjs";
import { RequestOptions } from "../../../internal/request-options.mjs";
export declare class TranscriptionSessions extends APIResource {
/**
* Create an ephemeral API token for use in client-side applications with the
* Realtime API specifically for realtime transcriptions. Can be configured with
* the same session parameters as the `transcription_session.update` client event.
*
* It responds with a session object, plus a `client_secret` key which contains a
* usable ephemeral API token that can be used to authenticate browser clients for
* the Realtime API.
*
* @example
* ```ts
* const transcriptionSession =
* await client.beta.realtime.transcriptionSessions.create();
* ```
*/
create(body: TranscriptionSessionCreateParams, options?: RequestOptions): APIPromise<TranscriptionSession>;
}
/**
* A new Realtime transcription session configuration.
*
* When a session is created on the server via REST API, the session object also
* contains an ephemeral key. Default TTL for keys is 10 minutes. This property is
* not present when a session is updated via the WebSocket API.
*/
export interface TranscriptionSession {
/**
* Ephemeral key returned by the API. Only present when the session is created on
* the server via REST API.
*/
client_secret: TranscriptionSession.ClientSecret;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
*/
input_audio_format?: string;
/**
* Configuration of the transcription model.
*/
input_audio_transcription?: TranscriptionSession.InputAudioTranscription;
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
* means that the model will detect the start and end of speech based on audio
* volume and respond at the end of user speech.
*/
turn_detection?: TranscriptionSession.TurnDetection;
}
export declare namespace TranscriptionSession {
/**
* Ephemeral key returned by the API. Only present when the session is created on
* the server via REST API.
*/
interface ClientSecret {
/**
* Timestamp for when the token expires. Currently, all tokens expire after one
* minute.
*/
expires_at: number;
/**
* Ephemeral key usable in client environments to authenticate connections to the
* Realtime API. Use this in client-side environments rather than a standard API
* token, which should only be used server-side.
*/
value: string;
}
/**
* Configuration of the transcription model.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription. Can be `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, or `whisper-1`.
*/
model?: 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe' | 'whisper-1';
/**
* An optional text to guide the model's style or continue a previous audio
* segment. The
* [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
* should match the audio language.
*/
prompt?: string;
}
/**
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
* means that the model will detect the start and end of speech based on audio
* volume and respond at the end of user speech.
*/
interface TurnDetection {
/**
* Amount of audio to include before the VAD detected speech (in milliseconds).
* Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms.
* With shorter values the model will respond more quickly, but may jump in on
* short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher
* threshold will require louder audio to activate the model, and thus might
* perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection, only `server_vad` is currently supported.
*/
type?: string;
}
}
export interface TranscriptionSessionCreateParams {
/**
* Configuration options for the generated client secret.
*/
client_secret?: TranscriptionSessionCreateParams.ClientSecret;
/**
* The set of items to include in the transcription. Current available items are:
*
* - `item.input_audio_transcription.logprobs`
*/
include?: Array<string>;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
* (mono), and little-endian byte order.
*/
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
input_audio_noise_reduction?: TranscriptionSessionCreateParams.InputAudioNoiseReduction;
/**
* Configuration for input audio transcription. The client can optionally set the
* language and prompt for transcription, these offer additional guidance to the
* transcription service.
*/
input_audio_transcription?: TranscriptionSessionCreateParams.InputAudioTranscription;
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
turn_detection?: TranscriptionSessionCreateParams.TurnDetection;
}
export declare namespace TranscriptionSessionCreateParams {
/**
* Configuration options for the generated client secret.
*/
interface ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
expires_at?: ClientSecret.ExpiresAt;
}
namespace ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
interface ExpiresAt {
/**
* The anchor point for the ephemeral token expiration. Only `created_at` is
* currently supported.
*/
anchor?: 'created_at';
/**
* The number of seconds from the anchor point to the expiration. Select a value
* between `10` and `7200`.
*/
seconds?: number;
}
}
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
interface InputAudioNoiseReduction {
/**
* Type of noise reduction. `near_field` is for close-talking microphones such as
* headphones, `far_field` is for far-field microphones such as laptop or
* conference room microphones.
*/
type?: 'near_field' | 'far_field';
}
/**
* Configuration for input audio transcription. The client can optionally set the
* language and prompt for transcription, these offer additional guidance to the
* transcription service.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription, current options are `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, and `whisper-1`.
*/
model?: 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe' | 'whisper-1';
/**
* An optional text to guide the model's style or continue a previous audio
* segment. For `whisper-1`, the
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
* "expect words related to technology".
*/
prompt?: string;
}
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
interface TurnDetection {
/**
* Whether or not to automatically generate a response when a VAD stop event
* occurs. Not available for transcription sessions.
*/
create_response?: boolean;
/**
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
* will wait longer for the user to continue speaking, `high` will respond more
* quickly. `auto` is the default and is equivalent to `medium`.
*/
eagerness?: 'low' | 'medium' | 'high' | 'auto';
/**
* Whether or not to automatically interrupt any ongoing response with output to
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
* occurs. Not available for transcription sessions.
*/
interrupt_response?: boolean;
/**
* Used only for `server_vad` mode. Amount of audio to include before the VAD
* detected speech (in milliseconds). Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
* milliseconds). Defaults to 500ms. With shorter values the model will respond
* more quickly, but may jump in on short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
* defaults to 0.5. A higher threshold will require louder audio to activate the
* model, and thus might perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection.
*/
type?: 'server_vad' | 'semantic_vad';
}
}
export declare namespace TranscriptionSessions {
export { type TranscriptionSession as TranscriptionSession, type TranscriptionSessionCreateParams as TranscriptionSessionCreateParams, };
}
//# sourceMappingURL=transcription-sessions.d.mts.map
@@ -0,0 +1 @@
{"version":3,"file":"transcription-sessions.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/realtime/transcription-sessions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,mCAA+B;AACrD,OAAO,EAAE,UAAU,EAAE,sCAAkC;AAEvD,OAAO,EAAE,cAAc,EAAE,8CAA0C;AAEnE,qBAAa,qBAAsB,SAAQ,WAAW;IACpD;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAI,EAAE,gCAAgC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,oBAAoB,CAAC;CAQ3G;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,aAAa,EAAE,oBAAoB,CAAC,YAAY,CAAC;IAEjD;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,yBAAyB,CAAC,EAAE,oBAAoB,CAAC,uBAAuB,CAAC;IAEzE;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;IAErC;;;;OAIG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC,aAAa,CAAC;CACrD;AAED,yBAAiB,oBAAoB,CAAC;IACpC;;;OAGG;IACH,UAAiB,YAAY;QAC3B;;;WAGG;QACH,UAAU,EAAE,MAAM,CAAC;QAEnB;;;;WAIG;QACH,KAAK,EAAE,MAAM,CAAC;KACf;IAED;;OAEG;IACH,UAAiB,uBAAuB;QACtC;;;;WAIG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAElB;;;WAGG;QACH,KAAK,CAAC,EAAE,mBAAmB,GAAG,wBAAwB,GAAG,WAAW,CAAC;QAErE;;;;;WAKG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAED;;;;OAIG;IACH,UAAiB,aAAa;QAC5B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAE3B;;;;WAIG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAE7B;;;;WAIG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;CACF;AAED,MAAM,WAAW,gCAAgC;IAC/C;;OAEG;IACH,aAAa,CAAC,EAAE,gCAAgC,CAAC,YAAY,CAAC;IAE9D;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAExB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;IAEzD;;;;;;OAMG;IACH,2BAA2B,CAAC,EAAE,gCAAgC,CAAC,wBAAwB,CAAC;IAExF;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,gCAAgC,CAAC,uBAAuB,CAAC;IAErF;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;IAErC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,gCAAgC,CAAC,aAAa,CAAC;CACjE;AAED,yBAAiB,gCAAgC,CAAC;IAChD;;OAEG;IACH,UAAiB,YAAY;QAC3B;;WAEG;QACH,UAAU,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC;KACrC;IAED,UAAiB,YAAY,CAAC;QAC5B;;WAEG;QACH,UAAiB,SAAS;YACxB;;;eAGG;YACH,MAAM,CAAC,EAAE,YAAY,CAAC;YAEtB;;;eAGG;YACH,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB;KACF;IAED;;;;;;OAMG;IACH,UAAiB,wBAAwB;QACvC;;;;WAIG;QACH,IAAI,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;KACnC;IAED;;;;OAIG;IACH,UAAiB,uBAAuB;QACtC;;;;WAIG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAElB;;;WAGG;QACH,KAAK,CAAC,EAAE,mBAAmB,GAAG,wBAAwB,GAAG,WAAW,CAAC;QAErE;;;;;;WAMG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAED;;;;;;;;;;;OAWG;IACH,UAAiB,aAAa;QAC5B;;;WAGG;QACH,eAAe,CAAC,EAAE,OAAO,CAAC;QAE1B;;;;WAIG;QACH,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;QAE/C;;;;WAIG;QACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAE7B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAE3B;;;;WAIG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAE7B;;;;WAIG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,IAAI,CAAC,EAAE,YAAY,GAAG,cAAc,CAAC;KACtC;CACF;AAED,MAAM,CAAC,OAAO,WAAW,qBAAqB,CAAC;IAC7C,OAAO,EACL,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,gCAAgC,IAAI,gCAAgC,GAC1E,CAAC;CACH"}
@@ -0,0 +1,299 @@
import { APIResource } from "../../../core/resource.js";
import { APIPromise } from "../../../core/api-promise.js";
import { RequestOptions } from "../../../internal/request-options.js";
export declare class TranscriptionSessions extends APIResource {
/**
* Create an ephemeral API token for use in client-side applications with the
* Realtime API specifically for realtime transcriptions. Can be configured with
* the same session parameters as the `transcription_session.update` client event.
*
* It responds with a session object, plus a `client_secret` key which contains a
* usable ephemeral API token that can be used to authenticate browser clients for
* the Realtime API.
*
* @example
* ```ts
* const transcriptionSession =
* await client.beta.realtime.transcriptionSessions.create();
* ```
*/
create(body: TranscriptionSessionCreateParams, options?: RequestOptions): APIPromise<TranscriptionSession>;
}
/**
* A new Realtime transcription session configuration.
*
* When a session is created on the server via REST API, the session object also
* contains an ephemeral key. Default TTL for keys is 10 minutes. This property is
* not present when a session is updated via the WebSocket API.
*/
export interface TranscriptionSession {
/**
* Ephemeral key returned by the API. Only present when the session is created on
* the server via REST API.
*/
client_secret: TranscriptionSession.ClientSecret;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
*/
input_audio_format?: string;
/**
* Configuration of the transcription model.
*/
input_audio_transcription?: TranscriptionSession.InputAudioTranscription;
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
* means that the model will detect the start and end of speech based on audio
* volume and respond at the end of user speech.
*/
turn_detection?: TranscriptionSession.TurnDetection;
}
export declare namespace TranscriptionSession {
/**
* Ephemeral key returned by the API. Only present when the session is created on
* the server via REST API.
*/
interface ClientSecret {
/**
* Timestamp for when the token expires. Currently, all tokens expire after one
* minute.
*/
expires_at: number;
/**
* Ephemeral key usable in client environments to authenticate connections to the
* Realtime API. Use this in client-side environments rather than a standard API
* token, which should only be used server-side.
*/
value: string;
}
/**
* Configuration of the transcription model.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription. Can be `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, or `whisper-1`.
*/
model?: 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe' | 'whisper-1';
/**
* An optional text to guide the model's style or continue a previous audio
* segment. The
* [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
* should match the audio language.
*/
prompt?: string;
}
/**
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
* means that the model will detect the start and end of speech based on audio
* volume and respond at the end of user speech.
*/
interface TurnDetection {
/**
* Amount of audio to include before the VAD detected speech (in milliseconds).
* Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms.
* With shorter values the model will respond more quickly, but may jump in on
* short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher
* threshold will require louder audio to activate the model, and thus might
* perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection, only `server_vad` is currently supported.
*/
type?: string;
}
}
export interface TranscriptionSessionCreateParams {
/**
* Configuration options for the generated client secret.
*/
client_secret?: TranscriptionSessionCreateParams.ClientSecret;
/**
* The set of items to include in the transcription. Current available items are:
*
* - `item.input_audio_transcription.logprobs`
*/
include?: Array<string>;
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
* (mono), and little-endian byte order.
*/
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
input_audio_noise_reduction?: TranscriptionSessionCreateParams.InputAudioNoiseReduction;
/**
* Configuration for input audio transcription. The client can optionally set the
* language and prompt for transcription, these offer additional guidance to the
* transcription service.
*/
input_audio_transcription?: TranscriptionSessionCreateParams.InputAudioTranscription;
/**
* The set of modalities the model can respond with. To disable audio, set this to
* ["text"].
*/
modalities?: Array<'text' | 'audio'>;
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
turn_detection?: TranscriptionSessionCreateParams.TurnDetection;
}
export declare namespace TranscriptionSessionCreateParams {
/**
* Configuration options for the generated client secret.
*/
interface ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
expires_at?: ClientSecret.ExpiresAt;
}
namespace ClientSecret {
/**
* Configuration for the ephemeral token expiration.
*/
interface ExpiresAt {
/**
* The anchor point for the ephemeral token expiration. Only `created_at` is
* currently supported.
*/
anchor?: 'created_at';
/**
* The number of seconds from the anchor point to the expiration. Select a value
* between `10` and `7200`.
*/
seconds?: number;
}
}
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
* sent to VAD and the model. Filtering the audio can improve VAD and turn
* detection accuracy (reducing false positives) and model performance by improving
* perception of the input audio.
*/
interface InputAudioNoiseReduction {
/**
* Type of noise reduction. `near_field` is for close-talking microphones such as
* headphones, `far_field` is for far-field microphones such as laptop or
* conference room microphones.
*/
type?: 'near_field' | 'far_field';
}
/**
* Configuration for input audio transcription. The client can optionally set the
* language and prompt for transcription, these offer additional guidance to the
* transcription service.
*/
interface InputAudioTranscription {
/**
* The language of the input audio. Supplying the input language in
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
* format will improve accuracy and latency.
*/
language?: string;
/**
* The model to use for transcription, current options are `gpt-4o-transcribe`,
* `gpt-4o-mini-transcribe`, and `whisper-1`.
*/
model?: 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe' | 'whisper-1';
/**
* An optional text to guide the model's style or continue a previous audio
* segment. For `whisper-1`, the
* [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
* For `gpt-4o-transcribe` models, the prompt is a free text string, for example
* "expect words related to technology".
*/
prompt?: string;
}
/**
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
* set to `null` to turn off, in which case the client must manually trigger model
* response. Server VAD means that the model will detect the start and end of
* speech based on audio volume and respond at the end of user speech. Semantic VAD
* is more advanced and uses a turn detection model (in conjunction with VAD) to
* semantically estimate whether the user has finished speaking, then dynamically
* sets a timeout based on this probability. For example, if user audio trails off
* with "uhhm", the model will score a low probability of turn end and wait longer
* for the user to continue speaking. This can be useful for more natural
* conversations, but may have a higher latency.
*/
interface TurnDetection {
/**
* Whether or not to automatically generate a response when a VAD stop event
* occurs. Not available for transcription sessions.
*/
create_response?: boolean;
/**
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
* will wait longer for the user to continue speaking, `high` will respond more
* quickly. `auto` is the default and is equivalent to `medium`.
*/
eagerness?: 'low' | 'medium' | 'high' | 'auto';
/**
* Whether or not to automatically interrupt any ongoing response with output to
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
* occurs. Not available for transcription sessions.
*/
interrupt_response?: boolean;
/**
* Used only for `server_vad` mode. Amount of audio to include before the VAD
* detected speech (in milliseconds). Defaults to 300ms.
*/
prefix_padding_ms?: number;
/**
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
* milliseconds). Defaults to 500ms. With shorter values the model will respond
* more quickly, but may jump in on short pauses from the user.
*/
silence_duration_ms?: number;
/**
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
* defaults to 0.5. A higher threshold will require louder audio to activate the
* model, and thus might perform better in noisy environments.
*/
threshold?: number;
/**
* Type of turn detection.
*/
type?: 'server_vad' | 'semantic_vad';
}
}
export declare namespace TranscriptionSessions {
export { type TranscriptionSession as TranscriptionSession, type TranscriptionSessionCreateParams as TranscriptionSessionCreateParams, };
}
//# sourceMappingURL=transcription-sessions.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"transcription-sessions.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/realtime/transcription-sessions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,kCAA+B;AACrD,OAAO,EAAE,UAAU,EAAE,qCAAkC;AAEvD,OAAO,EAAE,cAAc,EAAE,6CAA0C;AAEnE,qBAAa,qBAAsB,SAAQ,WAAW;IACpD;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAI,EAAE,gCAAgC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,oBAAoB,CAAC;CAQ3G;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,aAAa,EAAE,oBAAoB,CAAC,YAAY,CAAC;IAEjD;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,yBAAyB,CAAC,EAAE,oBAAoB,CAAC,uBAAuB,CAAC;IAEzE;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;IAErC;;;;OAIG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC,aAAa,CAAC;CACrD;AAED,yBAAiB,oBAAoB,CAAC;IACpC;;;OAGG;IACH,UAAiB,YAAY;QAC3B;;;WAGG;QACH,UAAU,EAAE,MAAM,CAAC;QAEnB;;;;WAIG;QACH,KAAK,EAAE,MAAM,CAAC;KACf;IAED;;OAEG;IACH,UAAiB,uBAAuB;QACtC;;;;WAIG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAElB;;;WAGG;QACH,KAAK,CAAC,EAAE,mBAAmB,GAAG,wBAAwB,GAAG,WAAW,CAAC;QAErE;;;;;WAKG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAED;;;;OAIG;IACH,UAAiB,aAAa;QAC5B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAE3B;;;;WAIG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAE7B;;;;WAIG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;CACF;AAED,MAAM,WAAW,gCAAgC;IAC/C;;OAEG;IACH,aAAa,CAAC,EAAE,gCAAgC,CAAC,YAAY,CAAC;IAE9D;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAExB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;IAEzD;;;;;;OAMG;IACH,2BAA2B,CAAC,EAAE,gCAAgC,CAAC,wBAAwB,CAAC;IAExF;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,gCAAgC,CAAC,uBAAuB,CAAC;IAErF;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;IAErC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,gCAAgC,CAAC,aAAa,CAAC;CACjE;AAED,yBAAiB,gCAAgC,CAAC;IAChD;;OAEG;IACH,UAAiB,YAAY;QAC3B;;WAEG;QACH,UAAU,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC;KACrC;IAED,UAAiB,YAAY,CAAC;QAC5B;;WAEG;QACH,UAAiB,SAAS;YACxB;;;eAGG;YACH,MAAM,CAAC,EAAE,YAAY,CAAC;YAEtB;;;eAGG;YACH,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB;KACF;IAED;;;;;;OAMG;IACH,UAAiB,wBAAwB;QACvC;;;;WAIG;QACH,IAAI,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;KACnC;IAED;;;;OAIG;IACH,UAAiB,uBAAuB;QACtC;;;;WAIG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAElB;;;WAGG;QACH,KAAK,CAAC,EAAE,mBAAmB,GAAG,wBAAwB,GAAG,WAAW,CAAC;QAErE;;;;;;WAMG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAED;;;;;;;;;;;OAWG;IACH,UAAiB,aAAa;QAC5B;;;WAGG;QACH,eAAe,CAAC,EAAE,OAAO,CAAC;QAE1B;;;;WAIG;QACH,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;QAE/C;;;;WAIG;QACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAE7B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAE3B;;;;WAIG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAE7B;;;;WAIG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,IAAI,CAAC,EAAE,YAAY,GAAG,cAAc,CAAC;KACtC;CACF;AAED,MAAM,CAAC,OAAO,WAAW,qBAAqB,CAAC;IAC7C,OAAO,EACL,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,gCAAgC,IAAI,gCAAgC,GAC1E,CAAC;CACH"}
@@ -0,0 +1,33 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TranscriptionSessions = void 0;
const resource_1 = require("../../../core/resource.js");
const headers_1 = require("../../../internal/headers.js");
class TranscriptionSessions extends resource_1.APIResource {
/**
* Create an ephemeral API token for use in client-side applications with the
* Realtime API specifically for realtime transcriptions. Can be configured with
* the same session parameters as the `transcription_session.update` client event.
*
* It responds with a session object, plus a `client_secret` key which contains a
* usable ephemeral API token that can be used to authenticate browser clients for
* the Realtime API.
*
* @example
* ```ts
* const transcriptionSession =
* await client.beta.realtime.transcriptionSessions.create();
* ```
*/
create(body, options) {
return this._client.post('/realtime/transcription_sessions', {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
exports.TranscriptionSessions = TranscriptionSessions;
//# sourceMappingURL=transcription-sessions.js.map
@@ -0,0 +1 @@
{"version":3,"file":"transcription-sessions.js","sourceRoot":"","sources":["../../../src/resources/beta/realtime/transcription-sessions.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wDAAqD;AAErD,0DAAyD;AAGzD,MAAa,qBAAsB,SAAQ,sBAAW;IACpD;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAsC,EAAE,OAAwB;QACrE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,kCAAkC,EAAE;YAC3D,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AAxBD,sDAwBC"}
@@ -0,0 +1,29 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { buildHeaders } from "../../../internal/headers.mjs";
export class TranscriptionSessions extends APIResource {
/**
* Create an ephemeral API token for use in client-side applications with the
* Realtime API specifically for realtime transcriptions. Can be configured with
* the same session parameters as the `transcription_session.update` client event.
*
* It responds with a session object, plus a `client_secret` key which contains a
* usable ephemeral API token that can be used to authenticate browser clients for
* the Realtime API.
*
* @example
* ```ts
* const transcriptionSession =
* await client.beta.realtime.transcriptionSessions.create();
* ```
*/
create(body, options) {
return this._client.post('/realtime/transcription_sessions', {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
//# sourceMappingURL=transcription-sessions.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"transcription-sessions.mjs","sourceRoot":"","sources":["../../../src/resources/beta/realtime/transcription-sessions.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AAErD,OAAO,EAAE,YAAY,EAAE,sCAAkC;AAGzD,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IACpD;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,IAAsC,EAAE,OAAwB;QACrE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,kCAAkC,EAAE;YAC3D,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
+2
View File
@@ -0,0 +1,2 @@
export * from "./threads/index.mjs";
//# sourceMappingURL=threads.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"threads.d.mts","sourceRoot":"","sources":["../../src/resources/beta/threads.ts"],"names":[],"mappings":"AAEA,oCAAgC"}
+2
View File
@@ -0,0 +1,2 @@
export * from "./threads/index.js";
//# sourceMappingURL=threads.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../src/resources/beta/threads.ts"],"names":[],"mappings":"AAEA,mCAAgC"}
+6
View File
@@ -0,0 +1,6 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("../../internal/tslib.js");
tslib_1.__exportStar(require("./threads/index.js"), exports);
//# sourceMappingURL=threads.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../src/resources/beta/threads.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6DAAgC"}
+3
View File
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export * from "./threads/index.mjs";
//# sourceMappingURL=threads.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"threads.mjs","sourceRoot":"","sources":["../../src/resources/beta/threads.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,oCAAgC"}
+4
View File
@@ -0,0 +1,4 @@
export { Messages, type Annotation, type AnnotationDelta, type FileCitationAnnotation, type FileCitationDeltaAnnotation, type FilePathAnnotation, type FilePathDeltaAnnotation, type ImageFile, type ImageFileContentBlock, type ImageFileDelta, type ImageFileDeltaBlock, type ImageURL, type ImageURLContentBlock, type ImageURLDelta, type ImageURLDeltaBlock, type Message, type MessageContent, type MessageContentDelta, type MessageContentPartParam, type MessageDeleted, type MessageDelta, type MessageDeltaEvent, type RefusalContentBlock, type RefusalDeltaBlock, type Text, type TextContentBlock, type TextContentBlockParam, type TextDelta, type TextDeltaBlock, type MessageCreateParams, type MessageRetrieveParams, type MessageUpdateParams, type MessageListParams, type MessageDeleteParams, type MessagesPage, } from "./messages.mjs";
export { Runs, type RequiredActionFunctionToolCall, type Run, type RunStatus, type RunCreateParams, type RunCreateParamsNonStreaming, type RunCreateParamsStreaming, type RunRetrieveParams, type RunUpdateParams, type RunListParams, type RunCancelParams, type RunSubmitToolOutputsParams, type RunSubmitToolOutputsParamsNonStreaming, type RunSubmitToolOutputsParamsStreaming, type RunsPage, type RunCreateAndPollParams, type RunCreateAndStreamParams, type RunStreamParams, type RunSubmitToolOutputsAndPollParams, type RunSubmitToolOutputsStreamParams, } from "./runs/index.mjs";
export { Threads, type AssistantResponseFormatOption, type AssistantToolChoice, type AssistantToolChoiceFunction, type AssistantToolChoiceOption, type Thread, type ThreadDeleted, type ThreadCreateParams, type ThreadUpdateParams, type ThreadCreateAndRunParams, type ThreadCreateAndRunParamsNonStreaming, type ThreadCreateAndRunParamsStreaming, type ThreadCreateAndRunPollParams, type ThreadCreateAndRunStreamParams, } from "./threads.mjs";
//# sourceMappingURL=index.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/threads/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACT,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,YAAY,GAClB,uBAAmB;AACpB,OAAO,EACL,IAAI,EACJ,KAAK,8BAA8B,EACnC,KAAK,GAAG,EACR,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,sCAAsC,EAC3C,KAAK,mCAAmC,EACxC,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,iCAAiC,EACtC,KAAK,gCAAgC,GACtC,yBAAqB;AACtB,OAAO,EACL,OAAO,EACP,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,oCAAoC,EACzC,KAAK,iCAAiC,EACtC,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,GACpC,sBAAkB"}
+4
View File
@@ -0,0 +1,4 @@
export { Messages, type Annotation, type AnnotationDelta, type FileCitationAnnotation, type FileCitationDeltaAnnotation, type FilePathAnnotation, type FilePathDeltaAnnotation, type ImageFile, type ImageFileContentBlock, type ImageFileDelta, type ImageFileDeltaBlock, type ImageURL, type ImageURLContentBlock, type ImageURLDelta, type ImageURLDeltaBlock, type Message, type MessageContent, type MessageContentDelta, type MessageContentPartParam, type MessageDeleted, type MessageDelta, type MessageDeltaEvent, type RefusalContentBlock, type RefusalDeltaBlock, type Text, type TextContentBlock, type TextContentBlockParam, type TextDelta, type TextDeltaBlock, type MessageCreateParams, type MessageRetrieveParams, type MessageUpdateParams, type MessageListParams, type MessageDeleteParams, type MessagesPage, } from "./messages.js";
export { Runs, type RequiredActionFunctionToolCall, type Run, type RunStatus, type RunCreateParams, type RunCreateParamsNonStreaming, type RunCreateParamsStreaming, type RunRetrieveParams, type RunUpdateParams, type RunListParams, type RunCancelParams, type RunSubmitToolOutputsParams, type RunSubmitToolOutputsParamsNonStreaming, type RunSubmitToolOutputsParamsStreaming, type RunsPage, type RunCreateAndPollParams, type RunCreateAndStreamParams, type RunStreamParams, type RunSubmitToolOutputsAndPollParams, type RunSubmitToolOutputsStreamParams, } from "./runs/index.js";
export { Threads, type AssistantResponseFormatOption, type AssistantToolChoice, type AssistantToolChoiceFunction, type AssistantToolChoiceOption, type Thread, type ThreadDeleted, type ThreadCreateParams, type ThreadUpdateParams, type ThreadCreateAndRunParams, type ThreadCreateAndRunParamsNonStreaming, type ThreadCreateAndRunParamsStreaming, type ThreadCreateAndRunPollParams, type ThreadCreateAndRunStreamParams, } from "./threads.js";
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/threads/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACT,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,YAAY,GAClB,sBAAmB;AACpB,OAAO,EACL,IAAI,EACJ,KAAK,8BAA8B,EACnC,KAAK,GAAG,EACR,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,sCAAsC,EAC3C,KAAK,mCAAmC,EACxC,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,iCAAiC,EACtC,KAAK,gCAAgC,GACtC,wBAAqB;AACtB,OAAO,EACL,OAAO,EACP,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,oCAAoC,EACzC,KAAK,iCAAiC,EACtC,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,GACpC,qBAAkB"}
+11
View File
@@ -0,0 +1,11 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Threads = exports.Runs = exports.Messages = void 0;
var messages_1 = require("./messages.js");
Object.defineProperty(exports, "Messages", { enumerable: true, get: function () { return messages_1.Messages; } });
var index_1 = require("./runs/index.js");
Object.defineProperty(exports, "Runs", { enumerable: true, get: function () { return index_1.Runs; } });
var threads_1 = require("./threads.js");
Object.defineProperty(exports, "Threads", { enumerable: true, get: function () { return threads_1.Threads; } });
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/beta/threads/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,0CAoCoB;AAnClB,oGAAA,QAAQ,OAAA;AAoCV,yCAqBsB;AApBpB,6FAAA,IAAI,OAAA;AAqBN,wCAemB;AAdjB,kGAAA,OAAO,OAAA"}
+5
View File
@@ -0,0 +1,5 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export { Messages, } from "./messages.mjs";
export { Runs, } from "./runs/index.mjs";
export { Threads, } from "./threads.mjs";
//# sourceMappingURL=index.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/resources/beta/threads/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EACL,QAAQ,GAmCT,uBAAmB;AACpB,OAAO,EACL,IAAI,GAoBL,yBAAqB;AACtB,OAAO,EACL,OAAO,GAcR,sBAAkB"}
+596
View File
@@ -0,0 +1,596 @@
import { APIResource } from "../../../core/resource.mjs";
import * as Shared from "../../shared.mjs";
import * as AssistantsAPI from "../assistants.mjs";
import { APIPromise } from "../../../core/api-promise.mjs";
import { CursorPage, type CursorPageParams, PagePromise } from "../../../core/pagination.mjs";
import { RequestOptions } from "../../../internal/request-options.mjs";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export declare class Messages extends APIResource {
/**
* Create a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(threadID: string, body: MessageCreateParams, options?: RequestOptions): APIPromise<Message>;
/**
* Retrieve a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(messageID: string, params: MessageRetrieveParams, options?: RequestOptions): APIPromise<Message>;
/**
* Modifies a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(messageID: string, params: MessageUpdateParams, options?: RequestOptions): APIPromise<Message>;
/**
* Returns a list of messages for a given thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(threadID: string, query?: MessageListParams | null | undefined, options?: RequestOptions): PagePromise<MessagesPage, Message>;
/**
* Deletes a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
delete(messageID: string, params: MessageDeleteParams, options?: RequestOptions): APIPromise<MessageDeleted>;
}
export type MessagesPage = CursorPage<Message>;
/**
* A citation within the message that points to a specific quote from a specific
* File associated with the assistant or the message. Generated when the assistant
* uses the "file_search" tool to search files.
*/
export type Annotation = FileCitationAnnotation | FilePathAnnotation;
/**
* A citation within the message that points to a specific quote from a specific
* File associated with the assistant or the message. Generated when the assistant
* uses the "file_search" tool to search files.
*/
export type AnnotationDelta = FileCitationDeltaAnnotation | FilePathDeltaAnnotation;
/**
* A citation within the message that points to a specific quote from a specific
* File associated with the assistant or the message. Generated when the assistant
* uses the "file_search" tool to search files.
*/
export interface FileCitationAnnotation {
end_index: number;
file_citation: FileCitationAnnotation.FileCitation;
start_index: number;
/**
* The text in the message content that needs to be replaced.
*/
text: string;
/**
* Always `file_citation`.
*/
type: 'file_citation';
}
export declare namespace FileCitationAnnotation {
interface FileCitation {
/**
* The ID of the specific File the citation is from.
*/
file_id: string;
}
}
/**
* A citation within the message that points to a specific quote from a specific
* File associated with the assistant or the message. Generated when the assistant
* uses the "file_search" tool to search files.
*/
export interface FileCitationDeltaAnnotation {
/**
* The index of the annotation in the text content part.
*/
index: number;
/**
* Always `file_citation`.
*/
type: 'file_citation';
end_index?: number;
file_citation?: FileCitationDeltaAnnotation.FileCitation;
start_index?: number;
/**
* The text in the message content that needs to be replaced.
*/
text?: string;
}
export declare namespace FileCitationDeltaAnnotation {
interface FileCitation {
/**
* The ID of the specific File the citation is from.
*/
file_id?: string;
/**
* The specific quote in the file.
*/
quote?: string;
}
}
/**
* A URL for the file that's generated when the assistant used the
* `code_interpreter` tool to generate a file.
*/
export interface FilePathAnnotation {
end_index: number;
file_path: FilePathAnnotation.FilePath;
start_index: number;
/**
* The text in the message content that needs to be replaced.
*/
text: string;
/**
* Always `file_path`.
*/
type: 'file_path';
}
export declare namespace FilePathAnnotation {
interface FilePath {
/**
* The ID of the file that was generated.
*/
file_id: string;
}
}
/**
* A URL for the file that's generated when the assistant used the
* `code_interpreter` tool to generate a file.
*/
export interface FilePathDeltaAnnotation {
/**
* The index of the annotation in the text content part.
*/
index: number;
/**
* Always `file_path`.
*/
type: 'file_path';
end_index?: number;
file_path?: FilePathDeltaAnnotation.FilePath;
start_index?: number;
/**
* The text in the message content that needs to be replaced.
*/
text?: string;
}
export declare namespace FilePathDeltaAnnotation {
interface FilePath {
/**
* The ID of the file that was generated.
*/
file_id?: string;
}
}
export interface ImageFile {
/**
* The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
* in the message content. Set `purpose="vision"` when uploading the File if you
* need to later display the file content.
*/
file_id: string;
/**
* Specifies the detail level of the image if specified by the user. `low` uses
* fewer tokens, you can opt in to high resolution using `high`.
*/
detail?: 'auto' | 'low' | 'high';
}
/**
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export interface ImageFileContentBlock {
image_file: ImageFile;
/**
* Always `image_file`.
*/
type: 'image_file';
}
export interface ImageFileDelta {
/**
* Specifies the detail level of the image if specified by the user. `low` uses
* fewer tokens, you can opt in to high resolution using `high`.
*/
detail?: 'auto' | 'low' | 'high';
/**
* The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
* in the message content. Set `purpose="vision"` when uploading the File if you
* need to later display the file content.
*/
file_id?: string;
}
/**
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export interface ImageFileDeltaBlock {
/**
* The index of the content part in the message.
*/
index: number;
/**
* Always `image_file`.
*/
type: 'image_file';
image_file?: ImageFileDelta;
}
export interface ImageURL {
/**
* The external URL of the image, must be a supported image types: jpeg, jpg, png,
* gif, webp.
*/
url: string;
/**
* Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
* to high resolution using `high`. Default value is `auto`
*/
detail?: 'auto' | 'low' | 'high';
}
/**
* References an image URL in the content of a message.
*/
export interface ImageURLContentBlock {
image_url: ImageURL;
/**
* The type of the content part.
*/
type: 'image_url';
}
export interface ImageURLDelta {
/**
* Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
* to high resolution using `high`.
*/
detail?: 'auto' | 'low' | 'high';
/**
* The URL of the image, must be a supported image types: jpeg, jpg, png, gif,
* webp.
*/
url?: string;
}
/**
* References an image URL in the content of a message.
*/
export interface ImageURLDeltaBlock {
/**
* The index of the content part in the message.
*/
index: number;
/**
* Always `image_url`.
*/
type: 'image_url';
image_url?: ImageURLDelta;
}
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
export interface Message {
/**
* The identifier, which can be referenced in API endpoints.
*/
id: string;
/**
* If applicable, the ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) that
* authored this message.
*/
assistant_id: string | null;
/**
* A list of files attached to the message, and the tools they were added to.
*/
attachments: Array<Message.Attachment> | null;
/**
* The Unix timestamp (in seconds) for when the message was completed.
*/
completed_at: number | null;
/**
* The content of the message in array of text and/or images.
*/
content: Array<MessageContent>;
/**
* The Unix timestamp (in seconds) for when the message was created.
*/
created_at: number;
/**
* The Unix timestamp (in seconds) for when the message was marked as incomplete.
*/
incomplete_at: number | null;
/**
* On an incomplete message, details about why the message is incomplete.
*/
incomplete_details: Message.IncompleteDetails | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata: Shared.Metadata | null;
/**
* The object type, which is always `thread.message`.
*/
object: 'thread.message';
/**
* The entity that produced the message. One of `user` or `assistant`.
*/
role: 'user' | 'assistant';
/**
* The ID of the [run](https://platform.openai.com/docs/api-reference/runs)
* associated with the creation of this message. Value is `null` when messages are
* created manually using the create message or create thread endpoints.
*/
run_id: string | null;
/**
* The status of the message, which can be either `in_progress`, `incomplete`, or
* `completed`.
*/
status: 'in_progress' | 'incomplete' | 'completed';
/**
* The [thread](https://platform.openai.com/docs/api-reference/threads) ID that
* this message belongs to.
*/
thread_id: string;
}
export declare namespace Message {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.AssistantToolsFileSearchTypeOnly>;
}
namespace Attachment {
interface AssistantToolsFileSearchTypeOnly {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
}
}
/**
* On an incomplete message, details about why the message is incomplete.
*/
interface IncompleteDetails {
/**
* The reason the message is incomplete.
*/
reason: 'content_filter' | 'max_tokens' | 'run_cancelled' | 'run_expired' | 'run_failed';
}
}
/**
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export type MessageContent = ImageFileContentBlock | ImageURLContentBlock | TextContentBlock | RefusalContentBlock;
/**
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export type MessageContentDelta = ImageFileDeltaBlock | TextDeltaBlock | RefusalDeltaBlock | ImageURLDeltaBlock;
/**
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export type MessageContentPartParam = ImageFileContentBlock | ImageURLContentBlock | TextContentBlockParam;
export interface MessageDeleted {
id: string;
deleted: boolean;
object: 'thread.message.deleted';
}
/**
* The delta containing the fields that have changed on the Message.
*/
export interface MessageDelta {
/**
* The content of the message in array of text and/or images.
*/
content?: Array<MessageContentDelta>;
/**
* The entity that produced the message. One of `user` or `assistant`.
*/
role?: 'user' | 'assistant';
}
/**
* Represents a message delta i.e. any changed fields on a message during
* streaming.
*/
export interface MessageDeltaEvent {
/**
* The identifier of the message, which can be referenced in API endpoints.
*/
id: string;
/**
* The delta containing the fields that have changed on the Message.
*/
delta: MessageDelta;
/**
* The object type, which is always `thread.message.delta`.
*/
object: 'thread.message.delta';
}
/**
* The refusal content generated by the assistant.
*/
export interface RefusalContentBlock {
refusal: string;
/**
* Always `refusal`.
*/
type: 'refusal';
}
/**
* The refusal content that is part of a message.
*/
export interface RefusalDeltaBlock {
/**
* The index of the refusal part in the message.
*/
index: number;
/**
* Always `refusal`.
*/
type: 'refusal';
refusal?: string;
}
export interface Text {
annotations: Array<Annotation>;
/**
* The data that makes up the text.
*/
value: string;
}
/**
* The text content that is part of a message.
*/
export interface TextContentBlock {
text: Text;
/**
* Always `text`.
*/
type: 'text';
}
/**
* The text content that is part of a message.
*/
export interface TextContentBlockParam {
/**
* Text content to be sent to the model
*/
text: string;
/**
* Always `text`.
*/
type: 'text';
}
export interface TextDelta {
annotations?: Array<AnnotationDelta>;
/**
* The data that makes up the text.
*/
value?: string;
}
/**
* The text content that is part of a message.
*/
export interface TextDeltaBlock {
/**
* The index of the content part in the message.
*/
index: number;
/**
* Always `text`.
*/
type: 'text';
text?: TextDelta;
}
export interface MessageCreateParams {
/**
* The text contents of the message.
*/
content: string | Array<MessageContentPartParam>;
/**
* The role of the entity that is creating the message. Allowed values include:
*
* - `user`: Indicates the message is sent by an actual user and should be used in
* most cases to represent user-generated messages.
* - `assistant`: Indicates the message is generated by the assistant. Use this
* value to insert messages from the assistant into the conversation.
*/
role: 'user' | 'assistant';
/**
* A list of files attached to the message, and the tools they should be added to.
*/
attachments?: Array<MessageCreateParams.Attachment> | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
export declare namespace MessageCreateParams {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.FileSearch>;
}
namespace Attachment {
interface FileSearch {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
}
}
}
export interface MessageRetrieveParams {
/**
* The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
* to which this message belongs.
*/
thread_id: string;
}
export interface MessageUpdateParams {
/**
* Path param: The ID of the thread to which this message belongs.
*/
thread_id: string;
/**
* Body param: Set of 16 key-value pairs that can be attached to an object. This
* can be useful for storing additional information about the object in a
* structured format, and querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
export interface MessageListParams extends CursorPageParams {
/**
* A cursor for use in pagination. `before` is an object ID that defines your place
* in the list. For instance, if you make a list request and receive 100 objects,
* starting with obj_foo, your subsequent call can include before=obj_foo in order
* to fetch the previous page of the list.
*/
before?: string;
/**
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
* order and `desc` for descending order.
*/
order?: 'asc' | 'desc';
/**
* Filter messages by the run ID that generated them.
*/
run_id?: string;
}
export interface MessageDeleteParams {
/**
* The ID of the thread to which this message belongs.
*/
thread_id: string;
}
export declare namespace Messages {
export { type Annotation as Annotation, type AnnotationDelta as AnnotationDelta, type FileCitationAnnotation as FileCitationAnnotation, type FileCitationDeltaAnnotation as FileCitationDeltaAnnotation, type FilePathAnnotation as FilePathAnnotation, type FilePathDeltaAnnotation as FilePathDeltaAnnotation, type ImageFile as ImageFile, type ImageFileContentBlock as ImageFileContentBlock, type ImageFileDelta as ImageFileDelta, type ImageFileDeltaBlock as ImageFileDeltaBlock, type ImageURL as ImageURL, type ImageURLContentBlock as ImageURLContentBlock, type ImageURLDelta as ImageURLDelta, type ImageURLDeltaBlock as ImageURLDeltaBlock, type Message as Message, type MessageContent as MessageContent, type MessageContentDelta as MessageContentDelta, type MessageContentPartParam as MessageContentPartParam, type MessageDeleted as MessageDeleted, type MessageDelta as MessageDelta, type MessageDeltaEvent as MessageDeltaEvent, type RefusalContentBlock as RefusalContentBlock, type RefusalDeltaBlock as RefusalDeltaBlock, type Text as Text, type TextContentBlock as TextContentBlock, type TextContentBlockParam as TextContentBlockParam, type TextDelta as TextDelta, type TextDeltaBlock as TextDeltaBlock, type MessagesPage as MessagesPage, type MessageCreateParams as MessageCreateParams, type MessageRetrieveParams as MessageRetrieveParams, type MessageUpdateParams as MessageUpdateParams, type MessageListParams as MessageListParams, type MessageDeleteParams as MessageDeleteParams, };
}
//# sourceMappingURL=messages.d.mts.map
File diff suppressed because one or more lines are too long
+596
View File
@@ -0,0 +1,596 @@
import { APIResource } from "../../../core/resource.js";
import * as Shared from "../../shared.js";
import * as AssistantsAPI from "../assistants.js";
import { APIPromise } from "../../../core/api-promise.js";
import { CursorPage, type CursorPageParams, PagePromise } from "../../../core/pagination.js";
import { RequestOptions } from "../../../internal/request-options.js";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export declare class Messages extends APIResource {
/**
* Create a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(threadID: string, body: MessageCreateParams, options?: RequestOptions): APIPromise<Message>;
/**
* Retrieve a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(messageID: string, params: MessageRetrieveParams, options?: RequestOptions): APIPromise<Message>;
/**
* Modifies a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(messageID: string, params: MessageUpdateParams, options?: RequestOptions): APIPromise<Message>;
/**
* Returns a list of messages for a given thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(threadID: string, query?: MessageListParams | null | undefined, options?: RequestOptions): PagePromise<MessagesPage, Message>;
/**
* Deletes a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
delete(messageID: string, params: MessageDeleteParams, options?: RequestOptions): APIPromise<MessageDeleted>;
}
export type MessagesPage = CursorPage<Message>;
/**
* A citation within the message that points to a specific quote from a specific
* File associated with the assistant or the message. Generated when the assistant
* uses the "file_search" tool to search files.
*/
export type Annotation = FileCitationAnnotation | FilePathAnnotation;
/**
* A citation within the message that points to a specific quote from a specific
* File associated with the assistant or the message. Generated when the assistant
* uses the "file_search" tool to search files.
*/
export type AnnotationDelta = FileCitationDeltaAnnotation | FilePathDeltaAnnotation;
/**
* A citation within the message that points to a specific quote from a specific
* File associated with the assistant or the message. Generated when the assistant
* uses the "file_search" tool to search files.
*/
export interface FileCitationAnnotation {
end_index: number;
file_citation: FileCitationAnnotation.FileCitation;
start_index: number;
/**
* The text in the message content that needs to be replaced.
*/
text: string;
/**
* Always `file_citation`.
*/
type: 'file_citation';
}
export declare namespace FileCitationAnnotation {
interface FileCitation {
/**
* The ID of the specific File the citation is from.
*/
file_id: string;
}
}
/**
* A citation within the message that points to a specific quote from a specific
* File associated with the assistant or the message. Generated when the assistant
* uses the "file_search" tool to search files.
*/
export interface FileCitationDeltaAnnotation {
/**
* The index of the annotation in the text content part.
*/
index: number;
/**
* Always `file_citation`.
*/
type: 'file_citation';
end_index?: number;
file_citation?: FileCitationDeltaAnnotation.FileCitation;
start_index?: number;
/**
* The text in the message content that needs to be replaced.
*/
text?: string;
}
export declare namespace FileCitationDeltaAnnotation {
interface FileCitation {
/**
* The ID of the specific File the citation is from.
*/
file_id?: string;
/**
* The specific quote in the file.
*/
quote?: string;
}
}
/**
* A URL for the file that's generated when the assistant used the
* `code_interpreter` tool to generate a file.
*/
export interface FilePathAnnotation {
end_index: number;
file_path: FilePathAnnotation.FilePath;
start_index: number;
/**
* The text in the message content that needs to be replaced.
*/
text: string;
/**
* Always `file_path`.
*/
type: 'file_path';
}
export declare namespace FilePathAnnotation {
interface FilePath {
/**
* The ID of the file that was generated.
*/
file_id: string;
}
}
/**
* A URL for the file that's generated when the assistant used the
* `code_interpreter` tool to generate a file.
*/
export interface FilePathDeltaAnnotation {
/**
* The index of the annotation in the text content part.
*/
index: number;
/**
* Always `file_path`.
*/
type: 'file_path';
end_index?: number;
file_path?: FilePathDeltaAnnotation.FilePath;
start_index?: number;
/**
* The text in the message content that needs to be replaced.
*/
text?: string;
}
export declare namespace FilePathDeltaAnnotation {
interface FilePath {
/**
* The ID of the file that was generated.
*/
file_id?: string;
}
}
export interface ImageFile {
/**
* The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
* in the message content. Set `purpose="vision"` when uploading the File if you
* need to later display the file content.
*/
file_id: string;
/**
* Specifies the detail level of the image if specified by the user. `low` uses
* fewer tokens, you can opt in to high resolution using `high`.
*/
detail?: 'auto' | 'low' | 'high';
}
/**
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export interface ImageFileContentBlock {
image_file: ImageFile;
/**
* Always `image_file`.
*/
type: 'image_file';
}
export interface ImageFileDelta {
/**
* Specifies the detail level of the image if specified by the user. `low` uses
* fewer tokens, you can opt in to high resolution using `high`.
*/
detail?: 'auto' | 'low' | 'high';
/**
* The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
* in the message content. Set `purpose="vision"` when uploading the File if you
* need to later display the file content.
*/
file_id?: string;
}
/**
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export interface ImageFileDeltaBlock {
/**
* The index of the content part in the message.
*/
index: number;
/**
* Always `image_file`.
*/
type: 'image_file';
image_file?: ImageFileDelta;
}
export interface ImageURL {
/**
* The external URL of the image, must be a supported image types: jpeg, jpg, png,
* gif, webp.
*/
url: string;
/**
* Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
* to high resolution using `high`. Default value is `auto`
*/
detail?: 'auto' | 'low' | 'high';
}
/**
* References an image URL in the content of a message.
*/
export interface ImageURLContentBlock {
image_url: ImageURL;
/**
* The type of the content part.
*/
type: 'image_url';
}
export interface ImageURLDelta {
/**
* Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
* to high resolution using `high`.
*/
detail?: 'auto' | 'low' | 'high';
/**
* The URL of the image, must be a supported image types: jpeg, jpg, png, gif,
* webp.
*/
url?: string;
}
/**
* References an image URL in the content of a message.
*/
export interface ImageURLDeltaBlock {
/**
* The index of the content part in the message.
*/
index: number;
/**
* Always `image_url`.
*/
type: 'image_url';
image_url?: ImageURLDelta;
}
/**
* Represents a message within a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
export interface Message {
/**
* The identifier, which can be referenced in API endpoints.
*/
id: string;
/**
* If applicable, the ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) that
* authored this message.
*/
assistant_id: string | null;
/**
* A list of files attached to the message, and the tools they were added to.
*/
attachments: Array<Message.Attachment> | null;
/**
* The Unix timestamp (in seconds) for when the message was completed.
*/
completed_at: number | null;
/**
* The content of the message in array of text and/or images.
*/
content: Array<MessageContent>;
/**
* The Unix timestamp (in seconds) for when the message was created.
*/
created_at: number;
/**
* The Unix timestamp (in seconds) for when the message was marked as incomplete.
*/
incomplete_at: number | null;
/**
* On an incomplete message, details about why the message is incomplete.
*/
incomplete_details: Message.IncompleteDetails | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata: Shared.Metadata | null;
/**
* The object type, which is always `thread.message`.
*/
object: 'thread.message';
/**
* The entity that produced the message. One of `user` or `assistant`.
*/
role: 'user' | 'assistant';
/**
* The ID of the [run](https://platform.openai.com/docs/api-reference/runs)
* associated with the creation of this message. Value is `null` when messages are
* created manually using the create message or create thread endpoints.
*/
run_id: string | null;
/**
* The status of the message, which can be either `in_progress`, `incomplete`, or
* `completed`.
*/
status: 'in_progress' | 'incomplete' | 'completed';
/**
* The [thread](https://platform.openai.com/docs/api-reference/threads) ID that
* this message belongs to.
*/
thread_id: string;
}
export declare namespace Message {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.AssistantToolsFileSearchTypeOnly>;
}
namespace Attachment {
interface AssistantToolsFileSearchTypeOnly {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
}
}
/**
* On an incomplete message, details about why the message is incomplete.
*/
interface IncompleteDetails {
/**
* The reason the message is incomplete.
*/
reason: 'content_filter' | 'max_tokens' | 'run_cancelled' | 'run_expired' | 'run_failed';
}
}
/**
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export type MessageContent = ImageFileContentBlock | ImageURLContentBlock | TextContentBlock | RefusalContentBlock;
/**
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export type MessageContentDelta = ImageFileDeltaBlock | TextDeltaBlock | RefusalDeltaBlock | ImageURLDeltaBlock;
/**
* References an image [File](https://platform.openai.com/docs/api-reference/files)
* in the content of a message.
*/
export type MessageContentPartParam = ImageFileContentBlock | ImageURLContentBlock | TextContentBlockParam;
export interface MessageDeleted {
id: string;
deleted: boolean;
object: 'thread.message.deleted';
}
/**
* The delta containing the fields that have changed on the Message.
*/
export interface MessageDelta {
/**
* The content of the message in array of text and/or images.
*/
content?: Array<MessageContentDelta>;
/**
* The entity that produced the message. One of `user` or `assistant`.
*/
role?: 'user' | 'assistant';
}
/**
* Represents a message delta i.e. any changed fields on a message during
* streaming.
*/
export interface MessageDeltaEvent {
/**
* The identifier of the message, which can be referenced in API endpoints.
*/
id: string;
/**
* The delta containing the fields that have changed on the Message.
*/
delta: MessageDelta;
/**
* The object type, which is always `thread.message.delta`.
*/
object: 'thread.message.delta';
}
/**
* The refusal content generated by the assistant.
*/
export interface RefusalContentBlock {
refusal: string;
/**
* Always `refusal`.
*/
type: 'refusal';
}
/**
* The refusal content that is part of a message.
*/
export interface RefusalDeltaBlock {
/**
* The index of the refusal part in the message.
*/
index: number;
/**
* Always `refusal`.
*/
type: 'refusal';
refusal?: string;
}
export interface Text {
annotations: Array<Annotation>;
/**
* The data that makes up the text.
*/
value: string;
}
/**
* The text content that is part of a message.
*/
export interface TextContentBlock {
text: Text;
/**
* Always `text`.
*/
type: 'text';
}
/**
* The text content that is part of a message.
*/
export interface TextContentBlockParam {
/**
* Text content to be sent to the model
*/
text: string;
/**
* Always `text`.
*/
type: 'text';
}
export interface TextDelta {
annotations?: Array<AnnotationDelta>;
/**
* The data that makes up the text.
*/
value?: string;
}
/**
* The text content that is part of a message.
*/
export interface TextDeltaBlock {
/**
* The index of the content part in the message.
*/
index: number;
/**
* Always `text`.
*/
type: 'text';
text?: TextDelta;
}
export interface MessageCreateParams {
/**
* The text contents of the message.
*/
content: string | Array<MessageContentPartParam>;
/**
* The role of the entity that is creating the message. Allowed values include:
*
* - `user`: Indicates the message is sent by an actual user and should be used in
* most cases to represent user-generated messages.
* - `assistant`: Indicates the message is generated by the assistant. Use this
* value to insert messages from the assistant into the conversation.
*/
role: 'user' | 'assistant';
/**
* A list of files attached to the message, and the tools they should be added to.
*/
attachments?: Array<MessageCreateParams.Attachment> | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
export declare namespace MessageCreateParams {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.FileSearch>;
}
namespace Attachment {
interface FileSearch {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
}
}
}
export interface MessageRetrieveParams {
/**
* The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
* to which this message belongs.
*/
thread_id: string;
}
export interface MessageUpdateParams {
/**
* Path param: The ID of the thread to which this message belongs.
*/
thread_id: string;
/**
* Body param: Set of 16 key-value pairs that can be attached to an object. This
* can be useful for storing additional information about the object in a
* structured format, and querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
export interface MessageListParams extends CursorPageParams {
/**
* A cursor for use in pagination. `before` is an object ID that defines your place
* in the list. For instance, if you make a list request and receive 100 objects,
* starting with obj_foo, your subsequent call can include before=obj_foo in order
* to fetch the previous page of the list.
*/
before?: string;
/**
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
* order and `desc` for descending order.
*/
order?: 'asc' | 'desc';
/**
* Filter messages by the run ID that generated them.
*/
run_id?: string;
}
export interface MessageDeleteParams {
/**
* The ID of the thread to which this message belongs.
*/
thread_id: string;
}
export declare namespace Messages {
export { type Annotation as Annotation, type AnnotationDelta as AnnotationDelta, type FileCitationAnnotation as FileCitationAnnotation, type FileCitationDeltaAnnotation as FileCitationDeltaAnnotation, type FilePathAnnotation as FilePathAnnotation, type FilePathDeltaAnnotation as FilePathDeltaAnnotation, type ImageFile as ImageFile, type ImageFileContentBlock as ImageFileContentBlock, type ImageFileDelta as ImageFileDelta, type ImageFileDeltaBlock as ImageFileDeltaBlock, type ImageURL as ImageURL, type ImageURLContentBlock as ImageURLContentBlock, type ImageURLDelta as ImageURLDelta, type ImageURLDeltaBlock as ImageURLDeltaBlock, type Message as Message, type MessageContent as MessageContent, type MessageContentDelta as MessageContentDelta, type MessageContentPartParam as MessageContentPartParam, type MessageDeleted as MessageDeleted, type MessageDelta as MessageDelta, type MessageDeltaEvent as MessageDeltaEvent, type RefusalContentBlock as RefusalContentBlock, type RefusalDeltaBlock as RefusalDeltaBlock, type Text as Text, type TextContentBlock as TextContentBlock, type TextContentBlockParam as TextContentBlockParam, type TextDelta as TextDelta, type TextDeltaBlock as TextDeltaBlock, type MessagesPage as MessagesPage, type MessageCreateParams as MessageCreateParams, type MessageRetrieveParams as MessageRetrieveParams, type MessageUpdateParams as MessageUpdateParams, type MessageListParams as MessageListParams, type MessageDeleteParams as MessageDeleteParams, };
}
//# sourceMappingURL=messages.d.ts.map
File diff suppressed because one or more lines are too long
+83
View File
@@ -0,0 +1,83 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Messages = void 0;
const resource_1 = require("../../../core/resource.js");
const pagination_1 = require("../../../core/pagination.js");
const headers_1 = require("../../../internal/headers.js");
const path_1 = require("../../../internal/utils/path.js");
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
class Messages extends resource_1.APIResource {
/**
* Create a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(threadID, body, options) {
return this._client.post((0, path_1.path) `/threads/${threadID}/messages`, {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Retrieve a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(messageID, params, options) {
const { thread_id } = params;
return this._client.get((0, path_1.path) `/threads/${thread_id}/messages/${messageID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Modifies a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(messageID, params, options) {
const { thread_id, ...body } = params;
return this._client.post((0, path_1.path) `/threads/${thread_id}/messages/${messageID}`, {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Returns a list of messages for a given thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(threadID, query = {}, options) {
return this._client.getAPIList((0, path_1.path) `/threads/${threadID}/messages`, (pagination_1.CursorPage), {
query,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Deletes a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
delete(messageID, params, options) {
const { thread_id } = params;
return this._client.delete((0, path_1.path) `/threads/${thread_id}/messages/${messageID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
exports.Messages = Messages;
//# sourceMappingURL=messages.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/resources/beta/threads/messages.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wDAAqD;AAIrD,4DAA0F;AAC1F,0DAAyD;AAEzD,0DAAoD;AAEpD;;;;GAIG;AACH,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;OAIG;IACH,MAAM,CAAC,QAAgB,EAAE,IAAyB,EAAE,OAAwB;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,YAAY,QAAQ,WAAW,EAAE;YAC5D,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,SAAiB,EAAE,MAA6B,EAAE,OAAwB;QACjF,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,YAAY,SAAS,aAAa,SAAS,EAAE,EAAE;YACzE,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAiB,EAAE,MAA2B,EAAE,OAAwB;QAC7E,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,YAAY,SAAS,aAAa,SAAS,EAAE,EAAE;YAC1E,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,IAAI,CACF,QAAgB,EAChB,QAA8C,EAAE,EAChD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAA,WAAI,EAAA,YAAY,QAAQ,WAAW,EAAE,CAAA,uBAAmB,CAAA,EAAE;YACvF,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CACJ,SAAiB,EACjB,MAA2B,EAC3B,OAAwB;QAExB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAA,WAAI,EAAA,YAAY,SAAS,aAAa,SAAS,EAAE,EAAE;YAC5E,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AA/ED,4BA+EC"}
+79
View File
@@ -0,0 +1,79 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { CursorPage } from "../../../core/pagination.mjs";
import { buildHeaders } from "../../../internal/headers.mjs";
import { path } from "../../../internal/utils/path.mjs";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export class Messages extends APIResource {
/**
* Create a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(threadID, body, options) {
return this._client.post(path `/threads/${threadID}/messages`, {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Retrieve a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(messageID, params, options) {
const { thread_id } = params;
return this._client.get(path `/threads/${thread_id}/messages/${messageID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Modifies a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(messageID, params, options) {
const { thread_id, ...body } = params;
return this._client.post(path `/threads/${thread_id}/messages/${messageID}`, {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Returns a list of messages for a given thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(threadID, query = {}, options) {
return this._client.getAPIList(path `/threads/${threadID}/messages`, (CursorPage), {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Deletes a message.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
delete(messageID, params, options) {
const { thread_id } = params;
return this._client.delete(path `/threads/${thread_id}/messages/${messageID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
//# sourceMappingURL=messages.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../../../src/resources/beta/threads/messages.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AAIrD,OAAO,EAAE,UAAU,EAAsC,qCAAiC;AAC1F,OAAO,EAAE,YAAY,EAAE,sCAAkC;AAEzD,OAAO,EAAE,IAAI,EAAE,yCAAqC;AAEpD;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;OAIG;IACH,MAAM,CAAC,QAAgB,EAAE,IAAyB,EAAE,OAAwB;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,YAAY,QAAQ,WAAW,EAAE;YAC5D,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,SAAiB,EAAE,MAA6B,EAAE,OAAwB;QACjF,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,YAAY,SAAS,aAAa,SAAS,EAAE,EAAE;YACzE,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAiB,EAAE,MAA2B,EAAE,OAAwB;QAC7E,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,YAAY,SAAS,aAAa,SAAS,EAAE,EAAE;YAC1E,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,IAAI,CACF,QAAgB,EAChB,QAA8C,EAAE,EAChD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAA,YAAY,QAAQ,WAAW,EAAE,CAAA,UAAmB,CAAA,EAAE;YACvF,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CACJ,SAAiB,EACjB,MAA2B,EAC3B,OAAwB;QAExB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,YAAY,SAAS,aAAa,SAAS,EAAE,EAAE;YAC5E,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
+2
View File
@@ -0,0 +1,2 @@
export * from "./runs/index.mjs";
//# sourceMappingURL=runs.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"runs.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/threads/runs.ts"],"names":[],"mappings":"AAEA,iCAA6B"}
+2
View File
@@ -0,0 +1,2 @@
export * from "./runs/index.js";
//# sourceMappingURL=runs.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/threads/runs.ts"],"names":[],"mappings":"AAEA,gCAA6B"}
+6
View File
@@ -0,0 +1,6 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("../../../internal/tslib.js");
tslib_1.__exportStar(require("./runs/index.js"), exports);
//# sourceMappingURL=runs.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../../src/resources/beta/threads/runs.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,0DAA6B"}
+3
View File
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export * from "./runs/index.mjs";
//# sourceMappingURL=runs.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"runs.mjs","sourceRoot":"","sources":["../../../src/resources/beta/threads/runs.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,iCAA6B"}
+3
View File
@@ -0,0 +1,3 @@
export { Runs, type RequiredActionFunctionToolCall, type Run, type RunStatus, type RunCreateParams, type RunCreateParamsNonStreaming, type RunCreateParamsStreaming, type RunRetrieveParams, type RunUpdateParams, type RunListParams, type RunCancelParams, type RunSubmitToolOutputsParams, type RunSubmitToolOutputsParamsNonStreaming, type RunSubmitToolOutputsParamsStreaming, type RunsPage, type RunCreateAndPollParams, type RunCreateAndStreamParams, type RunStreamParams, type RunSubmitToolOutputsAndPollParams, type RunSubmitToolOutputsStreamParams, } from "./runs.mjs";
export { Steps, type CodeInterpreterLogs, type CodeInterpreterOutputImage, type CodeInterpreterToolCall, type CodeInterpreterToolCallDelta, type FileSearchToolCall, type FileSearchToolCallDelta, type FunctionToolCall, type FunctionToolCallDelta, type MessageCreationStepDetails, type RunStep, type RunStepInclude, type RunStepDelta, type RunStepDeltaEvent, type RunStepDeltaMessageDelta, type ToolCall, type ToolCallDelta, type ToolCallDeltaObject, type ToolCallsStepDetails, type StepRetrieveParams, type StepListParams, type RunStepsPage, } from "./steps.mjs";
//# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/resources/beta/threads/runs/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,IAAI,EACJ,KAAK,8BAA8B,EACnC,KAAK,GAAG,EACR,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,sCAAsC,EAC3C,KAAK,mCAAmC,EACxC,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,iCAAiC,EACtC,KAAK,gCAAgC,GACtC,mBAAe;AAChB,OAAO,EACL,KAAK,EACL,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,oBAAgB"}
+3
View File
@@ -0,0 +1,3 @@
export { Runs, type RequiredActionFunctionToolCall, type Run, type RunStatus, type RunCreateParams, type RunCreateParamsNonStreaming, type RunCreateParamsStreaming, type RunRetrieveParams, type RunUpdateParams, type RunListParams, type RunCancelParams, type RunSubmitToolOutputsParams, type RunSubmitToolOutputsParamsNonStreaming, type RunSubmitToolOutputsParamsStreaming, type RunsPage, type RunCreateAndPollParams, type RunCreateAndStreamParams, type RunStreamParams, type RunSubmitToolOutputsAndPollParams, type RunSubmitToolOutputsStreamParams, } from "./runs.js";
export { Steps, type CodeInterpreterLogs, type CodeInterpreterOutputImage, type CodeInterpreterToolCall, type CodeInterpreterToolCallDelta, type FileSearchToolCall, type FileSearchToolCallDelta, type FunctionToolCall, type FunctionToolCallDelta, type MessageCreationStepDetails, type RunStep, type RunStepInclude, type RunStepDelta, type RunStepDeltaEvent, type RunStepDeltaMessageDelta, type ToolCall, type ToolCallDelta, type ToolCallDeltaObject, type ToolCallsStepDetails, type StepRetrieveParams, type StepListParams, type RunStepsPage, } from "./steps.js";
//# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/resources/beta/threads/runs/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,IAAI,EACJ,KAAK,8BAA8B,EACnC,KAAK,GAAG,EACR,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,sCAAsC,EAC3C,KAAK,mCAAmC,EACxC,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,iCAAiC,EACtC,KAAK,gCAAgC,GACtC,kBAAe;AAChB,OAAO,EACL,KAAK,EACL,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,mBAAgB"}
+9
View File
@@ -0,0 +1,9 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Steps = exports.Runs = void 0;
var runs_1 = require("./runs.js");
Object.defineProperty(exports, "Runs", { enumerable: true, get: function () { return runs_1.Runs; } });
var steps_1 = require("./steps.js");
Object.defineProperty(exports, "Steps", { enumerable: true, get: function () { return steps_1.Steps; } });
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/resources/beta/threads/runs/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kCAqBgB;AApBd,4FAAA,IAAI,OAAA;AAqBN,oCAuBiB;AAtBf,8FAAA,KAAK,OAAA"}
+4
View File
@@ -0,0 +1,4 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export { Runs, } from "./runs.mjs";
export { Steps, } from "./steps.mjs";
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/resources/beta/threads/runs/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EACL,IAAI,GAoBL,mBAAe;AAChB,OAAO,EACL,KAAK,GAsBN,oBAAgB"}
+743
View File
@@ -0,0 +1,743 @@
import { APIResource } from "../../../../core/resource.mjs";
import * as RunsAPI from "./runs.mjs";
import * as Shared from "../../../shared.mjs";
import * as AssistantsAPI from "../../assistants.mjs";
import * as MessagesAPI from "../messages.mjs";
import * as ThreadsAPI from "../threads.mjs";
import * as StepsAPI from "./steps.mjs";
import { CodeInterpreterLogs, CodeInterpreterOutputImage, CodeInterpreterToolCall, CodeInterpreterToolCallDelta, FileSearchToolCall, FileSearchToolCallDelta, FunctionToolCall, FunctionToolCallDelta, MessageCreationStepDetails, RunStep, RunStepDelta, RunStepDeltaEvent, RunStepDeltaMessageDelta, RunStepInclude, RunStepsPage, StepListParams, StepRetrieveParams, Steps, ToolCall, ToolCallDelta, ToolCallDeltaObject, ToolCallsStepDetails } from "./steps.mjs";
import { APIPromise } from "../../../../core/api-promise.mjs";
import { CursorPage, type CursorPageParams, PagePromise } from "../../../../core/pagination.mjs";
import { Stream } from "../../../../core/streaming.mjs";
import { RequestOptions } from "../../../../internal/request-options.mjs";
import { AssistantStream, RunCreateParamsBaseStream } from "../../../../lib/AssistantStream.mjs";
import { RunSubmitToolOutputsParamsStream } from "../../../../lib/AssistantStream.mjs";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export declare class Runs extends APIResource {
steps: StepsAPI.Steps;
/**
* Create a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(threadID: string, params: RunCreateParamsNonStreaming, options?: RequestOptions): APIPromise<Run>;
create(threadID: string, params: RunCreateParamsStreaming, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>>;
create(threadID: string, params: RunCreateParamsBase, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent> | Run>;
/**
* Retrieves a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(runID: string, params: RunRetrieveParams, options?: RequestOptions): APIPromise<Run>;
/**
* Modifies a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(runID: string, params: RunUpdateParams, options?: RequestOptions): APIPromise<Run>;
/**
* Returns a list of runs belonging to a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(threadID: string, query?: RunListParams | null | undefined, options?: RequestOptions): PagePromise<RunsPage, Run>;
/**
* Cancels a run that is `in_progress`.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
cancel(runID: string, params: RunCancelParams, options?: RequestOptions): APIPromise<Run>;
/**
* A helper to create a run an poll for a terminal state. More information on Run
* lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
createAndPoll(threadId: string, body: RunCreateParamsNonStreaming, options?: RequestOptions & {
pollIntervalMs?: number;
}): Promise<Run>;
/**
* Create a Run stream
*
* @deprecated use `stream` instead
*/
createAndStream(threadId: string, body: RunCreateParamsBaseStream, options?: RequestOptions): AssistantStream;
/**
* A helper to poll a run status until it reaches a terminal state. More
* information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
poll(runId: string, params: RunRetrieveParams, options?: RequestOptions & {
pollIntervalMs?: number;
}): Promise<Run>;
/**
* Create a Run stream
*/
stream(threadId: string, body: RunCreateParamsBaseStream, options?: RequestOptions): AssistantStream;
/**
* When a run has the `status: "requires_action"` and `required_action.type` is
* `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
* tool calls once they're all completed. All outputs must be submitted in a single
* request.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
submitToolOutputs(runID: string, params: RunSubmitToolOutputsParamsNonStreaming, options?: RequestOptions): APIPromise<Run>;
submitToolOutputs(runID: string, params: RunSubmitToolOutputsParamsStreaming, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>>;
submitToolOutputs(runID: string, params: RunSubmitToolOutputsParamsBase, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent> | Run>;
/**
* A helper to submit a tool output to a run and poll for a terminal run state.
* More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
submitToolOutputsAndPoll(runId: string, params: RunSubmitToolOutputsParamsNonStreaming, options?: RequestOptions & {
pollIntervalMs?: number;
}): Promise<Run>;
/**
* Submit the tool outputs from a previous run and stream the run to a terminal
* state. More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
submitToolOutputsStream(runId: string, params: RunSubmitToolOutputsParamsStream, options?: RequestOptions): AssistantStream;
}
export type RunsPage = CursorPage<Run>;
/**
* Tool call objects
*/
export interface RequiredActionFunctionToolCall {
/**
* The ID of the tool call. This ID must be referenced when you submit the tool
* outputs in using the
* [Submit tool outputs to run](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
* endpoint.
*/
id: string;
/**
* The function definition.
*/
function: RequiredActionFunctionToolCall.Function;
/**
* The type of tool call the output is required for. For now, this is always
* `function`.
*/
type: 'function';
}
export declare namespace RequiredActionFunctionToolCall {
/**
* The function definition.
*/
interface Function {
/**
* The arguments that the model expects you to pass to the function.
*/
arguments: string;
/**
* The name of the function.
*/
name: string;
}
}
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
export interface Run {
/**
* The identifier, which can be referenced in API endpoints.
*/
id: string;
/**
* The ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
* execution of this run.
*/
assistant_id: string;
/**
* The Unix timestamp (in seconds) for when the run was cancelled.
*/
cancelled_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run was completed.
*/
completed_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run was created.
*/
created_at: number;
/**
* The Unix timestamp (in seconds) for when the run will expire.
*/
expires_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run failed.
*/
failed_at: number | null;
/**
* Details on why the run is incomplete. Will be `null` if the run is not
* incomplete.
*/
incomplete_details: Run.IncompleteDetails | null;
/**
* The instructions that the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
* this run.
*/
instructions: string;
/**
* The last error associated with this run. Will be `null` if there are no errors.
*/
last_error: Run.LastError | null;
/**
* The maximum number of completion tokens specified to have been used over the
* course of the run.
*/
max_completion_tokens: number | null;
/**
* The maximum number of prompt tokens specified to have been used over the course
* of the run.
*/
max_prompt_tokens: number | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata: Shared.Metadata | null;
/**
* The model that the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
* this run.
*/
model: string;
/**
* The object type, which is always `thread.run`.
*/
object: 'thread.run';
/**
* Whether to enable
* [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
* during tool use.
*/
parallel_tool_calls: boolean;
/**
* Details on the action required to continue the run. Will be `null` if no action
* is required.
*/
required_action: Run.RequiredAction | null;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format: ThreadsAPI.AssistantResponseFormatOption | null;
/**
* The Unix timestamp (in seconds) for when the run was started.
*/
started_at: number | null;
/**
* The status of the run, which can be either `queued`, `in_progress`,
* `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`,
* `incomplete`, or `expired`.
*/
status: RunStatus;
/**
* The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
* that was executed on as a part of this run.
*/
thread_id: string;
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
tool_choice: ThreadsAPI.AssistantToolChoiceOption | null;
/**
* The list of tools that the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
* this run.
*/
tools: Array<AssistantsAPI.AssistantTool>;
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the initial context window of the run.
*/
truncation_strategy: Run.TruncationStrategy | null;
/**
* Usage statistics related to the run. This value will be `null` if the run is not
* in a terminal state (i.e. `in_progress`, `queued`, etc.).
*/
usage: Run.Usage | null;
/**
* The sampling temperature used for this run. If not set, defaults to 1.
*/
temperature?: number | null;
/**
* The nucleus sampling value used for this run. If not set, defaults to 1.
*/
top_p?: number | null;
}
export declare namespace Run {
/**
* Details on why the run is incomplete. Will be `null` if the run is not
* incomplete.
*/
interface IncompleteDetails {
/**
* The reason why the run is incomplete. This will point to which specific token
* limit was reached over the course of the run.
*/
reason?: 'max_completion_tokens' | 'max_prompt_tokens';
}
/**
* The last error associated with this run. Will be `null` if there are no errors.
*/
interface LastError {
/**
* One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.
*/
code: 'server_error' | 'rate_limit_exceeded' | 'invalid_prompt';
/**
* A human-readable description of the error.
*/
message: string;
}
/**
* Details on the action required to continue the run. Will be `null` if no action
* is required.
*/
interface RequiredAction {
/**
* Details on the tool outputs needed for this run to continue.
*/
submit_tool_outputs: RequiredAction.SubmitToolOutputs;
/**
* For now, this is always `submit_tool_outputs`.
*/
type: 'submit_tool_outputs';
}
namespace RequiredAction {
/**
* Details on the tool outputs needed for this run to continue.
*/
interface SubmitToolOutputs {
/**
* A list of the relevant tool calls.
*/
tool_calls: Array<RunsAPI.RequiredActionFunctionToolCall>;
}
}
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the initial context window of the run.
*/
interface TruncationStrategy {
/**
* The truncation strategy to use for the thread. The default is `auto`. If set to
* `last_messages`, the thread will be truncated to the n most recent messages in
* the thread. When set to `auto`, messages in the middle of the thread will be
* dropped to fit the context length of the model, `max_prompt_tokens`.
*/
type: 'auto' | 'last_messages';
/**
* The number of most recent messages from the thread when constructing the context
* for the run.
*/
last_messages?: number | null;
}
/**
* Usage statistics related to the run. This value will be `null` if the run is not
* in a terminal state (i.e. `in_progress`, `queued`, etc.).
*/
interface Usage {
/**
* Number of completion tokens used over the course of the run.
*/
completion_tokens: number;
/**
* Number of prompt tokens used over the course of the run.
*/
prompt_tokens: number;
/**
* Total number of tokens used (prompt + completion).
*/
total_tokens: number;
}
}
/**
* The status of the run, which can be either `queued`, `in_progress`,
* `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`,
* `incomplete`, or `expired`.
*/
export type RunStatus = 'queued' | 'in_progress' | 'requires_action' | 'cancelling' | 'cancelled' | 'failed' | 'completed' | 'incomplete' | 'expired';
export type RunCreateParams = RunCreateParamsNonStreaming | RunCreateParamsStreaming;
export interface RunCreateParamsBase {
/**
* Body param: The ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
* execute this run.
*/
assistant_id: string;
/**
* Query param: A list of additional fields to include in the response. Currently
* the only supported value is
* `step_details.tool_calls[*].file_search.results[*].content` to fetch the file
* search result content.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
include?: Array<StepsAPI.RunStepInclude>;
/**
* Body param: Appends additional instructions at the end of the instructions for
* the run. This is useful for modifying the behavior on a per-run basis without
* overriding other instructions.
*/
additional_instructions?: string | null;
/**
* Body param: Adds additional messages to the thread before creating the run.
*/
additional_messages?: Array<RunCreateParams.AdditionalMessage> | null;
/**
* Body param: Overrides the
* [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant)
* of the assistant. This is useful for modifying the behavior on a per-run basis.
*/
instructions?: string | null;
/**
* Body param: The maximum number of completion tokens that may be used over the
* course of the run. The run will make a best effort to use only the number of
* completion tokens specified, across multiple turns of the run. If the run
* exceeds the number of completion tokens specified, the run will end with status
* `incomplete`. See `incomplete_details` for more info.
*/
max_completion_tokens?: number | null;
/**
* Body param: The maximum number of prompt tokens that may be used over the course
* of the run. The run will make a best effort to use only the number of prompt
* tokens specified, across multiple turns of the run. If the run exceeds the
* number of prompt tokens specified, the run will end with status `incomplete`.
* See `incomplete_details` for more info.
*/
max_prompt_tokens?: number | null;
/**
* Body param: Set of 16 key-value pairs that can be attached to an object. This
* can be useful for storing additional information about the object in a
* structured format, and querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* Body param: The ID of the
* [Model](https://platform.openai.com/docs/api-reference/models) to be used to
* execute this run. If a value is provided here, it will override the model
* associated with the assistant. If not, the model associated with the assistant
* will be used.
*/
model?: (string & {}) | Shared.ChatModel | null;
/**
* Body param: Whether to enable
* [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
* during tool use.
*/
parallel_tool_calls?: boolean;
/**
* Body param: Constrains effort on reasoning for
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
* supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
* Reducing reasoning effort can result in faster responses and fewer tokens used
* on reasoning in a response.
*
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
* calls are supported for all reasoning values in gpt-5.1.
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
* support `none`.
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
* - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
*/
reasoning_effort?: Shared.ReasoningEffort | null;
/**
* Body param: Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream?: boolean | null;
/**
* Body param: What sampling temperature to use, between 0 and 2. Higher values
* like 0.8 will make the output more random, while lower values like 0.2 will make
* it more focused and deterministic.
*/
temperature?: number | null;
/**
* Body param: Controls which (if any) tool is called by the model. `none` means
* the model will not call any tools and instead generates a message. `auto` is the
* default value and means the model can pick between generating a message or
* calling one or more tools. `required` means the model must call one or more
* tools before responding to the user. Specifying a particular tool like
* `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
tool_choice?: ThreadsAPI.AssistantToolChoiceOption | null;
/**
* Body param: Override the tools the assistant can use for this run. This is
* useful for modifying the behavior on a per-run basis.
*/
tools?: Array<AssistantsAPI.AssistantTool> | null;
/**
* Body param: An alternative to sampling with temperature, called nucleus
* sampling, where the model considers the results of the tokens with top_p
* probability mass. So 0.1 means only the tokens comprising the top 10%
* probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
/**
* Body param: Controls for how a thread will be truncated prior to the run. Use
* this to control the initial context window of the run.
*/
truncation_strategy?: RunCreateParams.TruncationStrategy | null;
}
export declare namespace RunCreateParams {
interface AdditionalMessage {
/**
* The text contents of the message.
*/
content: string | Array<MessagesAPI.MessageContentPartParam>;
/**
* The role of the entity that is creating the message. Allowed values include:
*
* - `user`: Indicates the message is sent by an actual user and should be used in
* most cases to represent user-generated messages.
* - `assistant`: Indicates the message is generated by the assistant. Use this
* value to insert messages from the assistant into the conversation.
*/
role: 'user' | 'assistant';
/**
* A list of files attached to the message, and the tools they should be added to.
*/
attachments?: Array<AdditionalMessage.Attachment> | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace AdditionalMessage {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.FileSearch>;
}
namespace Attachment {
interface FileSearch {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
}
}
}
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the initial context window of the run.
*/
interface TruncationStrategy {
/**
* The truncation strategy to use for the thread. The default is `auto`. If set to
* `last_messages`, the thread will be truncated to the n most recent messages in
* the thread. When set to `auto`, messages in the middle of the thread will be
* dropped to fit the context length of the model, `max_prompt_tokens`.
*/
type: 'auto' | 'last_messages';
/**
* The number of most recent messages from the thread when constructing the context
* for the run.
*/
last_messages?: number | null;
}
type RunCreateParamsNonStreaming = RunsAPI.RunCreateParamsNonStreaming;
type RunCreateParamsStreaming = RunsAPI.RunCreateParamsStreaming;
}
export interface RunCreateParamsNonStreaming extends RunCreateParamsBase {
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream?: false | null;
}
export interface RunCreateParamsStreaming extends RunCreateParamsBase {
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream: true;
}
export interface RunRetrieveParams {
/**
* The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
* that was run.
*/
thread_id: string;
}
export interface RunUpdateParams {
/**
* Path param: The ID of the
* [thread](https://platform.openai.com/docs/api-reference/threads) that was run.
*/
thread_id: string;
/**
* Body param: Set of 16 key-value pairs that can be attached to an object. This
* can be useful for storing additional information about the object in a
* structured format, and querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
export interface RunListParams extends CursorPageParams {
/**
* A cursor for use in pagination. `before` is an object ID that defines your place
* in the list. For instance, if you make a list request and receive 100 objects,
* starting with obj_foo, your subsequent call can include before=obj_foo in order
* to fetch the previous page of the list.
*/
before?: string;
/**
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
* order and `desc` for descending order.
*/
order?: 'asc' | 'desc';
}
export interface RunCancelParams {
/**
* The ID of the thread to which this run belongs.
*/
thread_id: string;
}
export type RunCreateAndPollParams = ThreadsAPI.ThreadCreateAndRunParamsNonStreaming;
export type RunCreateAndStreamParams = RunCreateParamsBaseStream;
export type RunStreamParams = RunCreateParamsBaseStream;
export type RunSubmitToolOutputsParams = RunSubmitToolOutputsParamsNonStreaming | RunSubmitToolOutputsParamsStreaming;
export interface RunSubmitToolOutputsParamsBase {
/**
* Path param: The ID of the
* [thread](https://platform.openai.com/docs/api-reference/threads) to which this
* run belongs.
*/
thread_id: string;
/**
* Body param: A list of tools for which the outputs are being submitted.
*/
tool_outputs: Array<RunSubmitToolOutputsParams.ToolOutput>;
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream?: boolean | null;
}
export declare namespace RunSubmitToolOutputsParams {
interface ToolOutput {
/**
* The output of the tool call to be submitted to continue the run.
*/
output?: string;
/**
* The ID of the tool call in the `required_action` object within the run object
* the output is being submitted for.
*/
tool_call_id?: string;
}
type RunSubmitToolOutputsParamsNonStreaming = RunsAPI.RunSubmitToolOutputsParamsNonStreaming;
type RunSubmitToolOutputsParamsStreaming = RunsAPI.RunSubmitToolOutputsParamsStreaming;
}
export interface RunSubmitToolOutputsParamsNonStreaming extends RunSubmitToolOutputsParamsBase {
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream?: false | null;
}
export interface RunSubmitToolOutputsParamsStreaming extends RunSubmitToolOutputsParamsBase {
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream: true;
}
export type RunSubmitToolOutputsAndPollParams = RunSubmitToolOutputsParamsNonStreaming;
export type RunSubmitToolOutputsStreamParams = RunSubmitToolOutputsParamsStream;
export declare namespace Runs {
export { type RequiredActionFunctionToolCall as RequiredActionFunctionToolCall, type Run as Run, type RunStatus as RunStatus, type RunsPage as RunsPage, type RunCreateParams as RunCreateParams, type RunCreateParamsNonStreaming as RunCreateParamsNonStreaming, type RunCreateParamsStreaming as RunCreateParamsStreaming, type RunRetrieveParams as RunRetrieveParams, type RunUpdateParams as RunUpdateParams, type RunListParams as RunListParams, type RunCreateAndPollParams, type RunCreateAndStreamParams, type RunStreamParams, type RunSubmitToolOutputsParams as RunSubmitToolOutputsParams, type RunSubmitToolOutputsParamsNonStreaming as RunSubmitToolOutputsParamsNonStreaming, type RunSubmitToolOutputsParamsStreaming as RunSubmitToolOutputsParamsStreaming, type RunSubmitToolOutputsAndPollParams, type RunSubmitToolOutputsStreamParams, };
export { Steps as Steps, type CodeInterpreterLogs as CodeInterpreterLogs, type CodeInterpreterOutputImage as CodeInterpreterOutputImage, type CodeInterpreterToolCall as CodeInterpreterToolCall, type CodeInterpreterToolCallDelta as CodeInterpreterToolCallDelta, type FileSearchToolCall as FileSearchToolCall, type FileSearchToolCallDelta as FileSearchToolCallDelta, type FunctionToolCall as FunctionToolCall, type FunctionToolCallDelta as FunctionToolCallDelta, type MessageCreationStepDetails as MessageCreationStepDetails, type RunStep as RunStep, type RunStepDelta as RunStepDelta, type RunStepDeltaEvent as RunStepDeltaEvent, type RunStepDeltaMessageDelta as RunStepDeltaMessageDelta, type RunStepInclude as RunStepInclude, type ToolCall as ToolCall, type ToolCallDelta as ToolCallDelta, type ToolCallDeltaObject as ToolCallDeltaObject, type ToolCallsStepDetails as ToolCallsStepDetails, type RunStepsPage as RunStepsPage, type StepRetrieveParams as StepRetrieveParams, type StepListParams as StepListParams, };
}
//# sourceMappingURL=runs.d.mts.map
File diff suppressed because one or more lines are too long
+743
View File
@@ -0,0 +1,743 @@
import { APIResource } from "../../../../core/resource.js";
import * as RunsAPI from "./runs.js";
import * as Shared from "../../../shared.js";
import * as AssistantsAPI from "../../assistants.js";
import * as MessagesAPI from "../messages.js";
import * as ThreadsAPI from "../threads.js";
import * as StepsAPI from "./steps.js";
import { CodeInterpreterLogs, CodeInterpreterOutputImage, CodeInterpreterToolCall, CodeInterpreterToolCallDelta, FileSearchToolCall, FileSearchToolCallDelta, FunctionToolCall, FunctionToolCallDelta, MessageCreationStepDetails, RunStep, RunStepDelta, RunStepDeltaEvent, RunStepDeltaMessageDelta, RunStepInclude, RunStepsPage, StepListParams, StepRetrieveParams, Steps, ToolCall, ToolCallDelta, ToolCallDeltaObject, ToolCallsStepDetails } from "./steps.js";
import { APIPromise } from "../../../../core/api-promise.js";
import { CursorPage, type CursorPageParams, PagePromise } from "../../../../core/pagination.js";
import { Stream } from "../../../../core/streaming.js";
import { RequestOptions } from "../../../../internal/request-options.js";
import { AssistantStream, RunCreateParamsBaseStream } from "../../../../lib/AssistantStream.js";
import { RunSubmitToolOutputsParamsStream } from "../../../../lib/AssistantStream.js";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export declare class Runs extends APIResource {
steps: StepsAPI.Steps;
/**
* Create a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(threadID: string, params: RunCreateParamsNonStreaming, options?: RequestOptions): APIPromise<Run>;
create(threadID: string, params: RunCreateParamsStreaming, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>>;
create(threadID: string, params: RunCreateParamsBase, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent> | Run>;
/**
* Retrieves a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(runID: string, params: RunRetrieveParams, options?: RequestOptions): APIPromise<Run>;
/**
* Modifies a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(runID: string, params: RunUpdateParams, options?: RequestOptions): APIPromise<Run>;
/**
* Returns a list of runs belonging to a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(threadID: string, query?: RunListParams | null | undefined, options?: RequestOptions): PagePromise<RunsPage, Run>;
/**
* Cancels a run that is `in_progress`.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
cancel(runID: string, params: RunCancelParams, options?: RequestOptions): APIPromise<Run>;
/**
* A helper to create a run an poll for a terminal state. More information on Run
* lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
createAndPoll(threadId: string, body: RunCreateParamsNonStreaming, options?: RequestOptions & {
pollIntervalMs?: number;
}): Promise<Run>;
/**
* Create a Run stream
*
* @deprecated use `stream` instead
*/
createAndStream(threadId: string, body: RunCreateParamsBaseStream, options?: RequestOptions): AssistantStream;
/**
* A helper to poll a run status until it reaches a terminal state. More
* information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
poll(runId: string, params: RunRetrieveParams, options?: RequestOptions & {
pollIntervalMs?: number;
}): Promise<Run>;
/**
* Create a Run stream
*/
stream(threadId: string, body: RunCreateParamsBaseStream, options?: RequestOptions): AssistantStream;
/**
* When a run has the `status: "requires_action"` and `required_action.type` is
* `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
* tool calls once they're all completed. All outputs must be submitted in a single
* request.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
submitToolOutputs(runID: string, params: RunSubmitToolOutputsParamsNonStreaming, options?: RequestOptions): APIPromise<Run>;
submitToolOutputs(runID: string, params: RunSubmitToolOutputsParamsStreaming, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>>;
submitToolOutputs(runID: string, params: RunSubmitToolOutputsParamsBase, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent> | Run>;
/**
* A helper to submit a tool output to a run and poll for a terminal run state.
* More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
submitToolOutputsAndPoll(runId: string, params: RunSubmitToolOutputsParamsNonStreaming, options?: RequestOptions & {
pollIntervalMs?: number;
}): Promise<Run>;
/**
* Submit the tool outputs from a previous run and stream the run to a terminal
* state. More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
submitToolOutputsStream(runId: string, params: RunSubmitToolOutputsParamsStream, options?: RequestOptions): AssistantStream;
}
export type RunsPage = CursorPage<Run>;
/**
* Tool call objects
*/
export interface RequiredActionFunctionToolCall {
/**
* The ID of the tool call. This ID must be referenced when you submit the tool
* outputs in using the
* [Submit tool outputs to run](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
* endpoint.
*/
id: string;
/**
* The function definition.
*/
function: RequiredActionFunctionToolCall.Function;
/**
* The type of tool call the output is required for. For now, this is always
* `function`.
*/
type: 'function';
}
export declare namespace RequiredActionFunctionToolCall {
/**
* The function definition.
*/
interface Function {
/**
* The arguments that the model expects you to pass to the function.
*/
arguments: string;
/**
* The name of the function.
*/
name: string;
}
}
/**
* Represents an execution run on a
* [thread](https://platform.openai.com/docs/api-reference/threads).
*/
export interface Run {
/**
* The identifier, which can be referenced in API endpoints.
*/
id: string;
/**
* The ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
* execution of this run.
*/
assistant_id: string;
/**
* The Unix timestamp (in seconds) for when the run was cancelled.
*/
cancelled_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run was completed.
*/
completed_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run was created.
*/
created_at: number;
/**
* The Unix timestamp (in seconds) for when the run will expire.
*/
expires_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run failed.
*/
failed_at: number | null;
/**
* Details on why the run is incomplete. Will be `null` if the run is not
* incomplete.
*/
incomplete_details: Run.IncompleteDetails | null;
/**
* The instructions that the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
* this run.
*/
instructions: string;
/**
* The last error associated with this run. Will be `null` if there are no errors.
*/
last_error: Run.LastError | null;
/**
* The maximum number of completion tokens specified to have been used over the
* course of the run.
*/
max_completion_tokens: number | null;
/**
* The maximum number of prompt tokens specified to have been used over the course
* of the run.
*/
max_prompt_tokens: number | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata: Shared.Metadata | null;
/**
* The model that the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
* this run.
*/
model: string;
/**
* The object type, which is always `thread.run`.
*/
object: 'thread.run';
/**
* Whether to enable
* [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
* during tool use.
*/
parallel_tool_calls: boolean;
/**
* Details on the action required to continue the run. Will be `null` if no action
* is required.
*/
required_action: Run.RequiredAction | null;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format: ThreadsAPI.AssistantResponseFormatOption | null;
/**
* The Unix timestamp (in seconds) for when the run was started.
*/
started_at: number | null;
/**
* The status of the run, which can be either `queued`, `in_progress`,
* `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`,
* `incomplete`, or `expired`.
*/
status: RunStatus;
/**
* The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
* that was executed on as a part of this run.
*/
thread_id: string;
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
tool_choice: ThreadsAPI.AssistantToolChoiceOption | null;
/**
* The list of tools that the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
* this run.
*/
tools: Array<AssistantsAPI.AssistantTool>;
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the initial context window of the run.
*/
truncation_strategy: Run.TruncationStrategy | null;
/**
* Usage statistics related to the run. This value will be `null` if the run is not
* in a terminal state (i.e. `in_progress`, `queued`, etc.).
*/
usage: Run.Usage | null;
/**
* The sampling temperature used for this run. If not set, defaults to 1.
*/
temperature?: number | null;
/**
* The nucleus sampling value used for this run. If not set, defaults to 1.
*/
top_p?: number | null;
}
export declare namespace Run {
/**
* Details on why the run is incomplete. Will be `null` if the run is not
* incomplete.
*/
interface IncompleteDetails {
/**
* The reason why the run is incomplete. This will point to which specific token
* limit was reached over the course of the run.
*/
reason?: 'max_completion_tokens' | 'max_prompt_tokens';
}
/**
* The last error associated with this run. Will be `null` if there are no errors.
*/
interface LastError {
/**
* One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.
*/
code: 'server_error' | 'rate_limit_exceeded' | 'invalid_prompt';
/**
* A human-readable description of the error.
*/
message: string;
}
/**
* Details on the action required to continue the run. Will be `null` if no action
* is required.
*/
interface RequiredAction {
/**
* Details on the tool outputs needed for this run to continue.
*/
submit_tool_outputs: RequiredAction.SubmitToolOutputs;
/**
* For now, this is always `submit_tool_outputs`.
*/
type: 'submit_tool_outputs';
}
namespace RequiredAction {
/**
* Details on the tool outputs needed for this run to continue.
*/
interface SubmitToolOutputs {
/**
* A list of the relevant tool calls.
*/
tool_calls: Array<RunsAPI.RequiredActionFunctionToolCall>;
}
}
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the initial context window of the run.
*/
interface TruncationStrategy {
/**
* The truncation strategy to use for the thread. The default is `auto`. If set to
* `last_messages`, the thread will be truncated to the n most recent messages in
* the thread. When set to `auto`, messages in the middle of the thread will be
* dropped to fit the context length of the model, `max_prompt_tokens`.
*/
type: 'auto' | 'last_messages';
/**
* The number of most recent messages from the thread when constructing the context
* for the run.
*/
last_messages?: number | null;
}
/**
* Usage statistics related to the run. This value will be `null` if the run is not
* in a terminal state (i.e. `in_progress`, `queued`, etc.).
*/
interface Usage {
/**
* Number of completion tokens used over the course of the run.
*/
completion_tokens: number;
/**
* Number of prompt tokens used over the course of the run.
*/
prompt_tokens: number;
/**
* Total number of tokens used (prompt + completion).
*/
total_tokens: number;
}
}
/**
* The status of the run, which can be either `queued`, `in_progress`,
* `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`,
* `incomplete`, or `expired`.
*/
export type RunStatus = 'queued' | 'in_progress' | 'requires_action' | 'cancelling' | 'cancelled' | 'failed' | 'completed' | 'incomplete' | 'expired';
export type RunCreateParams = RunCreateParamsNonStreaming | RunCreateParamsStreaming;
export interface RunCreateParamsBase {
/**
* Body param: The ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
* execute this run.
*/
assistant_id: string;
/**
* Query param: A list of additional fields to include in the response. Currently
* the only supported value is
* `step_details.tool_calls[*].file_search.results[*].content` to fetch the file
* search result content.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
include?: Array<StepsAPI.RunStepInclude>;
/**
* Body param: Appends additional instructions at the end of the instructions for
* the run. This is useful for modifying the behavior on a per-run basis without
* overriding other instructions.
*/
additional_instructions?: string | null;
/**
* Body param: Adds additional messages to the thread before creating the run.
*/
additional_messages?: Array<RunCreateParams.AdditionalMessage> | null;
/**
* Body param: Overrides the
* [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant)
* of the assistant. This is useful for modifying the behavior on a per-run basis.
*/
instructions?: string | null;
/**
* Body param: The maximum number of completion tokens that may be used over the
* course of the run. The run will make a best effort to use only the number of
* completion tokens specified, across multiple turns of the run. If the run
* exceeds the number of completion tokens specified, the run will end with status
* `incomplete`. See `incomplete_details` for more info.
*/
max_completion_tokens?: number | null;
/**
* Body param: The maximum number of prompt tokens that may be used over the course
* of the run. The run will make a best effort to use only the number of prompt
* tokens specified, across multiple turns of the run. If the run exceeds the
* number of prompt tokens specified, the run will end with status `incomplete`.
* See `incomplete_details` for more info.
*/
max_prompt_tokens?: number | null;
/**
* Body param: Set of 16 key-value pairs that can be attached to an object. This
* can be useful for storing additional information about the object in a
* structured format, and querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* Body param: The ID of the
* [Model](https://platform.openai.com/docs/api-reference/models) to be used to
* execute this run. If a value is provided here, it will override the model
* associated with the assistant. If not, the model associated with the assistant
* will be used.
*/
model?: (string & {}) | Shared.ChatModel | null;
/**
* Body param: Whether to enable
* [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
* during tool use.
*/
parallel_tool_calls?: boolean;
/**
* Body param: Constrains effort on reasoning for
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
* supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`.
* Reducing reasoning effort can result in faster responses and fewer tokens used
* on reasoning in a response.
*
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
* calls are supported for all reasoning values in gpt-5.1.
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
* support `none`.
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
* - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
*/
reasoning_effort?: Shared.ReasoningEffort | null;
/**
* Body param: Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: ThreadsAPI.AssistantResponseFormatOption | null;
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream?: boolean | null;
/**
* Body param: What sampling temperature to use, between 0 and 2. Higher values
* like 0.8 will make the output more random, while lower values like 0.2 will make
* it more focused and deterministic.
*/
temperature?: number | null;
/**
* Body param: Controls which (if any) tool is called by the model. `none` means
* the model will not call any tools and instead generates a message. `auto` is the
* default value and means the model can pick between generating a message or
* calling one or more tools. `required` means the model must call one or more
* tools before responding to the user. Specifying a particular tool like
* `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
tool_choice?: ThreadsAPI.AssistantToolChoiceOption | null;
/**
* Body param: Override the tools the assistant can use for this run. This is
* useful for modifying the behavior on a per-run basis.
*/
tools?: Array<AssistantsAPI.AssistantTool> | null;
/**
* Body param: An alternative to sampling with temperature, called nucleus
* sampling, where the model considers the results of the tokens with top_p
* probability mass. So 0.1 means only the tokens comprising the top 10%
* probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
/**
* Body param: Controls for how a thread will be truncated prior to the run. Use
* this to control the initial context window of the run.
*/
truncation_strategy?: RunCreateParams.TruncationStrategy | null;
}
export declare namespace RunCreateParams {
interface AdditionalMessage {
/**
* The text contents of the message.
*/
content: string | Array<MessagesAPI.MessageContentPartParam>;
/**
* The role of the entity that is creating the message. Allowed values include:
*
* - `user`: Indicates the message is sent by an actual user and should be used in
* most cases to represent user-generated messages.
* - `assistant`: Indicates the message is generated by the assistant. Use this
* value to insert messages from the assistant into the conversation.
*/
role: 'user' | 'assistant';
/**
* A list of files attached to the message, and the tools they should be added to.
*/
attachments?: Array<AdditionalMessage.Attachment> | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace AdditionalMessage {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.FileSearch>;
}
namespace Attachment {
interface FileSearch {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
}
}
}
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the initial context window of the run.
*/
interface TruncationStrategy {
/**
* The truncation strategy to use for the thread. The default is `auto`. If set to
* `last_messages`, the thread will be truncated to the n most recent messages in
* the thread. When set to `auto`, messages in the middle of the thread will be
* dropped to fit the context length of the model, `max_prompt_tokens`.
*/
type: 'auto' | 'last_messages';
/**
* The number of most recent messages from the thread when constructing the context
* for the run.
*/
last_messages?: number | null;
}
type RunCreateParamsNonStreaming = RunsAPI.RunCreateParamsNonStreaming;
type RunCreateParamsStreaming = RunsAPI.RunCreateParamsStreaming;
}
export interface RunCreateParamsNonStreaming extends RunCreateParamsBase {
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream?: false | null;
}
export interface RunCreateParamsStreaming extends RunCreateParamsBase {
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream: true;
}
export interface RunRetrieveParams {
/**
* The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
* that was run.
*/
thread_id: string;
}
export interface RunUpdateParams {
/**
* Path param: The ID of the
* [thread](https://platform.openai.com/docs/api-reference/threads) that was run.
*/
thread_id: string;
/**
* Body param: Set of 16 key-value pairs that can be attached to an object. This
* can be useful for storing additional information about the object in a
* structured format, and querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
export interface RunListParams extends CursorPageParams {
/**
* A cursor for use in pagination. `before` is an object ID that defines your place
* in the list. For instance, if you make a list request and receive 100 objects,
* starting with obj_foo, your subsequent call can include before=obj_foo in order
* to fetch the previous page of the list.
*/
before?: string;
/**
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
* order and `desc` for descending order.
*/
order?: 'asc' | 'desc';
}
export interface RunCancelParams {
/**
* The ID of the thread to which this run belongs.
*/
thread_id: string;
}
export type RunCreateAndPollParams = ThreadsAPI.ThreadCreateAndRunParamsNonStreaming;
export type RunCreateAndStreamParams = RunCreateParamsBaseStream;
export type RunStreamParams = RunCreateParamsBaseStream;
export type RunSubmitToolOutputsParams = RunSubmitToolOutputsParamsNonStreaming | RunSubmitToolOutputsParamsStreaming;
export interface RunSubmitToolOutputsParamsBase {
/**
* Path param: The ID of the
* [thread](https://platform.openai.com/docs/api-reference/threads) to which this
* run belongs.
*/
thread_id: string;
/**
* Body param: A list of tools for which the outputs are being submitted.
*/
tool_outputs: Array<RunSubmitToolOutputsParams.ToolOutput>;
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream?: boolean | null;
}
export declare namespace RunSubmitToolOutputsParams {
interface ToolOutput {
/**
* The output of the tool call to be submitted to continue the run.
*/
output?: string;
/**
* The ID of the tool call in the `required_action` object within the run object
* the output is being submitted for.
*/
tool_call_id?: string;
}
type RunSubmitToolOutputsParamsNonStreaming = RunsAPI.RunSubmitToolOutputsParamsNonStreaming;
type RunSubmitToolOutputsParamsStreaming = RunsAPI.RunSubmitToolOutputsParamsStreaming;
}
export interface RunSubmitToolOutputsParamsNonStreaming extends RunSubmitToolOutputsParamsBase {
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream?: false | null;
}
export interface RunSubmitToolOutputsParamsStreaming extends RunSubmitToolOutputsParamsBase {
/**
* Body param: If `true`, returns a stream of events that happen during the Run as
* server-sent events, terminating when the Run enters a terminal state with a
* `data: [DONE]` message.
*/
stream: true;
}
export type RunSubmitToolOutputsAndPollParams = RunSubmitToolOutputsParamsNonStreaming;
export type RunSubmitToolOutputsStreamParams = RunSubmitToolOutputsParamsStream;
export declare namespace Runs {
export { type RequiredActionFunctionToolCall as RequiredActionFunctionToolCall, type Run as Run, type RunStatus as RunStatus, type RunsPage as RunsPage, type RunCreateParams as RunCreateParams, type RunCreateParamsNonStreaming as RunCreateParamsNonStreaming, type RunCreateParamsStreaming as RunCreateParamsStreaming, type RunRetrieveParams as RunRetrieveParams, type RunUpdateParams as RunUpdateParams, type RunListParams as RunListParams, type RunCreateAndPollParams, type RunCreateAndStreamParams, type RunStreamParams, type RunSubmitToolOutputsParams as RunSubmitToolOutputsParams, type RunSubmitToolOutputsParamsNonStreaming as RunSubmitToolOutputsParamsNonStreaming, type RunSubmitToolOutputsParamsStreaming as RunSubmitToolOutputsParamsStreaming, type RunSubmitToolOutputsAndPollParams, type RunSubmitToolOutputsStreamParams, };
export { Steps as Steps, type CodeInterpreterLogs as CodeInterpreterLogs, type CodeInterpreterOutputImage as CodeInterpreterOutputImage, type CodeInterpreterToolCall as CodeInterpreterToolCall, type CodeInterpreterToolCallDelta as CodeInterpreterToolCallDelta, type FileSearchToolCall as FileSearchToolCall, type FileSearchToolCallDelta as FileSearchToolCallDelta, type FunctionToolCall as FunctionToolCall, type FunctionToolCallDelta as FunctionToolCallDelta, type MessageCreationStepDetails as MessageCreationStepDetails, type RunStep as RunStep, type RunStepDelta as RunStepDelta, type RunStepDeltaEvent as RunStepDeltaEvent, type RunStepDeltaMessageDelta as RunStepDeltaMessageDelta, type RunStepInclude as RunStepInclude, type ToolCall as ToolCall, type ToolCallDelta as ToolCallDelta, type ToolCallDeltaObject as ToolCallDeltaObject, type ToolCallsStepDetails as ToolCallsStepDetails, type RunStepsPage as RunStepsPage, type StepRetrieveParams as StepRetrieveParams, type StepListParams as StepListParams, };
}
//# sourceMappingURL=runs.d.ts.map
File diff suppressed because one or more lines are too long
+192
View File
@@ -0,0 +1,192 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Runs = void 0;
const tslib_1 = require("../../../../internal/tslib.js");
const resource_1 = require("../../../../core/resource.js");
const StepsAPI = tslib_1.__importStar(require("./steps.js"));
const steps_1 = require("./steps.js");
const pagination_1 = require("../../../../core/pagination.js");
const headers_1 = require("../../../../internal/headers.js");
const AssistantStream_1 = require("../../../../lib/AssistantStream.js");
const sleep_1 = require("../../../../internal/utils/sleep.js");
const path_1 = require("../../../../internal/utils/path.js");
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
class Runs extends resource_1.APIResource {
constructor() {
super(...arguments);
this.steps = new StepsAPI.Steps(this._client);
}
create(threadID, params, options) {
const { include, ...body } = params;
return this._client.post((0, path_1.path) `/threads/${threadID}/runs`, {
query: { include },
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: params.stream ?? false,
__synthesizeEventData: true,
__security: { bearerAuth: true },
});
}
/**
* Retrieves a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(runID, params, options) {
const { thread_id } = params;
return this._client.get((0, path_1.path) `/threads/${thread_id}/runs/${runID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Modifies a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(runID, params, options) {
const { thread_id, ...body } = params;
return this._client.post((0, path_1.path) `/threads/${thread_id}/runs/${runID}`, {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Returns a list of runs belonging to a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(threadID, query = {}, options) {
return this._client.getAPIList((0, path_1.path) `/threads/${threadID}/runs`, (pagination_1.CursorPage), {
query,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Cancels a run that is `in_progress`.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
cancel(runID, params, options) {
const { thread_id } = params;
return this._client.post((0, path_1.path) `/threads/${thread_id}/runs/${runID}/cancel`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* A helper to create a run an poll for a terminal state. More information on Run
* lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
async createAndPoll(threadId, body, options) {
const run = await this.create(threadId, body, options);
return await this.poll(run.id, { thread_id: threadId }, options);
}
/**
* Create a Run stream
*
* @deprecated use `stream` instead
*/
createAndStream(threadId, body, options) {
return AssistantStream_1.AssistantStream.createAssistantStream(threadId, this._client.beta.threads.runs, body, options);
}
/**
* A helper to poll a run status until it reaches a terminal state. More
* information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
async poll(runId, params, options) {
const headers = (0, headers_1.buildHeaders)([
options?.headers,
{
'X-Stainless-Poll-Helper': 'true',
'X-Stainless-Custom-Poll-Interval': options?.pollIntervalMs?.toString() ?? undefined,
},
]);
while (true) {
const { data: run, response } = await this.retrieve(runId, params, {
...options,
headers: { ...options?.headers, ...headers },
}).withResponse();
switch (run.status) {
//If we are in any sort of intermediate state we poll
case 'queued':
case 'in_progress':
case 'cancelling':
let sleepInterval = 5000;
if (options?.pollIntervalMs) {
sleepInterval = options.pollIntervalMs;
}
else {
const headerInterval = response.headers.get('openai-poll-after-ms');
if (headerInterval) {
const headerIntervalMs = parseInt(headerInterval);
if (!isNaN(headerIntervalMs)) {
sleepInterval = headerIntervalMs;
}
}
}
await (0, sleep_1.sleep)(sleepInterval);
break;
//We return the run in any terminal state.
case 'requires_action':
case 'incomplete':
case 'cancelled':
case 'completed':
case 'failed':
case 'expired':
return run;
}
}
}
/**
* Create a Run stream
*/
stream(threadId, body, options) {
return AssistantStream_1.AssistantStream.createAssistantStream(threadId, this._client.beta.threads.runs, body, options);
}
submitToolOutputs(runID, params, options) {
const { thread_id, ...body } = params;
return this._client.post((0, path_1.path) `/threads/${thread_id}/runs/${runID}/submit_tool_outputs`, {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: params.stream ?? false,
__synthesizeEventData: true,
__security: { bearerAuth: true },
});
}
/**
* A helper to submit a tool output to a run and poll for a terminal run state.
* More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
async submitToolOutputsAndPoll(runId, params, options) {
const run = await this.submitToolOutputs(runId, params, options);
return await this.poll(run.id, params, options);
}
/**
* Submit the tool outputs from a previous run and stream the run to a terminal
* state. More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
submitToolOutputsStream(runId, params, options) {
return AssistantStream_1.AssistantStream.createToolAssistantStream(runId, this._client.beta.threads.runs, params, options);
}
}
exports.Runs = Runs;
Runs.Steps = steps_1.Steps;
//# sourceMappingURL=runs.js.map
File diff suppressed because one or more lines are too long
+187
View File
@@ -0,0 +1,187 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import * as StepsAPI from "./steps.mjs";
import { Steps, } from "./steps.mjs";
import { CursorPage } from "../../../../core/pagination.mjs";
import { buildHeaders } from "../../../../internal/headers.mjs";
import { AssistantStream } from "../../../../lib/AssistantStream.mjs";
import { sleep } from "../../../../internal/utils/sleep.mjs";
import { path } from "../../../../internal/utils/path.mjs";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export class Runs extends APIResource {
constructor() {
super(...arguments);
this.steps = new StepsAPI.Steps(this._client);
}
create(threadID, params, options) {
const { include, ...body } = params;
return this._client.post(path `/threads/${threadID}/runs`, {
query: { include },
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: params.stream ?? false,
__synthesizeEventData: true,
__security: { bearerAuth: true },
});
}
/**
* Retrieves a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(runID, params, options) {
const { thread_id } = params;
return this._client.get(path `/threads/${thread_id}/runs/${runID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Modifies a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(runID, params, options) {
const { thread_id, ...body } = params;
return this._client.post(path `/threads/${thread_id}/runs/${runID}`, {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Returns a list of runs belonging to a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(threadID, query = {}, options) {
return this._client.getAPIList(path `/threads/${threadID}/runs`, (CursorPage), {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Cancels a run that is `in_progress`.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
cancel(runID, params, options) {
const { thread_id } = params;
return this._client.post(path `/threads/${thread_id}/runs/${runID}/cancel`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* A helper to create a run an poll for a terminal state. More information on Run
* lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
async createAndPoll(threadId, body, options) {
const run = await this.create(threadId, body, options);
return await this.poll(run.id, { thread_id: threadId }, options);
}
/**
* Create a Run stream
*
* @deprecated use `stream` instead
*/
createAndStream(threadId, body, options) {
return AssistantStream.createAssistantStream(threadId, this._client.beta.threads.runs, body, options);
}
/**
* A helper to poll a run status until it reaches a terminal state. More
* information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
async poll(runId, params, options) {
const headers = buildHeaders([
options?.headers,
{
'X-Stainless-Poll-Helper': 'true',
'X-Stainless-Custom-Poll-Interval': options?.pollIntervalMs?.toString() ?? undefined,
},
]);
while (true) {
const { data: run, response } = await this.retrieve(runId, params, {
...options,
headers: { ...options?.headers, ...headers },
}).withResponse();
switch (run.status) {
//If we are in any sort of intermediate state we poll
case 'queued':
case 'in_progress':
case 'cancelling':
let sleepInterval = 5000;
if (options?.pollIntervalMs) {
sleepInterval = options.pollIntervalMs;
}
else {
const headerInterval = response.headers.get('openai-poll-after-ms');
if (headerInterval) {
const headerIntervalMs = parseInt(headerInterval);
if (!isNaN(headerIntervalMs)) {
sleepInterval = headerIntervalMs;
}
}
}
await sleep(sleepInterval);
break;
//We return the run in any terminal state.
case 'requires_action':
case 'incomplete':
case 'cancelled':
case 'completed':
case 'failed':
case 'expired':
return run;
}
}
}
/**
* Create a Run stream
*/
stream(threadId, body, options) {
return AssistantStream.createAssistantStream(threadId, this._client.beta.threads.runs, body, options);
}
submitToolOutputs(runID, params, options) {
const { thread_id, ...body } = params;
return this._client.post(path `/threads/${thread_id}/runs/${runID}/submit_tool_outputs`, {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: params.stream ?? false,
__synthesizeEventData: true,
__security: { bearerAuth: true },
});
}
/**
* A helper to submit a tool output to a run and poll for a terminal run state.
* More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
async submitToolOutputsAndPoll(runId, params, options) {
const run = await this.submitToolOutputs(runId, params, options);
return await this.poll(run.id, params, options);
}
/**
* Submit the tool outputs from a previous run and stream the run to a terminal
* state. More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
submitToolOutputsStream(runId, params, options) {
return AssistantStream.createToolAssistantStream(runId, this._client.beta.threads.runs, params, options);
}
}
Runs.Steps = Steps;
//# sourceMappingURL=runs.mjs.map
File diff suppressed because one or more lines are too long
+617
View File
@@ -0,0 +1,617 @@
import { APIResource } from "../../../../core/resource.mjs";
import * as StepsAPI from "./steps.mjs";
import * as Shared from "../../../shared.mjs";
import { APIPromise } from "../../../../core/api-promise.mjs";
import { CursorPage, type CursorPageParams, PagePromise } from "../../../../core/pagination.mjs";
import { RequestOptions } from "../../../../internal/request-options.mjs";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export declare class Steps extends APIResource {
/**
* Retrieves a run step.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(stepID: string, params: StepRetrieveParams, options?: RequestOptions): APIPromise<RunStep>;
/**
* Returns a list of run steps belonging to a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(runID: string, params: StepListParams, options?: RequestOptions): PagePromise<RunStepsPage, RunStep>;
}
export type RunStepsPage = CursorPage<RunStep>;
/**
* Text output from the Code Interpreter tool call as part of a run step.
*/
export interface CodeInterpreterLogs {
/**
* The index of the output in the outputs array.
*/
index: number;
/**
* Always `logs`.
*/
type: 'logs';
/**
* The text output from the Code Interpreter tool call.
*/
logs?: string;
}
export interface CodeInterpreterOutputImage {
/**
* The index of the output in the outputs array.
*/
index: number;
/**
* Always `image`.
*/
type: 'image';
image?: CodeInterpreterOutputImage.Image;
}
export declare namespace CodeInterpreterOutputImage {
interface Image {
/**
* The [file](https://platform.openai.com/docs/api-reference/files) ID of the
* image.
*/
file_id?: string;
}
}
/**
* Details of the Code Interpreter tool call the run step was involved in.
*/
export interface CodeInterpreterToolCall {
/**
* The ID of the tool call.
*/
id: string;
/**
* The Code Interpreter tool call definition.
*/
code_interpreter: CodeInterpreterToolCall.CodeInterpreter;
/**
* The type of tool call. This is always going to be `code_interpreter` for this
* type of tool call.
*/
type: 'code_interpreter';
}
export declare namespace CodeInterpreterToolCall {
/**
* The Code Interpreter tool call definition.
*/
interface CodeInterpreter {
/**
* The input to the Code Interpreter tool call.
*/
input: string;
/**
* The outputs from the Code Interpreter tool call. Code Interpreter can output one
* or more items, including text (`logs`) or images (`image`). Each of these are
* represented by a different object type.
*/
outputs: Array<CodeInterpreter.Logs | CodeInterpreter.Image>;
}
namespace CodeInterpreter {
/**
* Text output from the Code Interpreter tool call as part of a run step.
*/
interface Logs {
/**
* The text output from the Code Interpreter tool call.
*/
logs: string;
/**
* Always `logs`.
*/
type: 'logs';
}
interface Image {
image: Image.Image;
/**
* Always `image`.
*/
type: 'image';
}
namespace Image {
interface Image {
/**
* The [file](https://platform.openai.com/docs/api-reference/files) ID of the
* image.
*/
file_id: string;
}
}
}
}
/**
* Details of the Code Interpreter tool call the run step was involved in.
*/
export interface CodeInterpreterToolCallDelta {
/**
* The index of the tool call in the tool calls array.
*/
index: number;
/**
* The type of tool call. This is always going to be `code_interpreter` for this
* type of tool call.
*/
type: 'code_interpreter';
/**
* The ID of the tool call.
*/
id?: string;
/**
* The Code Interpreter tool call definition.
*/
code_interpreter?: CodeInterpreterToolCallDelta.CodeInterpreter;
}
export declare namespace CodeInterpreterToolCallDelta {
/**
* The Code Interpreter tool call definition.
*/
interface CodeInterpreter {
/**
* The input to the Code Interpreter tool call.
*/
input?: string;
/**
* The outputs from the Code Interpreter tool call. Code Interpreter can output one
* or more items, including text (`logs`) or images (`image`). Each of these are
* represented by a different object type.
*/
outputs?: Array<StepsAPI.CodeInterpreterLogs | StepsAPI.CodeInterpreterOutputImage>;
}
}
export interface FileSearchToolCall {
/**
* The ID of the tool call object.
*/
id: string;
/**
* For now, this is always going to be an empty object.
*/
file_search: FileSearchToolCall.FileSearch;
/**
* The type of tool call. This is always going to be `file_search` for this type of
* tool call.
*/
type: 'file_search';
}
export declare namespace FileSearchToolCall {
/**
* For now, this is always going to be an empty object.
*/
interface FileSearch {
/**
* The ranking options for the file search.
*/
ranking_options?: FileSearch.RankingOptions;
/**
* The results of the file search.
*/
results?: Array<FileSearch.Result>;
}
namespace FileSearch {
/**
* The ranking options for the file search.
*/
interface RankingOptions {
/**
* The ranker to use for the file search. If not specified will use the `auto`
* ranker.
*/
ranker: 'auto' | 'default_2024_08_21';
/**
* The score threshold for the file search. All values must be a floating point
* number between 0 and 1.
*/
score_threshold: number;
}
/**
* A result instance of the file search.
*/
interface Result {
/**
* The ID of the file that result was found in.
*/
file_id: string;
/**
* The name of the file that result was found in.
*/
file_name: string;
/**
* The score of the result. All values must be a floating point number between 0
* and 1.
*/
score: number;
/**
* The content of the result that was found. The content is only included if
* requested via the include query parameter.
*/
content?: Array<Result.Content>;
}
namespace Result {
interface Content {
/**
* The text content of the file.
*/
text?: string;
/**
* The type of the content.
*/
type?: 'text';
}
}
}
}
export interface FileSearchToolCallDelta {
/**
* For now, this is always going to be an empty object.
*/
file_search: unknown;
/**
* The index of the tool call in the tool calls array.
*/
index: number;
/**
* The type of tool call. This is always going to be `file_search` for this type of
* tool call.
*/
type: 'file_search';
/**
* The ID of the tool call object.
*/
id?: string;
}
export interface FunctionToolCall {
/**
* The ID of the tool call object.
*/
id: string;
/**
* The definition of the function that was called.
*/
function: FunctionToolCall.Function;
/**
* The type of tool call. This is always going to be `function` for this type of
* tool call.
*/
type: 'function';
}
export declare namespace FunctionToolCall {
/**
* The definition of the function that was called.
*/
interface Function {
/**
* The arguments passed to the function.
*/
arguments: string;
/**
* The name of the function.
*/
name: string;
/**
* The output of the function. This will be `null` if the outputs have not been
* [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
* yet.
*/
output: string | null;
}
}
export interface FunctionToolCallDelta {
/**
* The index of the tool call in the tool calls array.
*/
index: number;
/**
* The type of tool call. This is always going to be `function` for this type of
* tool call.
*/
type: 'function';
/**
* The ID of the tool call object.
*/
id?: string;
/**
* The definition of the function that was called.
*/
function?: FunctionToolCallDelta.Function;
}
export declare namespace FunctionToolCallDelta {
/**
* The definition of the function that was called.
*/
interface Function {
/**
* The arguments passed to the function.
*/
arguments?: string;
/**
* The name of the function.
*/
name?: string;
/**
* The output of the function. This will be `null` if the outputs have not been
* [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
* yet.
*/
output?: string | null;
}
}
/**
* Details of the message creation by the run step.
*/
export interface MessageCreationStepDetails {
message_creation: MessageCreationStepDetails.MessageCreation;
/**
* Always `message_creation`.
*/
type: 'message_creation';
}
export declare namespace MessageCreationStepDetails {
interface MessageCreation {
/**
* The ID of the message that was created by this run step.
*/
message_id: string;
}
}
/**
* Represents a step in execution of a run.
*/
export interface RunStep {
/**
* The identifier of the run step, which can be referenced in API endpoints.
*/
id: string;
/**
* The ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants)
* associated with the run step.
*/
assistant_id: string;
/**
* The Unix timestamp (in seconds) for when the run step was cancelled.
*/
cancelled_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run step completed.
*/
completed_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run step was created.
*/
created_at: number;
/**
* The Unix timestamp (in seconds) for when the run step expired. A step is
* considered expired if the parent run is expired.
*/
expired_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run step failed.
*/
failed_at: number | null;
/**
* The last error associated with this run step. Will be `null` if there are no
* errors.
*/
last_error: RunStep.LastError | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata: Shared.Metadata | null;
/**
* The object type, which is always `thread.run.step`.
*/
object: 'thread.run.step';
/**
* The ID of the [run](https://platform.openai.com/docs/api-reference/runs) that
* this run step is a part of.
*/
run_id: string;
/**
* The status of the run step, which can be either `in_progress`, `cancelled`,
* `failed`, `completed`, or `expired`.
*/
status: 'in_progress' | 'cancelled' | 'failed' | 'completed' | 'expired';
/**
* The details of the run step.
*/
step_details: MessageCreationStepDetails | ToolCallsStepDetails;
/**
* The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
* that was run.
*/
thread_id: string;
/**
* The type of run step, which can be either `message_creation` or `tool_calls`.
*/
type: 'message_creation' | 'tool_calls';
/**
* Usage statistics related to the run step. This value will be `null` while the
* run step's status is `in_progress`.
*/
usage: RunStep.Usage | null;
}
export declare namespace RunStep {
/**
* The last error associated with this run step. Will be `null` if there are no
* errors.
*/
interface LastError {
/**
* One of `server_error` or `rate_limit_exceeded`.
*/
code: 'server_error' | 'rate_limit_exceeded';
/**
* A human-readable description of the error.
*/
message: string;
}
/**
* Usage statistics related to the run step. This value will be `null` while the
* run step's status is `in_progress`.
*/
interface Usage {
/**
* Number of completion tokens used over the course of the run step.
*/
completion_tokens: number;
/**
* Number of prompt tokens used over the course of the run step.
*/
prompt_tokens: number;
/**
* Total number of tokens used (prompt + completion).
*/
total_tokens: number;
}
}
/**
* The delta containing the fields that have changed on the run step.
*/
export interface RunStepDelta {
/**
* The details of the run step.
*/
step_details?: RunStepDeltaMessageDelta | ToolCallDeltaObject;
}
/**
* Represents a run step delta i.e. any changed fields on a run step during
* streaming.
*/
export interface RunStepDeltaEvent {
/**
* The identifier of the run step, which can be referenced in API endpoints.
*/
id: string;
/**
* The delta containing the fields that have changed on the run step.
*/
delta: RunStepDelta;
/**
* The object type, which is always `thread.run.step.delta`.
*/
object: 'thread.run.step.delta';
}
/**
* Details of the message creation by the run step.
*/
export interface RunStepDeltaMessageDelta {
/**
* Always `message_creation`.
*/
type: 'message_creation';
message_creation?: RunStepDeltaMessageDelta.MessageCreation;
}
export declare namespace RunStepDeltaMessageDelta {
interface MessageCreation {
/**
* The ID of the message that was created by this run step.
*/
message_id?: string;
}
}
export type RunStepInclude = 'step_details.tool_calls[*].file_search.results[*].content';
/**
* Details of the Code Interpreter tool call the run step was involved in.
*/
export type ToolCall = CodeInterpreterToolCall | FileSearchToolCall | FunctionToolCall;
/**
* Details of the Code Interpreter tool call the run step was involved in.
*/
export type ToolCallDelta = CodeInterpreterToolCallDelta | FileSearchToolCallDelta | FunctionToolCallDelta;
/**
* Details of the tool call.
*/
export interface ToolCallDeltaObject {
/**
* Always `tool_calls`.
*/
type: 'tool_calls';
/**
* An array of tool calls the run step was involved in. These can be associated
* with one of three types of tools: `code_interpreter`, `file_search`, or
* `function`.
*/
tool_calls?: Array<ToolCallDelta>;
}
/**
* Details of the tool call.
*/
export interface ToolCallsStepDetails {
/**
* An array of tool calls the run step was involved in. These can be associated
* with one of three types of tools: `code_interpreter`, `file_search`, or
* `function`.
*/
tool_calls: Array<ToolCall>;
/**
* Always `tool_calls`.
*/
type: 'tool_calls';
}
export interface StepRetrieveParams {
/**
* Path param: The ID of the thread to which the run and run step belongs.
*/
thread_id: string;
/**
* Path param: The ID of the run to which the run step belongs.
*/
run_id: string;
/**
* Query param: A list of additional fields to include in the response. Currently
* the only supported value is
* `step_details.tool_calls[*].file_search.results[*].content` to fetch the file
* search result content.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
include?: Array<RunStepInclude>;
}
export interface StepListParams extends CursorPageParams {
/**
* Path param: The ID of the thread the run and run steps belong to.
*/
thread_id: string;
/**
* Query param: A cursor for use in pagination. `before` is an object ID that
* defines your place in the list. For instance, if you make a list request and
* receive 100 objects, starting with obj_foo, your subsequent call can include
* before=obj_foo in order to fetch the previous page of the list.
*/
before?: string;
/**
* Query param: A list of additional fields to include in the response. Currently
* the only supported value is
* `step_details.tool_calls[*].file_search.results[*].content` to fetch the file
* search result content.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
include?: Array<RunStepInclude>;
/**
* Query param: Sort order by the `created_at` timestamp of the objects. `asc` for
* ascending order and `desc` for descending order.
*/
order?: 'asc' | 'desc';
}
export declare namespace Steps {
export { type CodeInterpreterLogs as CodeInterpreterLogs, type CodeInterpreterOutputImage as CodeInterpreterOutputImage, type CodeInterpreterToolCall as CodeInterpreterToolCall, type CodeInterpreterToolCallDelta as CodeInterpreterToolCallDelta, type FileSearchToolCall as FileSearchToolCall, type FileSearchToolCallDelta as FileSearchToolCallDelta, type FunctionToolCall as FunctionToolCall, type FunctionToolCallDelta as FunctionToolCallDelta, type MessageCreationStepDetails as MessageCreationStepDetails, type RunStep as RunStep, type RunStepDelta as RunStepDelta, type RunStepDeltaEvent as RunStepDeltaEvent, type RunStepDeltaMessageDelta as RunStepDeltaMessageDelta, type RunStepInclude as RunStepInclude, type ToolCall as ToolCall, type ToolCallDelta as ToolCallDelta, type ToolCallDeltaObject as ToolCallDeltaObject, type ToolCallsStepDetails as ToolCallsStepDetails, type RunStepsPage as RunStepsPage, type StepRetrieveParams as StepRetrieveParams, type StepListParams as StepListParams, };
}
//# sourceMappingURL=steps.d.mts.map
File diff suppressed because one or more lines are too long
+617
View File
@@ -0,0 +1,617 @@
import { APIResource } from "../../../../core/resource.js";
import * as StepsAPI from "./steps.js";
import * as Shared from "../../../shared.js";
import { APIPromise } from "../../../../core/api-promise.js";
import { CursorPage, type CursorPageParams, PagePromise } from "../../../../core/pagination.js";
import { RequestOptions } from "../../../../internal/request-options.js";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export declare class Steps extends APIResource {
/**
* Retrieves a run step.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(stepID: string, params: StepRetrieveParams, options?: RequestOptions): APIPromise<RunStep>;
/**
* Returns a list of run steps belonging to a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(runID: string, params: StepListParams, options?: RequestOptions): PagePromise<RunStepsPage, RunStep>;
}
export type RunStepsPage = CursorPage<RunStep>;
/**
* Text output from the Code Interpreter tool call as part of a run step.
*/
export interface CodeInterpreterLogs {
/**
* The index of the output in the outputs array.
*/
index: number;
/**
* Always `logs`.
*/
type: 'logs';
/**
* The text output from the Code Interpreter tool call.
*/
logs?: string;
}
export interface CodeInterpreterOutputImage {
/**
* The index of the output in the outputs array.
*/
index: number;
/**
* Always `image`.
*/
type: 'image';
image?: CodeInterpreterOutputImage.Image;
}
export declare namespace CodeInterpreterOutputImage {
interface Image {
/**
* The [file](https://platform.openai.com/docs/api-reference/files) ID of the
* image.
*/
file_id?: string;
}
}
/**
* Details of the Code Interpreter tool call the run step was involved in.
*/
export interface CodeInterpreterToolCall {
/**
* The ID of the tool call.
*/
id: string;
/**
* The Code Interpreter tool call definition.
*/
code_interpreter: CodeInterpreterToolCall.CodeInterpreter;
/**
* The type of tool call. This is always going to be `code_interpreter` for this
* type of tool call.
*/
type: 'code_interpreter';
}
export declare namespace CodeInterpreterToolCall {
/**
* The Code Interpreter tool call definition.
*/
interface CodeInterpreter {
/**
* The input to the Code Interpreter tool call.
*/
input: string;
/**
* The outputs from the Code Interpreter tool call. Code Interpreter can output one
* or more items, including text (`logs`) or images (`image`). Each of these are
* represented by a different object type.
*/
outputs: Array<CodeInterpreter.Logs | CodeInterpreter.Image>;
}
namespace CodeInterpreter {
/**
* Text output from the Code Interpreter tool call as part of a run step.
*/
interface Logs {
/**
* The text output from the Code Interpreter tool call.
*/
logs: string;
/**
* Always `logs`.
*/
type: 'logs';
}
interface Image {
image: Image.Image;
/**
* Always `image`.
*/
type: 'image';
}
namespace Image {
interface Image {
/**
* The [file](https://platform.openai.com/docs/api-reference/files) ID of the
* image.
*/
file_id: string;
}
}
}
}
/**
* Details of the Code Interpreter tool call the run step was involved in.
*/
export interface CodeInterpreterToolCallDelta {
/**
* The index of the tool call in the tool calls array.
*/
index: number;
/**
* The type of tool call. This is always going to be `code_interpreter` for this
* type of tool call.
*/
type: 'code_interpreter';
/**
* The ID of the tool call.
*/
id?: string;
/**
* The Code Interpreter tool call definition.
*/
code_interpreter?: CodeInterpreterToolCallDelta.CodeInterpreter;
}
export declare namespace CodeInterpreterToolCallDelta {
/**
* The Code Interpreter tool call definition.
*/
interface CodeInterpreter {
/**
* The input to the Code Interpreter tool call.
*/
input?: string;
/**
* The outputs from the Code Interpreter tool call. Code Interpreter can output one
* or more items, including text (`logs`) or images (`image`). Each of these are
* represented by a different object type.
*/
outputs?: Array<StepsAPI.CodeInterpreterLogs | StepsAPI.CodeInterpreterOutputImage>;
}
}
export interface FileSearchToolCall {
/**
* The ID of the tool call object.
*/
id: string;
/**
* For now, this is always going to be an empty object.
*/
file_search: FileSearchToolCall.FileSearch;
/**
* The type of tool call. This is always going to be `file_search` for this type of
* tool call.
*/
type: 'file_search';
}
export declare namespace FileSearchToolCall {
/**
* For now, this is always going to be an empty object.
*/
interface FileSearch {
/**
* The ranking options for the file search.
*/
ranking_options?: FileSearch.RankingOptions;
/**
* The results of the file search.
*/
results?: Array<FileSearch.Result>;
}
namespace FileSearch {
/**
* The ranking options for the file search.
*/
interface RankingOptions {
/**
* The ranker to use for the file search. If not specified will use the `auto`
* ranker.
*/
ranker: 'auto' | 'default_2024_08_21';
/**
* The score threshold for the file search. All values must be a floating point
* number between 0 and 1.
*/
score_threshold: number;
}
/**
* A result instance of the file search.
*/
interface Result {
/**
* The ID of the file that result was found in.
*/
file_id: string;
/**
* The name of the file that result was found in.
*/
file_name: string;
/**
* The score of the result. All values must be a floating point number between 0
* and 1.
*/
score: number;
/**
* The content of the result that was found. The content is only included if
* requested via the include query parameter.
*/
content?: Array<Result.Content>;
}
namespace Result {
interface Content {
/**
* The text content of the file.
*/
text?: string;
/**
* The type of the content.
*/
type?: 'text';
}
}
}
}
export interface FileSearchToolCallDelta {
/**
* For now, this is always going to be an empty object.
*/
file_search: unknown;
/**
* The index of the tool call in the tool calls array.
*/
index: number;
/**
* The type of tool call. This is always going to be `file_search` for this type of
* tool call.
*/
type: 'file_search';
/**
* The ID of the tool call object.
*/
id?: string;
}
export interface FunctionToolCall {
/**
* The ID of the tool call object.
*/
id: string;
/**
* The definition of the function that was called.
*/
function: FunctionToolCall.Function;
/**
* The type of tool call. This is always going to be `function` for this type of
* tool call.
*/
type: 'function';
}
export declare namespace FunctionToolCall {
/**
* The definition of the function that was called.
*/
interface Function {
/**
* The arguments passed to the function.
*/
arguments: string;
/**
* The name of the function.
*/
name: string;
/**
* The output of the function. This will be `null` if the outputs have not been
* [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
* yet.
*/
output: string | null;
}
}
export interface FunctionToolCallDelta {
/**
* The index of the tool call in the tool calls array.
*/
index: number;
/**
* The type of tool call. This is always going to be `function` for this type of
* tool call.
*/
type: 'function';
/**
* The ID of the tool call object.
*/
id?: string;
/**
* The definition of the function that was called.
*/
function?: FunctionToolCallDelta.Function;
}
export declare namespace FunctionToolCallDelta {
/**
* The definition of the function that was called.
*/
interface Function {
/**
* The arguments passed to the function.
*/
arguments?: string;
/**
* The name of the function.
*/
name?: string;
/**
* The output of the function. This will be `null` if the outputs have not been
* [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
* yet.
*/
output?: string | null;
}
}
/**
* Details of the message creation by the run step.
*/
export interface MessageCreationStepDetails {
message_creation: MessageCreationStepDetails.MessageCreation;
/**
* Always `message_creation`.
*/
type: 'message_creation';
}
export declare namespace MessageCreationStepDetails {
interface MessageCreation {
/**
* The ID of the message that was created by this run step.
*/
message_id: string;
}
}
/**
* Represents a step in execution of a run.
*/
export interface RunStep {
/**
* The identifier of the run step, which can be referenced in API endpoints.
*/
id: string;
/**
* The ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants)
* associated with the run step.
*/
assistant_id: string;
/**
* The Unix timestamp (in seconds) for when the run step was cancelled.
*/
cancelled_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run step completed.
*/
completed_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run step was created.
*/
created_at: number;
/**
* The Unix timestamp (in seconds) for when the run step expired. A step is
* considered expired if the parent run is expired.
*/
expired_at: number | null;
/**
* The Unix timestamp (in seconds) for when the run step failed.
*/
failed_at: number | null;
/**
* The last error associated with this run step. Will be `null` if there are no
* errors.
*/
last_error: RunStep.LastError | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata: Shared.Metadata | null;
/**
* The object type, which is always `thread.run.step`.
*/
object: 'thread.run.step';
/**
* The ID of the [run](https://platform.openai.com/docs/api-reference/runs) that
* this run step is a part of.
*/
run_id: string;
/**
* The status of the run step, which can be either `in_progress`, `cancelled`,
* `failed`, `completed`, or `expired`.
*/
status: 'in_progress' | 'cancelled' | 'failed' | 'completed' | 'expired';
/**
* The details of the run step.
*/
step_details: MessageCreationStepDetails | ToolCallsStepDetails;
/**
* The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
* that was run.
*/
thread_id: string;
/**
* The type of run step, which can be either `message_creation` or `tool_calls`.
*/
type: 'message_creation' | 'tool_calls';
/**
* Usage statistics related to the run step. This value will be `null` while the
* run step's status is `in_progress`.
*/
usage: RunStep.Usage | null;
}
export declare namespace RunStep {
/**
* The last error associated with this run step. Will be `null` if there are no
* errors.
*/
interface LastError {
/**
* One of `server_error` or `rate_limit_exceeded`.
*/
code: 'server_error' | 'rate_limit_exceeded';
/**
* A human-readable description of the error.
*/
message: string;
}
/**
* Usage statistics related to the run step. This value will be `null` while the
* run step's status is `in_progress`.
*/
interface Usage {
/**
* Number of completion tokens used over the course of the run step.
*/
completion_tokens: number;
/**
* Number of prompt tokens used over the course of the run step.
*/
prompt_tokens: number;
/**
* Total number of tokens used (prompt + completion).
*/
total_tokens: number;
}
}
/**
* The delta containing the fields that have changed on the run step.
*/
export interface RunStepDelta {
/**
* The details of the run step.
*/
step_details?: RunStepDeltaMessageDelta | ToolCallDeltaObject;
}
/**
* Represents a run step delta i.e. any changed fields on a run step during
* streaming.
*/
export interface RunStepDeltaEvent {
/**
* The identifier of the run step, which can be referenced in API endpoints.
*/
id: string;
/**
* The delta containing the fields that have changed on the run step.
*/
delta: RunStepDelta;
/**
* The object type, which is always `thread.run.step.delta`.
*/
object: 'thread.run.step.delta';
}
/**
* Details of the message creation by the run step.
*/
export interface RunStepDeltaMessageDelta {
/**
* Always `message_creation`.
*/
type: 'message_creation';
message_creation?: RunStepDeltaMessageDelta.MessageCreation;
}
export declare namespace RunStepDeltaMessageDelta {
interface MessageCreation {
/**
* The ID of the message that was created by this run step.
*/
message_id?: string;
}
}
export type RunStepInclude = 'step_details.tool_calls[*].file_search.results[*].content';
/**
* Details of the Code Interpreter tool call the run step was involved in.
*/
export type ToolCall = CodeInterpreterToolCall | FileSearchToolCall | FunctionToolCall;
/**
* Details of the Code Interpreter tool call the run step was involved in.
*/
export type ToolCallDelta = CodeInterpreterToolCallDelta | FileSearchToolCallDelta | FunctionToolCallDelta;
/**
* Details of the tool call.
*/
export interface ToolCallDeltaObject {
/**
* Always `tool_calls`.
*/
type: 'tool_calls';
/**
* An array of tool calls the run step was involved in. These can be associated
* with one of three types of tools: `code_interpreter`, `file_search`, or
* `function`.
*/
tool_calls?: Array<ToolCallDelta>;
}
/**
* Details of the tool call.
*/
export interface ToolCallsStepDetails {
/**
* An array of tool calls the run step was involved in. These can be associated
* with one of three types of tools: `code_interpreter`, `file_search`, or
* `function`.
*/
tool_calls: Array<ToolCall>;
/**
* Always `tool_calls`.
*/
type: 'tool_calls';
}
export interface StepRetrieveParams {
/**
* Path param: The ID of the thread to which the run and run step belongs.
*/
thread_id: string;
/**
* Path param: The ID of the run to which the run step belongs.
*/
run_id: string;
/**
* Query param: A list of additional fields to include in the response. Currently
* the only supported value is
* `step_details.tool_calls[*].file_search.results[*].content` to fetch the file
* search result content.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
include?: Array<RunStepInclude>;
}
export interface StepListParams extends CursorPageParams {
/**
* Path param: The ID of the thread the run and run steps belong to.
*/
thread_id: string;
/**
* Query param: A cursor for use in pagination. `before` is an object ID that
* defines your place in the list. For instance, if you make a list request and
* receive 100 objects, starting with obj_foo, your subsequent call can include
* before=obj_foo in order to fetch the previous page of the list.
*/
before?: string;
/**
* Query param: A list of additional fields to include in the response. Currently
* the only supported value is
* `step_details.tool_calls[*].file_search.results[*].content` to fetch the file
* search result content.
*
* See the
* [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
* for more information.
*/
include?: Array<RunStepInclude>;
/**
* Query param: Sort order by the `created_at` timestamp of the objects. `asc` for
* ascending order and `desc` for descending order.
*/
order?: 'asc' | 'desc';
}
export declare namespace Steps {
export { type CodeInterpreterLogs as CodeInterpreterLogs, type CodeInterpreterOutputImage as CodeInterpreterOutputImage, type CodeInterpreterToolCall as CodeInterpreterToolCall, type CodeInterpreterToolCallDelta as CodeInterpreterToolCallDelta, type FileSearchToolCall as FileSearchToolCall, type FileSearchToolCallDelta as FileSearchToolCallDelta, type FunctionToolCall as FunctionToolCall, type FunctionToolCallDelta as FunctionToolCallDelta, type MessageCreationStepDetails as MessageCreationStepDetails, type RunStep as RunStep, type RunStepDelta as RunStepDelta, type RunStepDeltaEvent as RunStepDeltaEvent, type RunStepDeltaMessageDelta as RunStepDeltaMessageDelta, type RunStepInclude as RunStepInclude, type ToolCall as ToolCall, type ToolCallDelta as ToolCallDelta, type ToolCallDeltaObject as ToolCallDeltaObject, type ToolCallsStepDetails as ToolCallsStepDetails, type RunStepsPage as RunStepsPage, type StepRetrieveParams as StepRetrieveParams, type StepListParams as StepListParams, };
}
//# sourceMappingURL=steps.d.ts.map
File diff suppressed because one or more lines are too long
+45
View File
@@ -0,0 +1,45 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Steps = void 0;
const resource_1 = require("../../../../core/resource.js");
const pagination_1 = require("../../../../core/pagination.js");
const headers_1 = require("../../../../internal/headers.js");
const path_1 = require("../../../../internal/utils/path.js");
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
class Steps extends resource_1.APIResource {
/**
* Retrieves a run step.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(stepID, params, options) {
const { thread_id, run_id, ...query } = params;
return this._client.get((0, path_1.path) `/threads/${thread_id}/runs/${run_id}/steps/${stepID}`, {
query,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Returns a list of run steps belonging to a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(runID, params, options) {
const { thread_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/threads/${thread_id}/runs/${runID}/steps`, (pagination_1.CursorPage), {
query,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
exports.Steps = Steps;
//# sourceMappingURL=steps.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"steps.js","sourceRoot":"","sources":["../../../../src/resources/beta/threads/runs/steps.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,2DAAwD;AAIxD,+DAA6F;AAC7F,6DAA4D;AAE5D,6DAAuD;AAEvD;;;;GAIG;AACH,MAAa,KAAM,SAAQ,sBAAW;IACpC;;;;OAIG;IACH,QAAQ,CAAC,MAAc,EAAE,MAA0B,EAAE,OAAwB;QAC3E,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,YAAY,SAAS,SAAS,MAAM,UAAU,MAAM,EAAE,EAAE;YAClF,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,KAAa,EAAE,MAAsB,EAAE,OAAwB;QAClE,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QACvC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAA,WAAI,EAAA,YAAY,SAAS,SAAS,KAAK,QAAQ,EAAE,CAAA,uBAAmB,CAAA,EAAE;YACnG,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AA9BD,sBA8BC"}
+41
View File
@@ -0,0 +1,41 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import { CursorPage } from "../../../../core/pagination.mjs";
import { buildHeaders } from "../../../../internal/headers.mjs";
import { path } from "../../../../internal/utils/path.mjs";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export class Steps extends APIResource {
/**
* Retrieves a run step.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(stepID, params, options) {
const { thread_id, run_id, ...query } = params;
return this._client.get(path `/threads/${thread_id}/runs/${run_id}/steps/${stepID}`, {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Returns a list of run steps belonging to a run.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(runID, params, options) {
const { thread_id, ...query } = params;
return this._client.getAPIList(path `/threads/${thread_id}/runs/${runID}/steps`, (CursorPage), {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
//# sourceMappingURL=steps.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"steps.mjs","sourceRoot":"","sources":["../../../../src/resources/beta/threads/runs/steps.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,sCAAkC;AAIxD,OAAO,EAAE,UAAU,EAAsC,wCAAoC;AAC7F,OAAO,EAAE,YAAY,EAAE,yCAAqC;AAE5D,OAAO,EAAE,IAAI,EAAE,4CAAwC;AAEvD;;;;GAIG;AACH,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC;;;;OAIG;IACH,QAAQ,CAAC,MAAc,EAAE,MAA0B,EAAE,OAAwB;QAC3E,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,YAAY,SAAS,SAAS,MAAM,UAAU,MAAM,EAAE,EAAE;YAClF,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,KAAa,EAAE,MAAsB,EAAE,OAAwB;QAClE,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QACvC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAA,YAAY,SAAS,SAAS,KAAK,QAAQ,EAAE,CAAA,UAAmB,CAAA,EAAE;YACnG,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
+1048
View File
@@ -0,0 +1,1048 @@
import { APIResource } from "../../../core/resource.mjs";
import * as ThreadsAPI from "./threads.mjs";
import * as Shared from "../../shared.mjs";
import * as AssistantsAPI from "../assistants.mjs";
import * as MessagesAPI from "./messages.mjs";
import { Annotation, AnnotationDelta, FileCitationAnnotation, FileCitationDeltaAnnotation, FilePathAnnotation, FilePathDeltaAnnotation, ImageFile, ImageFileContentBlock, ImageFileDelta, ImageFileDeltaBlock, ImageURL, ImageURLContentBlock, ImageURLDelta, ImageURLDeltaBlock, Message as MessagesAPIMessage, MessageContent, MessageContentDelta, MessageContentPartParam, MessageCreateParams, MessageDeleteParams, MessageDeleted, MessageDelta, MessageDeltaEvent, MessageListParams, MessageRetrieveParams, MessageUpdateParams, Messages, MessagesPage, RefusalContentBlock, RefusalDeltaBlock, Text, TextContentBlock, TextContentBlockParam, TextDelta, TextDeltaBlock } from "./messages.mjs";
import * as RunsAPI from "./runs/runs.mjs";
import { RequiredActionFunctionToolCall, Run, RunCreateAndPollParams, RunCreateAndStreamParams, RunCancelParams, RunCreateParams, RunCreateParamsNonStreaming, RunCreateParamsStreaming, RunListParams, RunRetrieveParams, RunStatus, RunStreamParams, RunSubmitToolOutputsAndPollParams, RunSubmitToolOutputsParams, RunSubmitToolOutputsParamsNonStreaming, RunSubmitToolOutputsParamsStreaming, RunSubmitToolOutputsStreamParams, RunUpdateParams, Runs, RunsPage } from "./runs/runs.mjs";
import { APIPromise } from "../../../core/api-promise.mjs";
import { Stream } from "../../../core/streaming.mjs";
import { RequestOptions } from "../../../internal/request-options.mjs";
import { AssistantStream, ThreadCreateAndRunParamsBaseStream } from "../../../lib/AssistantStream.mjs";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export declare class Threads extends APIResource {
runs: RunsAPI.Runs;
messages: MessagesAPI.Messages;
/**
* Create a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(body?: ThreadCreateParams | null | undefined, options?: RequestOptions): APIPromise<Thread>;
/**
* Retrieves a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(threadID: string, options?: RequestOptions): APIPromise<Thread>;
/**
* Modifies a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(threadID: string, body: ThreadUpdateParams, options?: RequestOptions): APIPromise<Thread>;
/**
* Delete a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
delete(threadID: string, options?: RequestOptions): APIPromise<ThreadDeleted>;
/**
* Create a thread and run it in one request.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
createAndRun(body: ThreadCreateAndRunParamsNonStreaming, options?: RequestOptions): APIPromise<RunsAPI.Run>;
createAndRun(body: ThreadCreateAndRunParamsStreaming, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>>;
createAndRun(body: ThreadCreateAndRunParamsBase, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent> | RunsAPI.Run>;
/**
* A helper to create a thread, start a run and then poll for a terminal state.
* More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
createAndRunPoll(body: ThreadCreateAndRunParamsNonStreaming, options?: RequestOptions & {
pollIntervalMs?: number;
}): Promise<Threads.Run>;
/**
* Create a thread and stream the run back
*/
createAndRunStream(body: ThreadCreateAndRunParamsBaseStream, options?: RequestOptions): AssistantStream;
}
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
export type AssistantResponseFormatOption = 'auto' | Shared.ResponseFormatText | Shared.ResponseFormatJSONObject | Shared.ResponseFormatJSONSchema;
/**
* Specifies a tool the model should use. Use to force the model to call a specific
* tool.
*/
export interface AssistantToolChoice {
/**
* The type of the tool. If type is `function`, the function name must be set
*/
type: 'function' | 'code_interpreter' | 'file_search';
function?: AssistantToolChoiceFunction;
}
export interface AssistantToolChoiceFunction {
/**
* The name of the function to call.
*/
name: string;
}
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
export type AssistantToolChoiceOption = 'none' | 'auto' | 'required' | AssistantToolChoice;
/**
* Represents a thread that contains
* [messages](https://platform.openai.com/docs/api-reference/messages).
*/
export interface Thread {
/**
* The identifier, which can be referenced in API endpoints.
*/
id: string;
/**
* The Unix timestamp (in seconds) for when the thread was created.
*/
created_at: number;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata: Shared.Metadata | null;
/**
* The object type, which is always `thread`.
*/
object: 'thread';
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
tool_resources: Thread.ToolResources | null;
}
export declare namespace Thread {
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this thread. There can be a maximum of 1 vector store attached to
* the thread.
*/
vector_store_ids?: Array<string>;
}
}
}
export interface ThreadDeleted {
id: string;
deleted: boolean;
object: 'thread.deleted';
}
export interface ThreadCreateParams {
/**
* A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
* start the thread with.
*/
messages?: Array<ThreadCreateParams.Message>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
tool_resources?: ThreadCreateParams.ToolResources | null;
}
export declare namespace ThreadCreateParams {
interface Message {
/**
* The text contents of the message.
*/
content: string | Array<MessagesAPI.MessageContentPartParam>;
/**
* The role of the entity that is creating the message. Allowed values include:
*
* - `user`: Indicates the message is sent by an actual user and should be used in
* most cases to represent user-generated messages.
* - `assistant`: Indicates the message is generated by the assistant. Use this
* value to insert messages from the assistant into the conversation.
*/
role: 'user' | 'assistant';
/**
* A list of files attached to the message, and the tools they should be added to.
*/
attachments?: Array<Message.Attachment> | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace Message {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.FileSearch>;
}
namespace Attachment {
interface FileSearch {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
}
}
}
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this thread. There can be a maximum of 1 vector store attached to
* the thread.
*/
vector_store_ids?: Array<string>;
/**
* A helper to create a
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* with file_ids and attach it to this thread. There can be a maximum of 1 vector
* store attached to the thread.
*/
vector_stores?: Array<FileSearch.VectorStore>;
}
namespace FileSearch {
interface VectorStore {
/**
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
* strategy.
*/
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
* add to the vector store. For vector stores created before Nov 2025, there can be
* a maximum of 10,000 files in a vector store. For vector stores created starting
* in Nov 2025, the limit is 100,000,000 files.
*/
file_ids?: Array<string>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace VectorStore {
/**
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
* `800` and `chunk_overlap_tokens` of `400`.
*/
interface Auto {
/**
* Always `auto`.
*/
type: 'auto';
}
interface Static {
static: Static.Static;
/**
* Always `static`.
*/
type: 'static';
}
namespace Static {
interface Static {
/**
* The number of tokens that overlap between chunks. The default value is `400`.
*
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
*/
chunk_overlap_tokens: number;
/**
* The maximum number of tokens in each chunk. The default value is `800`. The
* minimum value is `100` and the maximum value is `4096`.
*/
max_chunk_size_tokens: number;
}
}
}
}
}
}
export interface ThreadUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
tool_resources?: ThreadUpdateParams.ToolResources | null;
}
export declare namespace ThreadUpdateParams {
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this thread. There can be a maximum of 1 vector store attached to
* the thread.
*/
vector_store_ids?: Array<string>;
}
}
}
export type ThreadCreateAndRunParams = ThreadCreateAndRunParamsNonStreaming | ThreadCreateAndRunParamsStreaming;
export interface ThreadCreateAndRunParamsBase {
/**
* The ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
* execute this run.
*/
assistant_id: string;
/**
* Override the default system message of the assistant. This is useful for
* modifying the behavior on a per-run basis.
*/
instructions?: string | null;
/**
* The maximum number of completion tokens that may be used over the course of the
* run. The run will make a best effort to use only the number of completion tokens
* specified, across multiple turns of the run. If the run exceeds the number of
* completion tokens specified, the run will end with status `incomplete`. See
* `incomplete_details` for more info.
*/
max_completion_tokens?: number | null;
/**
* The maximum number of prompt tokens that may be used over the course of the run.
* The run will make a best effort to use only the number of prompt tokens
* specified, across multiple turns of the run. If the run exceeds the number of
* prompt tokens specified, the run will end with status `incomplete`. See
* `incomplete_details` for more info.
*/
max_prompt_tokens?: number | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
* be used to execute this run. If a value is provided here, it will override the
* model associated with the assistant. If not, the model associated with the
* assistant will be used.
*/
model?: (string & {}) | Shared.ChatModel | null;
/**
* Whether to enable
* [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
* during tool use.
*/
parallel_tool_calls?: boolean;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: AssistantResponseFormatOption | null;
/**
* If `true`, returns a stream of events that happen during the Run as server-sent
* events, terminating when the Run enters a terminal state with a `data: [DONE]`
* message.
*/
stream?: boolean | null;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;
/**
* Options to create a new thread. If no thread is provided when running a request,
* an empty thread will be created.
*/
thread?: ThreadCreateAndRunParams.Thread;
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
tool_choice?: AssistantToolChoiceOption | null;
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
tool_resources?: ThreadCreateAndRunParams.ToolResources | null;
/**
* Override the tools the assistant can use for this run. This is useful for
* modifying the behavior on a per-run basis.
*/
tools?: Array<AssistantsAPI.AssistantTool> | null;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the
* model considers the results of the tokens with top_p probability mass. So 0.1
* means only the tokens comprising the top 10% probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the initial context window of the run.
*/
truncation_strategy?: ThreadCreateAndRunParams.TruncationStrategy | null;
}
export declare namespace ThreadCreateAndRunParams {
/**
* Options to create a new thread. If no thread is provided when running a request,
* an empty thread will be created.
*/
interface Thread {
/**
* A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
* start the thread with.
*/
messages?: Array<Thread.Message>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
tool_resources?: Thread.ToolResources | null;
}
namespace Thread {
interface Message {
/**
* The text contents of the message.
*/
content: string | Array<MessagesAPI.MessageContentPartParam>;
/**
* The role of the entity that is creating the message. Allowed values include:
*
* - `user`: Indicates the message is sent by an actual user and should be used in
* most cases to represent user-generated messages.
* - `assistant`: Indicates the message is generated by the assistant. Use this
* value to insert messages from the assistant into the conversation.
*/
role: 'user' | 'assistant';
/**
* A list of files attached to the message, and the tools they should be added to.
*/
attachments?: Array<Message.Attachment> | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace Message {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.FileSearch>;
}
namespace Attachment {
interface FileSearch {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
}
}
}
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this thread. There can be a maximum of 1 vector store attached to
* the thread.
*/
vector_store_ids?: Array<string>;
/**
* A helper to create a
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* with file_ids and attach it to this thread. There can be a maximum of 1 vector
* store attached to the thread.
*/
vector_stores?: Array<FileSearch.VectorStore>;
}
namespace FileSearch {
interface VectorStore {
/**
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
* strategy.
*/
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
* add to the vector store. For vector stores created before Nov 2025, there can be
* a maximum of 10,000 files in a vector store. For vector stores created starting
* in Nov 2025, the limit is 100,000,000 files.
*/
file_ids?: Array<string>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace VectorStore {
/**
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
* `800` and `chunk_overlap_tokens` of `400`.
*/
interface Auto {
/**
* Always `auto`.
*/
type: 'auto';
}
interface Static {
static: Static.Static;
/**
* Always `static`.
*/
type: 'static';
}
namespace Static {
interface Static {
/**
* The number of tokens that overlap between chunks. The default value is `400`.
*
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
*/
chunk_overlap_tokens: number;
/**
* The maximum number of tokens in each chunk. The default value is `800`. The
* minimum value is `100` and the maximum value is `4096`.
*/
max_chunk_size_tokens: number;
}
}
}
}
}
}
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The ID of the
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this assistant. There can be a maximum of 1 vector store attached to
* the assistant.
*/
vector_store_ids?: Array<string>;
}
}
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the initial context window of the run.
*/
interface TruncationStrategy {
/**
* The truncation strategy to use for the thread. The default is `auto`. If set to
* `last_messages`, the thread will be truncated to the n most recent messages in
* the thread. When set to `auto`, messages in the middle of the thread will be
* dropped to fit the context length of the model, `max_prompt_tokens`.
*/
type: 'auto' | 'last_messages';
/**
* The number of most recent messages from the thread when constructing the context
* for the run.
*/
last_messages?: number | null;
}
type ThreadCreateAndRunParamsNonStreaming = ThreadsAPI.ThreadCreateAndRunParamsNonStreaming;
type ThreadCreateAndRunParamsStreaming = ThreadsAPI.ThreadCreateAndRunParamsStreaming;
}
export interface ThreadCreateAndRunParamsNonStreaming extends ThreadCreateAndRunParamsBase {
/**
* If `true`, returns a stream of events that happen during the Run as server-sent
* events, terminating when the Run enters a terminal state with a `data: [DONE]`
* message.
*/
stream?: false | null;
}
export interface ThreadCreateAndRunParamsStreaming extends ThreadCreateAndRunParamsBase {
/**
* If `true`, returns a stream of events that happen during the Run as server-sent
* events, terminating when the Run enters a terminal state with a `data: [DONE]`
* message.
*/
stream: true;
}
export interface ThreadCreateAndRunPollParams {
/**
* The ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
* execute this run.
*/
assistant_id: string;
/**
* Override the default system message of the assistant. This is useful for
* modifying the behavior on a per-run basis.
*/
instructions?: string | null;
/**
* The maximum number of completion tokens that may be used over the course of the
* run. The run will make a best effort to use only the number of completion tokens
* specified, across multiple turns of the run. If the run exceeds the number of
* completion tokens specified, the run will end with status `incomplete`. See
* `incomplete_details` for more info.
*/
max_completion_tokens?: number | null;
/**
* The maximum number of prompt tokens that may be used over the course of the run.
* The run will make a best effort to use only the number of prompt tokens
* specified, across multiple turns of the run. If the run exceeds the number of
* prompt tokens specified, the run will end with status `incomplete`. See
* `incomplete_details` for more info.
*/
max_prompt_tokens?: number | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format. Keys
* can be a maximum of 64 characters long and values can be a maxium of 512
* characters long.
*/
metadata?: unknown | null;
/**
* The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
* be used to execute this run. If a value is provided here, it will override the
* model associated with the assistant. If not, the model associated with the
* assistant will be used.
*/
model?: (string & {}) | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-0125-preview' | 'gpt-4-turbo-preview' | 'gpt-4-1106-preview' | 'gpt-4-vision-preview' | 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-16k' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-16k-0613' | null;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: AssistantResponseFormatOption | null;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;
/**
* If no thread is provided, an empty thread will be created.
*/
thread?: ThreadCreateAndRunPollParams.Thread;
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
tool_choice?: AssistantToolChoiceOption | null;
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
tool_resources?: ThreadCreateAndRunPollParams.ToolResources | null;
/**
* Override the tools the assistant can use for this run. This is useful for
* modifying the behavior on a per-run basis.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool | AssistantsAPI.FunctionTool> | null;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the
* model considers the results of the tokens with top_p probability mass. So 0.1
* means only the tokens comprising the top 10% probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the intial context window of the run.
*/
truncation_strategy?: ThreadCreateAndRunPollParams.TruncationStrategy | null;
}
export declare namespace ThreadCreateAndRunPollParams {
/**
* If no thread is provided, an empty thread will be created.
*/
interface Thread {
/**
* A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
* start the thread with.
*/
messages?: Array<Thread.Message>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format. Keys
* can be a maximum of 64 characters long and values can be a maxium of 512
* characters long.
*/
metadata?: unknown | null;
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
tool_resources?: Thread.ToolResources | null;
}
namespace Thread {
interface Message {
/**
* The text contents of the message.
*/
content: string | Array<MessagesAPI.MessageContentPartParam>;
/**
* The role of the entity that is creating the message. Allowed values include:
*
* - `user`: Indicates the message is sent by an actual user and should be used in
* most cases to represent user-generated messages.
* - `assistant`: Indicates the message is generated by the assistant. Use this
* value to insert messages from the assistant into the conversation.
*/
role: 'user' | 'assistant';
/**
* A list of files attached to the message, and the tools they should be added to.
*/
attachments?: Array<Message.Attachment> | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format. Keys
* can be a maximum of 64 characters long and values can be a maxium of 512
* characters long.
*/
metadata?: unknown | null;
}
namespace Message {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
}
}
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this thread. There can be a maximum of 1 vector store attached to
* the thread.
*/
vector_store_ids?: Array<string>;
/**
* A helper to create a
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* with file_ids and attach it to this thread. There can be a maximum of 1 vector
* store attached to the thread.
*/
vector_stores?: Array<FileSearch.VectorStore>;
}
namespace FileSearch {
interface VectorStore {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
* add to the vector store. There can be a maximum of 10000 files in a vector
* store.
*/
file_ids?: Array<string>;
/**
* Set of 16 key-value pairs that can be attached to a vector store. This can be
* useful for storing additional information about the vector store in a structured
* format. Keys can be a maximum of 64 characters long and values can be a maxium
* of 512 characters long.
*/
metadata?: unknown;
}
}
}
}
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The ID of the
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this assistant. There can be a maximum of 1 vector store attached to
* the assistant.
*/
vector_store_ids?: Array<string>;
}
}
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the intial context window of the run.
*/
interface TruncationStrategy {
/**
* The truncation strategy to use for the thread. The default is `auto`. If set to
* `last_messages`, the thread will be truncated to the n most recent messages in
* the thread. When set to `auto`, messages in the middle of the thread will be
* dropped to fit the context length of the model, `max_prompt_tokens`.
*/
type: 'auto' | 'last_messages';
/**
* The number of most recent messages from the thread when constructing the context
* for the run.
*/
last_messages?: number | null;
}
}
export type ThreadCreateAndRunStreamParams = ThreadCreateAndRunParamsBaseStream;
export declare namespace Threads {
export { type AssistantResponseFormatOption as AssistantResponseFormatOption, type AssistantToolChoice as AssistantToolChoice, type AssistantToolChoiceFunction as AssistantToolChoiceFunction, type AssistantToolChoiceOption as AssistantToolChoiceOption, type Thread as Thread, type ThreadDeleted as ThreadDeleted, type ThreadCreateParams as ThreadCreateParams, type ThreadUpdateParams as ThreadUpdateParams, type ThreadCreateAndRunParams as ThreadCreateAndRunParams, type ThreadCreateAndRunParamsNonStreaming as ThreadCreateAndRunParamsNonStreaming, type ThreadCreateAndRunParamsStreaming as ThreadCreateAndRunParamsStreaming, type ThreadCreateAndRunPollParams, type ThreadCreateAndRunStreamParams, };
export { Runs as Runs, type RequiredActionFunctionToolCall as RequiredActionFunctionToolCall, type Run as Run, type RunStatus as RunStatus, type RunsPage as RunsPage, type RunCreateParams as RunCreateParams, type RunCreateParamsNonStreaming as RunCreateParamsNonStreaming, type RunCreateParamsStreaming as RunCreateParamsStreaming, type RunRetrieveParams as RunRetrieveParams, type RunUpdateParams as RunUpdateParams, type RunListParams as RunListParams, type RunCancelParams as RunCancelParams, type RunCreateAndPollParams, type RunCreateAndStreamParams, type RunStreamParams, type RunSubmitToolOutputsParams as RunSubmitToolOutputsParams, type RunSubmitToolOutputsParamsNonStreaming as RunSubmitToolOutputsParamsNonStreaming, type RunSubmitToolOutputsParamsStreaming as RunSubmitToolOutputsParamsStreaming, type RunSubmitToolOutputsAndPollParams, type RunSubmitToolOutputsStreamParams, };
export { Messages as Messages, type Annotation as Annotation, type AnnotationDelta as AnnotationDelta, type FileCitationAnnotation as FileCitationAnnotation, type FileCitationDeltaAnnotation as FileCitationDeltaAnnotation, type FilePathAnnotation as FilePathAnnotation, type FilePathDeltaAnnotation as FilePathDeltaAnnotation, type ImageFile as ImageFile, type ImageFileContentBlock as ImageFileContentBlock, type ImageFileDelta as ImageFileDelta, type ImageFileDeltaBlock as ImageFileDeltaBlock, type ImageURL as ImageURL, type ImageURLContentBlock as ImageURLContentBlock, type ImageURLDelta as ImageURLDelta, type ImageURLDeltaBlock as ImageURLDeltaBlock, type MessagesAPIMessage as Message, type MessageContent as MessageContent, type MessageContentDelta as MessageContentDelta, type MessageContentPartParam as MessageContentPartParam, type MessageDeleted as MessageDeleted, type MessageDelta as MessageDelta, type MessageDeltaEvent as MessageDeltaEvent, type RefusalContentBlock as RefusalContentBlock, type RefusalDeltaBlock as RefusalDeltaBlock, type Text as Text, type TextContentBlock as TextContentBlock, type TextContentBlockParam as TextContentBlockParam, type TextDelta as TextDelta, type TextDeltaBlock as TextDeltaBlock, type MessagesPage as MessagesPage, type MessageCreateParams as MessageCreateParams, type MessageRetrieveParams as MessageRetrieveParams, type MessageUpdateParams as MessageUpdateParams, type MessageListParams as MessageListParams, type MessageDeleteParams as MessageDeleteParams, };
export { AssistantStream };
}
//# sourceMappingURL=threads.d.mts.map
File diff suppressed because one or more lines are too long
+1048
View File
@@ -0,0 +1,1048 @@
import { APIResource } from "../../../core/resource.js";
import * as ThreadsAPI from "./threads.js";
import * as Shared from "../../shared.js";
import * as AssistantsAPI from "../assistants.js";
import * as MessagesAPI from "./messages.js";
import { Annotation, AnnotationDelta, FileCitationAnnotation, FileCitationDeltaAnnotation, FilePathAnnotation, FilePathDeltaAnnotation, ImageFile, ImageFileContentBlock, ImageFileDelta, ImageFileDeltaBlock, ImageURL, ImageURLContentBlock, ImageURLDelta, ImageURLDeltaBlock, Message as MessagesAPIMessage, MessageContent, MessageContentDelta, MessageContentPartParam, MessageCreateParams, MessageDeleteParams, MessageDeleted, MessageDelta, MessageDeltaEvent, MessageListParams, MessageRetrieveParams, MessageUpdateParams, Messages, MessagesPage, RefusalContentBlock, RefusalDeltaBlock, Text, TextContentBlock, TextContentBlockParam, TextDelta, TextDeltaBlock } from "./messages.js";
import * as RunsAPI from "./runs/runs.js";
import { RequiredActionFunctionToolCall, Run, RunCreateAndPollParams, RunCreateAndStreamParams, RunCancelParams, RunCreateParams, RunCreateParamsNonStreaming, RunCreateParamsStreaming, RunListParams, RunRetrieveParams, RunStatus, RunStreamParams, RunSubmitToolOutputsAndPollParams, RunSubmitToolOutputsParams, RunSubmitToolOutputsParamsNonStreaming, RunSubmitToolOutputsParamsStreaming, RunSubmitToolOutputsStreamParams, RunUpdateParams, Runs, RunsPage } from "./runs/runs.js";
import { APIPromise } from "../../../core/api-promise.js";
import { Stream } from "../../../core/streaming.js";
import { RequestOptions } from "../../../internal/request-options.js";
import { AssistantStream, ThreadCreateAndRunParamsBaseStream } from "../../../lib/AssistantStream.js";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export declare class Threads extends APIResource {
runs: RunsAPI.Runs;
messages: MessagesAPI.Messages;
/**
* Create a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(body?: ThreadCreateParams | null | undefined, options?: RequestOptions): APIPromise<Thread>;
/**
* Retrieves a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(threadID: string, options?: RequestOptions): APIPromise<Thread>;
/**
* Modifies a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(threadID: string, body: ThreadUpdateParams, options?: RequestOptions): APIPromise<Thread>;
/**
* Delete a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
delete(threadID: string, options?: RequestOptions): APIPromise<ThreadDeleted>;
/**
* Create a thread and run it in one request.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
createAndRun(body: ThreadCreateAndRunParamsNonStreaming, options?: RequestOptions): APIPromise<RunsAPI.Run>;
createAndRun(body: ThreadCreateAndRunParamsStreaming, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>>;
createAndRun(body: ThreadCreateAndRunParamsBase, options?: RequestOptions): APIPromise<Stream<AssistantsAPI.AssistantStreamEvent> | RunsAPI.Run>;
/**
* A helper to create a thread, start a run and then poll for a terminal state.
* More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
createAndRunPoll(body: ThreadCreateAndRunParamsNonStreaming, options?: RequestOptions & {
pollIntervalMs?: number;
}): Promise<Threads.Run>;
/**
* Create a thread and stream the run back
*/
createAndRunStream(body: ThreadCreateAndRunParamsBaseStream, options?: RequestOptions): AssistantStream;
}
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
export type AssistantResponseFormatOption = 'auto' | Shared.ResponseFormatText | Shared.ResponseFormatJSONObject | Shared.ResponseFormatJSONSchema;
/**
* Specifies a tool the model should use. Use to force the model to call a specific
* tool.
*/
export interface AssistantToolChoice {
/**
* The type of the tool. If type is `function`, the function name must be set
*/
type: 'function' | 'code_interpreter' | 'file_search';
function?: AssistantToolChoiceFunction;
}
export interface AssistantToolChoiceFunction {
/**
* The name of the function to call.
*/
name: string;
}
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
export type AssistantToolChoiceOption = 'none' | 'auto' | 'required' | AssistantToolChoice;
/**
* Represents a thread that contains
* [messages](https://platform.openai.com/docs/api-reference/messages).
*/
export interface Thread {
/**
* The identifier, which can be referenced in API endpoints.
*/
id: string;
/**
* The Unix timestamp (in seconds) for when the thread was created.
*/
created_at: number;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata: Shared.Metadata | null;
/**
* The object type, which is always `thread`.
*/
object: 'thread';
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
tool_resources: Thread.ToolResources | null;
}
export declare namespace Thread {
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this thread. There can be a maximum of 1 vector store attached to
* the thread.
*/
vector_store_ids?: Array<string>;
}
}
}
export interface ThreadDeleted {
id: string;
deleted: boolean;
object: 'thread.deleted';
}
export interface ThreadCreateParams {
/**
* A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
* start the thread with.
*/
messages?: Array<ThreadCreateParams.Message>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
tool_resources?: ThreadCreateParams.ToolResources | null;
}
export declare namespace ThreadCreateParams {
interface Message {
/**
* The text contents of the message.
*/
content: string | Array<MessagesAPI.MessageContentPartParam>;
/**
* The role of the entity that is creating the message. Allowed values include:
*
* - `user`: Indicates the message is sent by an actual user and should be used in
* most cases to represent user-generated messages.
* - `assistant`: Indicates the message is generated by the assistant. Use this
* value to insert messages from the assistant into the conversation.
*/
role: 'user' | 'assistant';
/**
* A list of files attached to the message, and the tools they should be added to.
*/
attachments?: Array<Message.Attachment> | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace Message {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.FileSearch>;
}
namespace Attachment {
interface FileSearch {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
}
}
}
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this thread. There can be a maximum of 1 vector store attached to
* the thread.
*/
vector_store_ids?: Array<string>;
/**
* A helper to create a
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* with file_ids and attach it to this thread. There can be a maximum of 1 vector
* store attached to the thread.
*/
vector_stores?: Array<FileSearch.VectorStore>;
}
namespace FileSearch {
interface VectorStore {
/**
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
* strategy.
*/
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
* add to the vector store. For vector stores created before Nov 2025, there can be
* a maximum of 10,000 files in a vector store. For vector stores created starting
* in Nov 2025, the limit is 100,000,000 files.
*/
file_ids?: Array<string>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace VectorStore {
/**
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
* `800` and `chunk_overlap_tokens` of `400`.
*/
interface Auto {
/**
* Always `auto`.
*/
type: 'auto';
}
interface Static {
static: Static.Static;
/**
* Always `static`.
*/
type: 'static';
}
namespace Static {
interface Static {
/**
* The number of tokens that overlap between chunks. The default value is `400`.
*
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
*/
chunk_overlap_tokens: number;
/**
* The maximum number of tokens in each chunk. The default value is `800`. The
* minimum value is `100` and the maximum value is `4096`.
*/
max_chunk_size_tokens: number;
}
}
}
}
}
}
export interface ThreadUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
tool_resources?: ThreadUpdateParams.ToolResources | null;
}
export declare namespace ThreadUpdateParams {
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this thread. There can be a maximum of 1 vector store attached to
* the thread.
*/
vector_store_ids?: Array<string>;
}
}
}
export type ThreadCreateAndRunParams = ThreadCreateAndRunParamsNonStreaming | ThreadCreateAndRunParamsStreaming;
export interface ThreadCreateAndRunParamsBase {
/**
* The ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
* execute this run.
*/
assistant_id: string;
/**
* Override the default system message of the assistant. This is useful for
* modifying the behavior on a per-run basis.
*/
instructions?: string | null;
/**
* The maximum number of completion tokens that may be used over the course of the
* run. The run will make a best effort to use only the number of completion tokens
* specified, across multiple turns of the run. If the run exceeds the number of
* completion tokens specified, the run will end with status `incomplete`. See
* `incomplete_details` for more info.
*/
max_completion_tokens?: number | null;
/**
* The maximum number of prompt tokens that may be used over the course of the run.
* The run will make a best effort to use only the number of prompt tokens
* specified, across multiple turns of the run. If the run exceeds the number of
* prompt tokens specified, the run will end with status `incomplete`. See
* `incomplete_details` for more info.
*/
max_prompt_tokens?: number | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
* be used to execute this run. If a value is provided here, it will override the
* model associated with the assistant. If not, the model associated with the
* assistant will be used.
*/
model?: (string & {}) | Shared.ChatModel | null;
/**
* Whether to enable
* [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
* during tool use.
*/
parallel_tool_calls?: boolean;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
* in the
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: AssistantResponseFormatOption | null;
/**
* If `true`, returns a stream of events that happen during the Run as server-sent
* events, terminating when the Run enters a terminal state with a `data: [DONE]`
* message.
*/
stream?: boolean | null;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;
/**
* Options to create a new thread. If no thread is provided when running a request,
* an empty thread will be created.
*/
thread?: ThreadCreateAndRunParams.Thread;
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
tool_choice?: AssistantToolChoiceOption | null;
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
tool_resources?: ThreadCreateAndRunParams.ToolResources | null;
/**
* Override the tools the assistant can use for this run. This is useful for
* modifying the behavior on a per-run basis.
*/
tools?: Array<AssistantsAPI.AssistantTool> | null;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the
* model considers the results of the tokens with top_p probability mass. So 0.1
* means only the tokens comprising the top 10% probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the initial context window of the run.
*/
truncation_strategy?: ThreadCreateAndRunParams.TruncationStrategy | null;
}
export declare namespace ThreadCreateAndRunParams {
/**
* Options to create a new thread. If no thread is provided when running a request,
* an empty thread will be created.
*/
interface Thread {
/**
* A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
* start the thread with.
*/
messages?: Array<Thread.Message>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
tool_resources?: Thread.ToolResources | null;
}
namespace Thread {
interface Message {
/**
* The text contents of the message.
*/
content: string | Array<MessagesAPI.MessageContentPartParam>;
/**
* The role of the entity that is creating the message. Allowed values include:
*
* - `user`: Indicates the message is sent by an actual user and should be used in
* most cases to represent user-generated messages.
* - `assistant`: Indicates the message is generated by the assistant. Use this
* value to insert messages from the assistant into the conversation.
*/
role: 'user' | 'assistant';
/**
* A list of files attached to the message, and the tools they should be added to.
*/
attachments?: Array<Message.Attachment> | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace Message {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | Attachment.FileSearch>;
}
namespace Attachment {
interface FileSearch {
/**
* The type of tool being defined: `file_search`
*/
type: 'file_search';
}
}
}
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this thread. There can be a maximum of 1 vector store attached to
* the thread.
*/
vector_store_ids?: Array<string>;
/**
* A helper to create a
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* with file_ids and attach it to this thread. There can be a maximum of 1 vector
* store attached to the thread.
*/
vector_stores?: Array<FileSearch.VectorStore>;
}
namespace FileSearch {
interface VectorStore {
/**
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
* strategy.
*/
chunking_strategy?: VectorStore.Auto | VectorStore.Static;
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
* add to the vector store. For vector stores created before Nov 2025, there can be
* a maximum of 10,000 files in a vector store. For vector stores created starting
* in Nov 2025, the limit is 100,000,000 files.
*/
file_ids?: Array<string>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format, and
* querying for objects via API or the dashboard.
*
* Keys are strings with a maximum length of 64 characters. Values are strings with
* a maximum length of 512 characters.
*/
metadata?: Shared.Metadata | null;
}
namespace VectorStore {
/**
* The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
* `800` and `chunk_overlap_tokens` of `400`.
*/
interface Auto {
/**
* Always `auto`.
*/
type: 'auto';
}
interface Static {
static: Static.Static;
/**
* Always `static`.
*/
type: 'static';
}
namespace Static {
interface Static {
/**
* The number of tokens that overlap between chunks. The default value is `400`.
*
* Note that the overlap must not exceed half of `max_chunk_size_tokens`.
*/
chunk_overlap_tokens: number;
/**
* The maximum number of tokens in each chunk. The default value is `800`. The
* minimum value is `100` and the maximum value is `4096`.
*/
max_chunk_size_tokens: number;
}
}
}
}
}
}
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The ID of the
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this assistant. There can be a maximum of 1 vector store attached to
* the assistant.
*/
vector_store_ids?: Array<string>;
}
}
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the initial context window of the run.
*/
interface TruncationStrategy {
/**
* The truncation strategy to use for the thread. The default is `auto`. If set to
* `last_messages`, the thread will be truncated to the n most recent messages in
* the thread. When set to `auto`, messages in the middle of the thread will be
* dropped to fit the context length of the model, `max_prompt_tokens`.
*/
type: 'auto' | 'last_messages';
/**
* The number of most recent messages from the thread when constructing the context
* for the run.
*/
last_messages?: number | null;
}
type ThreadCreateAndRunParamsNonStreaming = ThreadsAPI.ThreadCreateAndRunParamsNonStreaming;
type ThreadCreateAndRunParamsStreaming = ThreadsAPI.ThreadCreateAndRunParamsStreaming;
}
export interface ThreadCreateAndRunParamsNonStreaming extends ThreadCreateAndRunParamsBase {
/**
* If `true`, returns a stream of events that happen during the Run as server-sent
* events, terminating when the Run enters a terminal state with a `data: [DONE]`
* message.
*/
stream?: false | null;
}
export interface ThreadCreateAndRunParamsStreaming extends ThreadCreateAndRunParamsBase {
/**
* If `true`, returns a stream of events that happen during the Run as server-sent
* events, terminating when the Run enters a terminal state with a `data: [DONE]`
* message.
*/
stream: true;
}
export interface ThreadCreateAndRunPollParams {
/**
* The ID of the
* [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
* execute this run.
*/
assistant_id: string;
/**
* Override the default system message of the assistant. This is useful for
* modifying the behavior on a per-run basis.
*/
instructions?: string | null;
/**
* The maximum number of completion tokens that may be used over the course of the
* run. The run will make a best effort to use only the number of completion tokens
* specified, across multiple turns of the run. If the run exceeds the number of
* completion tokens specified, the run will end with status `incomplete`. See
* `incomplete_details` for more info.
*/
max_completion_tokens?: number | null;
/**
* The maximum number of prompt tokens that may be used over the course of the run.
* The run will make a best effort to use only the number of prompt tokens
* specified, across multiple turns of the run. If the run exceeds the number of
* prompt tokens specified, the run will end with status `incomplete`. See
* `incomplete_details` for more info.
*/
max_prompt_tokens?: number | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format. Keys
* can be a maximum of 64 characters long and values can be a maxium of 512
* characters long.
*/
metadata?: unknown | null;
/**
* The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
* be used to execute this run. If a value is provided here, it will override the
* model associated with the assistant. If not, the model associated with the
* assistant will be used.
*/
model?: (string & {}) | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-0125-preview' | 'gpt-4-turbo-preview' | 'gpt-4-1106-preview' | 'gpt-4-vision-preview' | 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-16k' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-16k-0613' | null;
/**
* Specifies the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
* and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
* message the model generates is valid JSON.
*
* **Important:** when using JSON mode, you **must** also instruct the model to
* produce JSON yourself via a system or user message. Without this, the model may
* generate an unending stream of whitespace until the generation reaches the token
* limit, resulting in a long-running and seemingly "stuck" request. Also note that
* the message content may be partially cut off if `finish_reason="length"`, which
* indicates the generation exceeded `max_tokens` or the conversation exceeded the
* max context length.
*/
response_format?: AssistantResponseFormatOption | null;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;
/**
* If no thread is provided, an empty thread will be created.
*/
thread?: ThreadCreateAndRunPollParams.Thread;
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
tool_choice?: AssistantToolChoiceOption | null;
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
tool_resources?: ThreadCreateAndRunPollParams.ToolResources | null;
/**
* Override the tools the assistant can use for this run. This is useful for
* modifying the behavior on a per-run basis.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool | AssistantsAPI.FunctionTool> | null;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the
* model considers the results of the tokens with top_p probability mass. So 0.1
* means only the tokens comprising the top 10% probability mass are considered.
*
* We generally recommend altering this or temperature but not both.
*/
top_p?: number | null;
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the intial context window of the run.
*/
truncation_strategy?: ThreadCreateAndRunPollParams.TruncationStrategy | null;
}
export declare namespace ThreadCreateAndRunPollParams {
/**
* If no thread is provided, an empty thread will be created.
*/
interface Thread {
/**
* A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
* start the thread with.
*/
messages?: Array<Thread.Message>;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format. Keys
* can be a maximum of 64 characters long and values can be a maxium of 512
* characters long.
*/
metadata?: unknown | null;
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
tool_resources?: Thread.ToolResources | null;
}
namespace Thread {
interface Message {
/**
* The text contents of the message.
*/
content: string | Array<MessagesAPI.MessageContentPartParam>;
/**
* The role of the entity that is creating the message. Allowed values include:
*
* - `user`: Indicates the message is sent by an actual user and should be used in
* most cases to represent user-generated messages.
* - `assistant`: Indicates the message is generated by the assistant. Use this
* value to insert messages from the assistant into the conversation.
*/
role: 'user' | 'assistant';
/**
* A list of files attached to the message, and the tools they should be added to.
*/
attachments?: Array<Message.Attachment> | null;
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful
* for storing additional information about the object in a structured format. Keys
* can be a maximum of 64 characters long and values can be a maxium of 512
* characters long.
*/
metadata?: unknown | null;
}
namespace Message {
interface Attachment {
/**
* The ID of the file to attach to the message.
*/
file_id?: string;
/**
* The tools to add this file to.
*/
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
}
}
/**
* A set of resources that are made available to the assistant's tools in this
* thread. The resources are specific to the type of tool. For example, the
* `code_interpreter` tool requires a list of file IDs, while the `file_search`
* tool requires a list of vector store IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this thread. There can be a maximum of 1 vector store attached to
* the thread.
*/
vector_store_ids?: Array<string>;
/**
* A helper to create a
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* with file_ids and attach it to this thread. There can be a maximum of 1 vector
* store attached to the thread.
*/
vector_stores?: Array<FileSearch.VectorStore>;
}
namespace FileSearch {
interface VectorStore {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
* add to the vector store. There can be a maximum of 10000 files in a vector
* store.
*/
file_ids?: Array<string>;
/**
* Set of 16 key-value pairs that can be attached to a vector store. This can be
* useful for storing additional information about the vector store in a structured
* format. Keys can be a maximum of 64 characters long and values can be a maxium
* of 512 characters long.
*/
metadata?: unknown;
}
}
}
}
/**
* A set of resources that are used by the assistant's tools. The resources are
* specific to the type of tool. For example, the `code_interpreter` tool requires
* a list of file IDs, while the `file_search` tool requires a list of vector store
* IDs.
*/
interface ToolResources {
code_interpreter?: ToolResources.CodeInterpreter;
file_search?: ToolResources.FileSearch;
}
namespace ToolResources {
interface CodeInterpreter {
/**
* A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
* available to the `code_interpreter` tool. There can be a maximum of 20 files
* associated with the tool.
*/
file_ids?: Array<string>;
}
interface FileSearch {
/**
* The ID of the
* [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
* attached to this assistant. There can be a maximum of 1 vector store attached to
* the assistant.
*/
vector_store_ids?: Array<string>;
}
}
/**
* Controls for how a thread will be truncated prior to the run. Use this to
* control the intial context window of the run.
*/
interface TruncationStrategy {
/**
* The truncation strategy to use for the thread. The default is `auto`. If set to
* `last_messages`, the thread will be truncated to the n most recent messages in
* the thread. When set to `auto`, messages in the middle of the thread will be
* dropped to fit the context length of the model, `max_prompt_tokens`.
*/
type: 'auto' | 'last_messages';
/**
* The number of most recent messages from the thread when constructing the context
* for the run.
*/
last_messages?: number | null;
}
}
export type ThreadCreateAndRunStreamParams = ThreadCreateAndRunParamsBaseStream;
export declare namespace Threads {
export { type AssistantResponseFormatOption as AssistantResponseFormatOption, type AssistantToolChoice as AssistantToolChoice, type AssistantToolChoiceFunction as AssistantToolChoiceFunction, type AssistantToolChoiceOption as AssistantToolChoiceOption, type Thread as Thread, type ThreadDeleted as ThreadDeleted, type ThreadCreateParams as ThreadCreateParams, type ThreadUpdateParams as ThreadUpdateParams, type ThreadCreateAndRunParams as ThreadCreateAndRunParams, type ThreadCreateAndRunParamsNonStreaming as ThreadCreateAndRunParamsNonStreaming, type ThreadCreateAndRunParamsStreaming as ThreadCreateAndRunParamsStreaming, type ThreadCreateAndRunPollParams, type ThreadCreateAndRunStreamParams, };
export { Runs as Runs, type RequiredActionFunctionToolCall as RequiredActionFunctionToolCall, type Run as Run, type RunStatus as RunStatus, type RunsPage as RunsPage, type RunCreateParams as RunCreateParams, type RunCreateParamsNonStreaming as RunCreateParamsNonStreaming, type RunCreateParamsStreaming as RunCreateParamsStreaming, type RunRetrieveParams as RunRetrieveParams, type RunUpdateParams as RunUpdateParams, type RunListParams as RunListParams, type RunCancelParams as RunCancelParams, type RunCreateAndPollParams, type RunCreateAndStreamParams, type RunStreamParams, type RunSubmitToolOutputsParams as RunSubmitToolOutputsParams, type RunSubmitToolOutputsParamsNonStreaming as RunSubmitToolOutputsParamsNonStreaming, type RunSubmitToolOutputsParamsStreaming as RunSubmitToolOutputsParamsStreaming, type RunSubmitToolOutputsAndPollParams, type RunSubmitToolOutputsStreamParams, };
export { Messages as Messages, type Annotation as Annotation, type AnnotationDelta as AnnotationDelta, type FileCitationAnnotation as FileCitationAnnotation, type FileCitationDeltaAnnotation as FileCitationDeltaAnnotation, type FilePathAnnotation as FilePathAnnotation, type FilePathDeltaAnnotation as FilePathDeltaAnnotation, type ImageFile as ImageFile, type ImageFileContentBlock as ImageFileContentBlock, type ImageFileDelta as ImageFileDelta, type ImageFileDeltaBlock as ImageFileDeltaBlock, type ImageURL as ImageURL, type ImageURLContentBlock as ImageURLContentBlock, type ImageURLDelta as ImageURLDelta, type ImageURLDeltaBlock as ImageURLDeltaBlock, type MessagesAPIMessage as Message, type MessageContent as MessageContent, type MessageContentDelta as MessageContentDelta, type MessageContentPartParam as MessageContentPartParam, type MessageDeleted as MessageDeleted, type MessageDelta as MessageDelta, type MessageDeltaEvent as MessageDeltaEvent, type RefusalContentBlock as RefusalContentBlock, type RefusalDeltaBlock as RefusalDeltaBlock, type Text as Text, type TextContentBlock as TextContentBlock, type TextContentBlockParam as TextContentBlockParam, type TextDelta as TextDelta, type TextDeltaBlock as TextDeltaBlock, type MessagesPage as MessagesPage, type MessageCreateParams as MessageCreateParams, type MessageRetrieveParams as MessageRetrieveParams, type MessageUpdateParams as MessageUpdateParams, type MessageListParams as MessageListParams, type MessageDeleteParams as MessageDeleteParams, };
export { AssistantStream };
}
//# sourceMappingURL=threads.d.ts.map
File diff suppressed because one or more lines are too long
+104
View File
@@ -0,0 +1,104 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Threads = void 0;
const tslib_1 = require("../../../internal/tslib.js");
const resource_1 = require("../../../core/resource.js");
const MessagesAPI = tslib_1.__importStar(require("./messages.js"));
const messages_1 = require("./messages.js");
const RunsAPI = tslib_1.__importStar(require("./runs/runs.js"));
const runs_1 = require("./runs/runs.js");
const headers_1 = require("../../../internal/headers.js");
const AssistantStream_1 = require("../../../lib/AssistantStream.js");
const path_1 = require("../../../internal/utils/path.js");
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
class Threads extends resource_1.APIResource {
constructor() {
super(...arguments);
this.runs = new RunsAPI.Runs(this._client);
this.messages = new MessagesAPI.Messages(this._client);
}
/**
* Create a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(body = {}, options) {
return this._client.post('/threads', {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Retrieves a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(threadID, options) {
return this._client.get((0, path_1.path) `/threads/${threadID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Modifies a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(threadID, body, options) {
return this._client.post((0, path_1.path) `/threads/${threadID}`, {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Delete a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
delete(threadID, options) {
return this._client.delete((0, path_1.path) `/threads/${threadID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
createAndRun(body, options) {
return this._client.post('/threads/runs', {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: body.stream ?? false,
__synthesizeEventData: true,
__security: { bearerAuth: true },
});
}
/**
* A helper to create a thread, start a run and then poll for a terminal state.
* More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
async createAndRunPoll(body, options) {
const run = await this.createAndRun(body, options);
return await this.runs.poll(run.id, { thread_id: run.thread_id }, options);
}
/**
* Create a thread and stream the run back
*/
createAndRunStream(body, options) {
return AssistantStream_1.AssistantStream.createThreadAssistantStream(body, this._client.beta.threads, options);
}
}
exports.Threads = Threads;
Threads.Runs = runs_1.Runs;
Threads.Messages = messages_1.Messages;
//# sourceMappingURL=threads.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../../src/resources/beta/threads/threads.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,wDAAqD;AAIrD,mEAA0C;AAC1C,4CAoCoB;AACpB,gEAAuC;AACvC,yCAqBqB;AAGrB,0DAAyD;AAEzD,qEAAmG;AACnG,0DAAoD;AAEpD;;;;GAIG;AACH,MAAa,OAAQ,SAAQ,sBAAW;IAAxC;;QACE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpD,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAuG1E,CAAC;IArGC;;;;OAIG;IACH,MAAM,CAAC,OAA8C,EAAE,EAAE,OAAwB;QAC/E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE;YACnC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,QAAgB,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,YAAY,QAAQ,EAAE,EAAE;YAClD,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAgB,EAAE,IAAwB,EAAE,OAAwB;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,YAAY,QAAQ,EAAE,EAAE;YACnD,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAgB,EAAE,OAAwB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAA,WAAI,EAAA,YAAY,QAAQ,EAAE,EAAE;YACrD,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAgBD,YAAY,CACV,IAA8B,EAC9B,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE;YACxC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;YAC5B,qBAAqB,EAAE,IAAI;YAC3B,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAqF,CAAC;IACzF,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CACpB,IAA0C,EAC1C,OAAsD;QAEtD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACnD,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,IAAwC,EAAE,OAAwB;QACnF,OAAO,iCAAe,CAAC,2BAA2B,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/F,CAAC;CACF;AAzGD,0BAyGC;AAonCD,OAAO,CAAC,IAAI,GAAG,WAAI,CAAC;AACpB,OAAO,CAAC,QAAQ,GAAG,mBAAQ,CAAC"}
+99
View File
@@ -0,0 +1,99 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as MessagesAPI from "./messages.mjs";
import { Messages, } from "./messages.mjs";
import * as RunsAPI from "./runs/runs.mjs";
import { Runs, } from "./runs/runs.mjs";
import { buildHeaders } from "../../../internal/headers.mjs";
import { AssistantStream } from "../../../lib/AssistantStream.mjs";
import { path } from "../../../internal/utils/path.mjs";
/**
* Build Assistants that can call models and use tools.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
export class Threads extends APIResource {
constructor() {
super(...arguments);
this.runs = new RunsAPI.Runs(this._client);
this.messages = new MessagesAPI.Messages(this._client);
}
/**
* Create a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(body = {}, options) {
return this._client.post('/threads', {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Retrieves a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(threadID, options) {
return this._client.get(path `/threads/${threadID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Modifies a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(threadID, body, options) {
return this._client.post(path `/threads/${threadID}`, {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Delete a thread.
*
* @deprecated The Assistants API is deprecated in favor of the Responses API
*/
delete(threadID, options) {
return this._client.delete(path `/threads/${threadID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
__security: { bearerAuth: true },
});
}
createAndRun(body, options) {
return this._client.post('/threads/runs', {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: body.stream ?? false,
__synthesizeEventData: true,
__security: { bearerAuth: true },
});
}
/**
* A helper to create a thread, start a run and then poll for a terminal state.
* More information on Run lifecycles can be found here:
* https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps
*/
async createAndRunPoll(body, options) {
const run = await this.createAndRun(body, options);
return await this.runs.poll(run.id, { thread_id: run.thread_id }, options);
}
/**
* Create a thread and stream the run back
*/
createAndRunStream(body, options) {
return AssistantStream.createThreadAssistantStream(body, this._client.beta.threads, options);
}
}
Threads.Runs = Runs;
Threads.Messages = Messages;
//# sourceMappingURL=threads.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"threads.mjs","sourceRoot":"","sources":["../../../src/resources/beta/threads/threads.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AAIrD,OAAO,KAAK,WAAW,uBAAmB;AAC1C,OAAO,EA2BL,QAAQ,GAST,uBAAmB;AACpB,OAAO,KAAK,OAAO,wBAAoB;AACvC,OAAO,EAmBL,IAAI,GAEL,wBAAoB;AAGrB,OAAO,EAAE,YAAY,EAAE,sCAAkC;AAEzD,OAAO,EAAE,eAAe,EAAsC,yCAAqC;AACnG,OAAO,EAAE,IAAI,EAAE,yCAAqC;AAEpD;;;;GAIG;AACH,MAAM,OAAO,OAAQ,SAAQ,WAAW;IAAxC;;QACE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpD,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAuG1E,CAAC;IArGC;;;;OAIG;IACH,MAAM,CAAC,OAA8C,EAAE,EAAE,OAAwB;QAC/E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE;YACnC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,QAAgB,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,YAAY,QAAQ,EAAE,EAAE;YAClD,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAgB,EAAE,IAAwB,EAAE,OAAwB;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,YAAY,QAAQ,EAAE,EAAE;YACnD,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAgB,EAAE,OAAwB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,YAAY,QAAQ,EAAE,EAAE;YACrD,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAgBD,YAAY,CACV,IAA8B,EAC9B,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE;YACxC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7E,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;YAC5B,qBAAqB,EAAE,IAAI;YAC3B,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAqF,CAAC;IACzF,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CACpB,IAA0C,EAC1C,OAAsD;QAEtD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACnD,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,IAAwC,EAAE,OAAwB;QACnF,OAAO,eAAe,CAAC,2BAA2B,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/F,CAAC;CACF;AAonCD,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;AACpB,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC"}