Skip to content

OpenAiClient

59 exports Added in v1.0.0 Source

Constructors

make

Added in v1.0.0 Source

Signature

declare function make(options: {
  readonly apiKey?: Redacted<string>;
  readonly apiUrl?: string;
  readonly organizationId?: Redacted<string>;
  readonly projectId?: Redacted<string>;
  readonly transformClient?: (client: HttpClient) => HttpClient;
}): Effect<Service, never, any>;

Context

OpenAiClient

Added in v1.0.0 Source

Signature

declare class OpenAiClient extends any {
  constructor();
}

Layers

layer

Added in v1.0.0 Source

Signature

declare function layer(options: {
  readonly apiKey?: Redacted<string>;
  readonly apiUrl?: string;
  readonly organizationId?: Redacted<string>;
  readonly projectId?: Redacted<string>;
  readonly transformClient?: (client: HttpClient) => HttpClient;
}): Layer<OpenAiClient, never, HttpClient>;

layerConfig

Added in v1.0.0 Source

Signature

declare function layerConfig(options: {
  readonly apiKey?: Config<Redacted<string> | undefined>;
  readonly apiUrl?: Config<string | undefined>;
  readonly organizationId?: Config<Redacted<string> | undefined>;
  readonly projectId?: Config<Redacted<string> | undefined>;
  readonly transformClient?: (client: HttpClient) => HttpClient;
}): Layer<OpenAiClient, ConfigError, HttpClient>;

Models

ResponseStreamEvent type

Added in v1.0.0 Source

Represents the events that can be emitted during a streaming response.

Signature

type ResponseStreamEvent = typeof ResponseStreamEvent.Type;

Service interface

Added in v1.0.0 Source

Signature

interface Service {
  readonly client: Client;
  readonly createEmbedding: (options: {
    [key: string]: any;
  }) => Effect<CreateEmbeddingResponse, AiError>;
  readonly createResponse: (options: { [key: string]: any }) => Effect<Response, AiError>;
  readonly createResponseStream: (
    options: Omit<typeof Generated.CreateResponse.Encoded, "stream">,
  ) => Stream<
    | ResponseCreatedEvent
    | ResponseQueuedEvent
    | ResponseInProgressEvent
    | ResponseCompletedEvent
    | ResponseIncompleteEvent
    | ResponseFailedEvent
    | ResponseOutputItemAddedEvent
    | ResponseOutputItemDoneEvent
    | ResponseContentPartAddedEvent
    | ResponseContentPartDoneEvent
    | ResponseOutputTextDeltaEvent
    | ResponseOutputTextDoneEvent
    | ResponseOutputTextAnnotationAddedEvent
    | ResponseRefusalDeltaEvent
    | ResponseRefusalDoneEvent
    | ResponseFunctionCallArgumentsDeltaEvent
    | ResponseFunctionCallArgumentsDoneEvent
    | ResponseFileSearchCallInProgressEvent
    | ResponseFileSearchCallSearchingEvent
    | ResponseFileSearchCallCompletedEvent
    | ResponseWebSearchCallInProgressEvent
    | ResponseWebSearchCallSearchingEvent
    | ResponseWebSearchCallCompletedEvent
    | ResponseReasoningSummaryPartAddedEvent
    | ResponseReasoningSummaryPartDoneEvent
    | ResponseReasoningSummaryTextDeltaEvent
    | ResponseReasoningSummaryTextDoneEvent
    | ResponseReasoningTextDeltaEvent
    | ResponseReasoningTextDoneEvent
    | ResponseImageGenerationCallInProgressEvent
    | ResponseImageGenerationCallGeneratingEvent
    | ResponseImageGenerationCallPartialImageEvent
    | ResponseImageGenerationCallCompletedEvent
    | ResponseMcpCallArgumentsDeltaEvent
    | ResponseMcpCallArgumentsDoneEvent
    | ResponseMcpCallInProgressEvent
    | ResponseMcpCallCompletedEvent
    | ResponseMcpCallFailedEvent
    | ResponseMcpListToolsInProgressEvent
    | ResponseMcpListToolsCompletedEvent
    | ResponseMcpListToolsFailedEvent
    | ResponseCodeInterpreterCallInProgressEvent
    | ResponseCodeInterpreterCallInterpretingEvent
    | ResponseCodeInterpreterCallCompletedEvent
    | ResponseCodeInterpreterCallCodeDeltaEvent
    | ResponseCodeInterpreterCallCodeDoneEvent
    | ResponseCustomToolCallInputDeltaEvent
    | ResponseCustomToolCallInputDoneEvent
    | ResponseErrorEvent,
    AiError
  >;
  readonly streamRequest: <A, I, R>(
    request: HttpClientRequest,
    schema: any,
  ) => Stream<A, AiError, R>;
}

Signature

type StreamCompletionRequest = Omit<typeof Generated.CreateChatCompletionRequest.Encoded, "stream">;

Schemas

LogProbs

Added in v1.0.0 Source

Signature

declare class LogProbs extends ReadonlySide<
  {
    readonly logprob: Number;
    readonly token: String;
    readonly top_logprobs: $Array<
      Struct<{
        readonly logprob: Number;
        readonly token: String;
      }>
    >;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly logprob: Number;
        readonly token: String;
        readonly top_logprobs: $Array<
          Struct<{
            readonly logprob: Number;
            readonly token: String;
          }>
        >;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a partial code snippet is streamed by the code interpreter.

Signature

declare class ResponseCodeInterpreterCallCodeDeltaEvent extends ReadonlySide<
  {
    readonly delta: String;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.code_interpreter_call_code.delta">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly delta: String;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.code_interpreter_call_code.delta">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when the code snippet is finalized by the code interpreter.

Signature

declare class ResponseCodeInterpreterCallCodeDoneEvent extends ReadonlySide<
  {
    readonly code: String;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.code_interpreter_call_code.done">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly code: String;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.code_interpreter_call_code.done">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when the code interpreter call is completed.

Signature

declare class ResponseCodeInterpreterCallCompletedEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.code_interpreter_call.completed">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.code_interpreter_call.completed">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a code interpreter call is in progress.

Signature

declare class ResponseCodeInterpreterCallInProgressEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.code_interpreter_call.in_progress">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.code_interpreter_call.in_progress">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when the code interpreter is actively interpreting the code snippet.

Signature

declare class ResponseCodeInterpreterCallInterpretingEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.code_interpreter_call.interpreting">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.code_interpreter_call.interpreting">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when the model response is complete.

Signature

declare class ResponseCompletedEvent extends ReadonlySide<
  {
    readonly response: typeof Response;
    readonly sequence_number: Int;
    readonly type: Literal<"response.completed">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly response: typeof Response;
        readonly sequence_number: Int;
        readonly type: Literal<"response.completed">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a new content part is added.

Signature

declare class ResponseContentPartAddedEvent extends ReadonlySide<{
  readonly content_index: Int;
  readonly item_id: String;
  readonly output_index: Int;
  readonly part: Union<readonly Array<Constraint>>;
  readonly sequence_number: Int;
  readonly type: Literal<"response.content_part.added">;
}, "Type"> {
  constructor(...args: [props: ReadonlyMakeIn<{
    readonly content_index: Int;
    readonly item_id: String;
    readonly output_index: Int;
    readonly part: Union<readonly Array<Constraint>>;
    readonly sequence_number: Int;
    readonly type: Literal<"response.content_part.added">;
  }>, options?: MakeOptions]);
}

Emitted when a content part is done.

Signature

declare class ResponseContentPartDoneEvent extends ReadonlySide<{
  readonly content_index: Int;
  readonly item_id: String;
  readonly output_index: Int;
  readonly part: Union<readonly Array<Constraint>>;
  readonly sequence_number: Int;
  readonly type: Literal<"response.content_part.done">;
}, "Type"> {
  constructor(...args: [props: ReadonlyMakeIn<{
    readonly content_index: Int;
    readonly item_id: String;
    readonly output_index: Int;
    readonly part: Union<readonly Array<Constraint>>;
    readonly sequence_number: Int;
    readonly type: Literal<"response.content_part.done">;
  }>, options?: MakeOptions]);
}

An event that is emitted when a response is created.

Signature

declare class ResponseCreatedEvent extends ReadonlySide<
  {
    readonly response: typeof Response;
    readonly sequence_number: Int;
    readonly type: Literal<"response.created">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly response: typeof Response;
        readonly sequence_number: Int;
        readonly type: Literal<"response.created">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Event representing a delta (partial update) to the input of a custom tool call.

Signature

declare class ResponseCustomToolCallInputDeltaEvent extends ReadonlySide<
  {
    readonly delta: String;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.custom_tool_call_input.delta">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly delta: String;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.custom_tool_call_input.delta">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Event indicating that input for a custom tool call is complete.

Signature

declare class ResponseCustomToolCallInputDoneEvent extends ReadonlySide<
  {
    readonly input: String;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.custom_tool_call_input.done">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly input: String;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.custom_tool_call_input.done">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when an error occurs.

Signature

declare class ResponseErrorEvent extends {
  readonly code?: string | null;
  readonly message: string;
  readonly param?: string | null;
  readonly sequence_number: number;
  readonly type: "error";
} {
  constructor(...args: [props: {
    readonly code?: string | null;
    readonly message: string;
    readonly param?: string | null;
    readonly sequence_number: number;
    readonly type: "error";
  }, options?: MakeOptions]);
}

An event that is emitted when a response fails.

Signature

declare class ResponseFailedEvent extends ReadonlySide<
  {
    readonly response: typeof Response;
    readonly sequence_number: Int;
    readonly type: Literal<"response.failed">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly response: typeof Response;
        readonly sequence_number: Int;
        readonly type: Literal<"response.failed">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a file search call is completed (results found).

Signature

declare class ResponseFileSearchCallCompletedEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.file_search_call.completed">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.file_search_call.completed">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a file search call is initiated.

Signature

declare class ResponseFileSearchCallInProgressEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.file_search_call.in_progress">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.file_search_call.in_progress">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a file search is currently searching.

Signature

declare class ResponseFileSearchCallSearchingEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.file_search_call.searching">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.file_search_call.searching">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when there is a partial function-call arguments delta.

Signature

declare class ResponseFunctionCallArgumentsDeltaEvent extends ReadonlySide<
  {
    readonly delta: String;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.function_call_arguments.delta">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly delta: String;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.function_call_arguments.delta">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when function-call arguments are finalized.

Signature

declare class ResponseFunctionCallArgumentsDoneEvent extends ReadonlySide<
  {
    readonly arguments: String;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.function_call_arguments.done">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly arguments: String;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.function_call_arguments.done">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when an image generation tool call has completed and the final image is available.

Signature

declare class ResponseImageGenerationCallCompletedEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.image_generation_call.completed">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.image_generation_call.completed">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when an image generation tool call is actively generating an image (intermediate state).

Signature

declare class ResponseImageGenerationCallGeneratingEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.image_generation_call.generating">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.image_generation_call.generating">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when an image generation tool call is in progress.

Signature

declare class ResponseImageGenerationCallInProgressEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.image_generation_call.in_progress">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.image_generation_call.in_progress">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a partial image is available during image generation streaming.

Signature

declare class ResponseImageGenerationCallPartialImageEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly partial_image_b64: String;
    readonly partial_image_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.image_generation_call.partial_image">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly partial_image_b64: String;
        readonly partial_image_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.image_generation_call.partial_image">;
      }>,
      options?: MakeOptions,
    ]
  );
}

An event that is emitted when a response finishes as incomplete.

Signature

declare class ResponseIncompleteEvent extends ReadonlySide<
  {
    readonly response: typeof Response;
    readonly sequence_number: Int;
    readonly type: Literal<"response.incomplete">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly response: typeof Response;
        readonly sequence_number: Int;
        readonly type: Literal<"response.incomplete">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when the response is in progress.

Signature

declare class ResponseInProgressEvent extends ReadonlySide<
  {
    readonly response: typeof Response;
    readonly sequence_number: Int;
    readonly type: Literal<"response.in_progress">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly response: typeof Response;
        readonly sequence_number: Int;
        readonly type: Literal<"response.in_progress">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when there is a delta (partial update) to the arguments of an MCP tool call.

Signature

declare class ResponseMcpCallArgumentsDeltaEvent extends ReadonlySide<
  {
    readonly delta: String;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.mcp_call_arguments.delta">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly delta: String;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.mcp_call_arguments.delta">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when the arguments for an MCP tool call are finalized.

Signature

declare class ResponseMcpCallArgumentsDoneEvent extends ReadonlySide<
  {
    readonly arguments: String;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.mcp_call_arguments.done">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly arguments: String;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.mcp_call_arguments.done">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when an MCP tool call has completed successfully.

Signature

declare class ResponseMcpCallCompletedEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.mcp_call.completed">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.mcp_call.completed">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when an MCP tool call has failed.

Signature

declare class ResponseMcpCallFailedEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.mcp_call.failed">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.mcp_call.failed">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when an MCP tool call is in progress.

Signature

declare class ResponseMcpCallInProgressEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.mcp_call.in_progress">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.mcp_call.in_progress">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when the list of available MCP tools has been successfully retrieved.

Signature

declare class ResponseMcpListToolsCompletedEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.mcp_list_tools.completed">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.mcp_list_tools.completed">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when the attempt to list available MCP tools has failed.

Signature

declare class ResponseMcpListToolsFailedEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.mcp_list_tools.failed">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.mcp_list_tools.failed">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when the system is in the process of retrieving the list of available MCP tools.

Signature

declare class ResponseMcpListToolsInProgressEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.mcp_list_tools.in_progress">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.mcp_list_tools.in_progress">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a new output item is added.

Signature

declare class ResponseOutputItemAddedEvent extends ReadonlySide<{
  readonly item: Union<readonly Array<Constraint>>;
  readonly output_index: Int;
  readonly sequence_number: Int;
  readonly type: Literal<"response.output_item.added">;
}, "Type"> {
  constructor(...args: [props: ReadonlyMakeIn<{
    readonly item: Union<readonly Array<Constraint>>;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.output_item.added">;
  }>, options?: MakeOptions]);
}

Emitted when an output item is marked done.

Signature

declare class ResponseOutputItemDoneEvent extends ReadonlySide<Fields, "Type"> {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
  constructor(...args: [props?: ReadonlyMakeIn<Fields>, options?: MakeOptions]);
}

Emitted when an annotation is added to output text content.

Signature

declare class ResponseOutputTextAnnotationAddedEvent extends ReadonlySide<Fields, "Type"> {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
  constructor(...args: [props?: ReadonlyMakeIn<Fields>, options?: MakeOptions]);
}

Emitted when there is an additional text delta.

Signature

declare class ResponseOutputTextDeltaEvent extends {
  readonly content_index: number;
  readonly delta: string;
  readonly item_id: string;
  readonly logprobs?: readonly Array<LogProbs> | null;
  readonly output_index: number;
  readonly sequence_number: number;
  readonly type: "response.output_text.delta";
} {
  constructor(...args: [props: {
    readonly content_index: number;
    readonly delta: string;
    readonly item_id: string;
    readonly logprobs?: readonly Array<LogProbs> | null;
    readonly output_index: number;
    readonly sequence_number: number;
    readonly type: "response.output_text.delta";
  }, options?: MakeOptions]);
}

Emitted when text content is finalized.

Signature

declare class ResponseOutputTextDoneEvent extends {
  readonly content_index: number;
  readonly item_id: string;
  readonly logprobs?: readonly Array<LogProbs> | null;
  readonly output_index: number;
  readonly sequence_number: number;
  readonly text: string;
  readonly type: "response.output_text.done";
} {
  constructor(...args: [props: {
    readonly content_index: number;
    readonly item_id: string;
    readonly logprobs?: readonly Array<LogProbs> | null;
    readonly output_index: number;
    readonly sequence_number: number;
    readonly text: string;
    readonly type: "response.output_text.done";
  }, options?: MakeOptions]);
}

Emitted when a response is queued and waiting to be processed.

Signature

declare class ResponseQueuedEvent extends ReadonlySide<
  {
    readonly response: typeof Response;
    readonly sequence_number: Int;
    readonly type: Literal<"response.queued">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly response: typeof Response;
        readonly sequence_number: Int;
        readonly type: Literal<"response.queued">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a reasoning summary part is completed.

Signature

declare class ResponseReasoningSummaryPartAddedEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly part: typeof SummaryPart;
    readonly sequence_number: Int;
    readonly summary_index: Int;
    readonly type: Literal<"response.reasoning_summary_part.added">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly part: typeof SummaryPart;
        readonly sequence_number: Int;
        readonly summary_index: Int;
        readonly type: Literal<"response.reasoning_summary_part.added">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a new reasoning summary part is added.

Signature

declare class ResponseReasoningSummaryPartDoneEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly part: typeof SummaryPart;
    readonly sequence_number: Int;
    readonly summary_index: Int;
    readonly type: Literal<"response.reasoning_summary_part.done">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly part: typeof SummaryPart;
        readonly sequence_number: Int;
        readonly summary_index: Int;
        readonly type: Literal<"response.reasoning_summary_part.done">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a delta is added to a reasoning summary text.

Signature

declare class ResponseReasoningSummaryTextDeltaEvent extends ReadonlySide<
  {
    readonly delta: String;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly summary_index: Int;
    readonly type: Literal<"response.reasoning_summary_text.delta">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly delta: String;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly summary_index: Int;
        readonly type: Literal<"response.reasoning_summary_text.delta">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a reasoning summary text is completed.

Signature

declare class ResponseReasoningSummaryTextDoneEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly summary_index: Int;
    readonly text: String;
    readonly type: Literal<"response.reasoning_summary_text.done">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly summary_index: Int;
        readonly text: String;
        readonly type: Literal<"response.reasoning_summary_text.done">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a delta is added to a reasoning text.

Signature

declare class ResponseReasoningTextDeltaEvent extends ReadonlySide<
  {
    readonly content_index: Int;
    readonly delta: String;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.reasoning_text.delta">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly content_index: Int;
        readonly delta: String;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.reasoning_text.delta">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a reasoning text is completed.

Signature

declare class ResponseReasoningTextDoneEvent extends ReadonlySide<
  {
    readonly content_index: Int;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly text: String;
    readonly type: Literal<"response.reasoning_text.done">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly content_index: Int;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly text: String;
        readonly type: Literal<"response.reasoning_text.done">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when there is a partial refusal text.

Signature

declare class ResponseRefusalDeltaEvent extends ReadonlySide<
  {
    readonly content_index: Int;
    readonly delta: String;
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.refusal.delta">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly content_index: Int;
        readonly delta: String;
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.refusal.delta">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when refusal text is finalized.

Signature

declare class ResponseRefusalDoneEvent extends ReadonlySide<
  {
    readonly content_index: Int;
    readonly item_id: String;
    readonly output_index: Int;
    readonly refusal: String;
    readonly sequence_number: Int;
    readonly type: Literal<"response.refusal.done">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly content_index: Int;
        readonly item_id: String;
        readonly output_index: Int;
        readonly refusal: String;
        readonly sequence_number: Int;
        readonly type: Literal<"response.refusal.done">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Represents the events that can be emitted during a streaming response.

Signature

declare const ResponseStreamEvent: Schema.Union<
  [
    typeof ResponseCreatedEvent,
    typeof ResponseQueuedEvent,
    typeof ResponseInProgressEvent,
    typeof ResponseCompletedEvent,
    typeof ResponseIncompleteEvent,
    typeof ResponseFailedEvent,
    typeof ResponseOutputItemAddedEvent,
    typeof ResponseOutputItemDoneEvent,
    typeof ResponseContentPartAddedEvent,
    typeof ResponseContentPartDoneEvent,
    typeof ResponseOutputTextDeltaEvent,
    typeof ResponseOutputTextDoneEvent,
    typeof ResponseOutputTextAnnotationAddedEvent,
    typeof ResponseRefusalDeltaEvent,
    typeof ResponseRefusalDoneEvent,
    typeof ResponseFunctionCallArgumentsDeltaEvent,
    typeof ResponseFunctionCallArgumentsDoneEvent,
    typeof ResponseFileSearchCallInProgressEvent,
    typeof ResponseFileSearchCallSearchingEvent,
    typeof ResponseFileSearchCallCompletedEvent,
    typeof ResponseWebSearchCallInProgressEvent,
    typeof ResponseWebSearchCallSearchingEvent,
    typeof ResponseWebSearchCallCompletedEvent,
    typeof ResponseReasoningSummaryPartAddedEvent,
    typeof ResponseReasoningSummaryPartDoneEvent,
    typeof ResponseReasoningSummaryTextDeltaEvent,
    typeof ResponseReasoningSummaryTextDoneEvent,
    typeof ResponseReasoningTextDeltaEvent,
    typeof ResponseReasoningTextDoneEvent,
    typeof ResponseImageGenerationCallInProgressEvent,
    typeof ResponseImageGenerationCallGeneratingEvent,
    typeof ResponseImageGenerationCallPartialImageEvent,
    typeof ResponseImageGenerationCallCompletedEvent,
    typeof ResponseMcpCallArgumentsDeltaEvent,
    typeof ResponseMcpCallArgumentsDoneEvent,
    typeof ResponseMcpCallInProgressEvent,
    typeof ResponseMcpCallCompletedEvent,
    typeof ResponseMcpCallFailedEvent,
    typeof ResponseMcpListToolsInProgressEvent,
    typeof ResponseMcpListToolsCompletedEvent,
    typeof ResponseMcpListToolsFailedEvent,
    typeof ResponseCodeInterpreterCallInProgressEvent,
    typeof ResponseCodeInterpreterCallInterpretingEvent,
    typeof ResponseCodeInterpreterCallCompletedEvent,
    typeof ResponseCodeInterpreterCallCodeDeltaEvent,
    typeof ResponseCodeInterpreterCallCodeDoneEvent,
    typeof ResponseCustomToolCallInputDeltaEvent,
    typeof ResponseCustomToolCallInputDoneEvent,
    typeof ResponseErrorEvent,
  ]
>;

Emitted when a web search call is completed.

Signature

declare class ResponseWebSearchCallCompletedEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.web_search_call.completed">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.web_search_call.completed">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a web search call is initiated.

Signature

declare class ResponseWebSearchCallInProgressEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.web_search_call.in_progress">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.web_search_call.in_progress">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Emitted when a web search call is executing.

Signature

declare class ResponseWebSearchCallSearchingEvent extends ReadonlySide<
  {
    readonly item_id: String;
    readonly output_index: Int;
    readonly sequence_number: Int;
    readonly type: Literal<"response.web_search_call.searching">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly item_id: String;
        readonly output_index: Int;
        readonly sequence_number: Int;
        readonly type: Literal<"response.web_search_call.searching">;
      }>,
      options?: MakeOptions,
    ]
  );
}

SummaryPart

Added in v1.0.0 Source

Signature

declare class SummaryPart extends ReadonlySide<
  {
    readonly text: String;
    readonly type: Literal<"summary_text">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly text: String;
        readonly type: Literal<"summary_text">;
      }>,
      options?: MakeOptions,
    ]
  );
}