Skip to main content Link Search Menu Expand Document (external link)

OpenAiClient.ts overview

Since v1.0.0


Exports Grouped by Category


Constructors

make

Signature

declare const make: (options: {
  readonly apiKey?: Redacted.Redacted | undefined
  readonly apiUrl?: string | undefined
  readonly organizationId?: Redacted.Redacted | undefined
  readonly projectId?: Redacted.Redacted | undefined
  readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
}) => Effect.Effect<Service, never, HttpClient.HttpClient>

Source

Since v1.0.0

Context

OpenAiClient (class)

Signature

declare class OpenAiClient

Source

Since v1.0.0

Layers

layer

Signature

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

Source

Since v1.0.0

layerConfig

Signature

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

Source

Since v1.0.0

Models

ResponseStreamEvent (type alias)

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

Signature

type ResponseStreamEvent = typeof ResponseStreamEvent.Type

Source

Since v1.0.0

Service (interface)

Signature

export interface Service {
  readonly client: Generated.Client

  readonly streamRequest: <A, I, R>(
    request: HttpClientRequest.HttpClientRequest,
    schema: Schema.Schema<A, I, R>
  ) => Stream.Stream<A, AiError.AiError, R>

  readonly createResponse: (
    options: typeof Generated.CreateResponse.Encoded
  ) => Effect.Effect<Generated.Response, AiError.AiError>

  readonly createResponseStream: (
    options: Omit<typeof Generated.CreateResponse.Encoded, "stream">
  ) => Stream.Stream<ResponseStreamEvent, AiError.AiError>

  readonly createEmbedding: (
    options: typeof Generated.CreateEmbeddingRequest.Encoded
  ) => Effect.Effect<Generated.CreateEmbeddingResponse, AiError.AiError>
}

Source

Since v1.0.0

StreamCompletionRequest (type alias)

Signature

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

Source

Since v1.0.0

Schemas

LogProbs (class)

Signature

declare class LogProbs

Source

Since v1.0.0

ResponseCodeInterpreterCallCodeDeltaEvent (class)

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

Signature

declare class ResponseCodeInterpreterCallCodeDeltaEvent

Source

Since v1.0.0

ResponseCodeInterpreterCallCodeDoneEvent (class)

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

Signature

declare class ResponseCodeInterpreterCallCodeDoneEvent

Source

Since v1.0.0

ResponseCodeInterpreterCallCompletedEvent (class)

Emitted when the code interpreter call is completed.

Signature

declare class ResponseCodeInterpreterCallCompletedEvent

Source

Since v1.0.0

ResponseCodeInterpreterCallInProgressEvent (class)

Emitted when a code interpreter call is in progress.

Signature

declare class ResponseCodeInterpreterCallInProgressEvent

Source

Since v1.0.0

ResponseCodeInterpreterCallInterpretingEvent (class)

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

Signature

declare class ResponseCodeInterpreterCallInterpretingEvent

Source

Since v1.0.0

ResponseCompletedEvent (class)

Emitted when the model response is complete.

Signature

declare class ResponseCompletedEvent

Source

Since v1.0.0

ResponseContentPartAddedEvent (class)

Emitted when a new content part is added.

Signature

declare class ResponseContentPartAddedEvent

Source

Since v1.0.0

ResponseContentPartDoneEvent (class)

Emitted when a content part is done.

Signature

declare class ResponseContentPartDoneEvent

Source

Since v1.0.0

ResponseCreatedEvent (class)

An event that is emitted when a response is created.

Signature

declare class ResponseCreatedEvent

Source

Since v1.0.0

ResponseCustomToolCallInputDeltaEvent (class)

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

Signature

declare class ResponseCustomToolCallInputDeltaEvent

Source

Since v1.0.0

ResponseCustomToolCallInputDoneEvent (class)

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

Signature

declare class ResponseCustomToolCallInputDoneEvent

Source

Since v1.0.0

ResponseErrorEvent (class)

Emitted when an error occurs.

Signature

declare class ResponseErrorEvent

Source

Since v1.0.0

ResponseFailedEvent (class)

An event that is emitted when a response fails.

Signature

declare class ResponseFailedEvent

Source

Since v1.0.0

ResponseFileSearchCallCompletedEvent (class)

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

Signature

declare class ResponseFileSearchCallCompletedEvent

Source

Since v1.0.0

ResponseFileSearchCallInProgressEvent (class)

Emitted when a file search call is initiated.

Signature

declare class ResponseFileSearchCallInProgressEvent

Source

Since v1.0.0

ResponseFileSearchCallSearchingEvent (class)

Emitted when a file search is currently searching.

Signature

declare class ResponseFileSearchCallSearchingEvent

Source

Since v1.0.0

ResponseFunctionCallArgumentsDeltaEvent (class)

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

Signature

declare class ResponseFunctionCallArgumentsDeltaEvent

Source

Since v1.0.0

ResponseFunctionCallArgumentsDoneEvent (class)

Emitted when function-call arguments are finalized.

Signature

declare class ResponseFunctionCallArgumentsDoneEvent

Source

Since v1.0.0

ResponseImageGenerationCallCompletedEvent (class)

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

Signature

declare class ResponseImageGenerationCallCompletedEvent

Source

Since v1.0.0

ResponseImageGenerationCallGeneratingEvent (class)

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

Signature

declare class ResponseImageGenerationCallGeneratingEvent

Source

Since v1.0.0

ResponseImageGenerationCallInProgressEvent (class)

Emitted when an image generation tool call is in progress.

Signature

declare class ResponseImageGenerationCallInProgressEvent

Source

Since v1.0.0

ResponseImageGenerationCallPartialImageEvent (class)

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

Signature

declare class ResponseImageGenerationCallPartialImageEvent

Source

Since v1.0.0

ResponseInProgressEvent (class)

Emitted when the response is in progress.

Signature

declare class ResponseInProgressEvent

Source

Since v1.0.0

ResponseIncompleteEvent (class)

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

Signature

declare class ResponseIncompleteEvent

Source

Since v1.0.0

ResponseMcpCallArgumentsDeltaEvent (class)

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

Signature

declare class ResponseMcpCallArgumentsDeltaEvent

Source

Since v1.0.0

ResponseMcpCallArgumentsDoneEvent (class)

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

Signature

declare class ResponseMcpCallArgumentsDoneEvent

Source

Since v1.0.0

ResponseMcpCallCompletedEvent (class)

Emitted when an MCP tool call has completed successfully.

Signature

declare class ResponseMcpCallCompletedEvent

Source

Since v1.0.0

ResponseMcpCallFailedEvent (class)

Emitted when an MCP tool call has failed.

Signature

declare class ResponseMcpCallFailedEvent

Source

Since v1.0.0

ResponseMcpCallInProgressEvent (class)

Emitted when an MCP tool call is in progress.

Signature

declare class ResponseMcpCallInProgressEvent

Source

Since v1.0.0

ResponseMcpListToolsCompletedEvent (class)

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

Signature

declare class ResponseMcpListToolsCompletedEvent

Source

Since v1.0.0

ResponseMcpListToolsFailedEvent (class)

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

Signature

declare class ResponseMcpListToolsFailedEvent

Source

Since v1.0.0

ResponseMcpListToolsInProgressEvent (class)

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

Signature

declare class ResponseMcpListToolsInProgressEvent

Source

Since v1.0.0

ResponseOutputItemAddedEvent (class)

Emitted when a new output item is added.

Signature

declare class ResponseOutputItemAddedEvent

Source

Since v1.0.0

ResponseOutputItemDoneEvent (class)

Emitted when an output item is marked done.

Signature

declare class ResponseOutputItemDoneEvent

Source

Since v1.0.0

ResponseOutputTextAnnotationAddedEvent (class)

Emitted when an annotation is added to output text content.

Signature

declare class ResponseOutputTextAnnotationAddedEvent

Source

Since v1.0.0

ResponseOutputTextDeltaEvent (class)

Emitted when there is an additional text delta.

Signature

declare class ResponseOutputTextDeltaEvent

Source

Since v1.0.0

ResponseOutputTextDoneEvent (class)

Emitted when text content is finalized.

Signature

declare class ResponseOutputTextDoneEvent

Source

Since v1.0.0

ResponseQueuedEvent (class)

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

Signature

declare class ResponseQueuedEvent

Source

Since v1.0.0

ResponseReasoningSummaryPartAddedEvent (class)

Emitted when a reasoning summary part is completed.

Signature

declare class ResponseReasoningSummaryPartAddedEvent

Source

Since v1.0.0

ResponseReasoningSummaryPartDoneEvent (class)

Emitted when a new reasoning summary part is added.

Signature

declare class ResponseReasoningSummaryPartDoneEvent

Source

Since v1.0.0

ResponseReasoningSummaryTextDeltaEvent (class)

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

Signature

declare class ResponseReasoningSummaryTextDeltaEvent

Source

Since v1.0.0

ResponseReasoningSummaryTextDoneEvent (class)

Emitted when a reasoning summary text is completed.

Signature

declare class ResponseReasoningSummaryTextDoneEvent

Source

Since v1.0.0

ResponseReasoningTextDeltaEvent (class)

Emitted when a delta is added to a reasoning text.

Signature

declare class ResponseReasoningTextDeltaEvent

Source

Since v1.0.0

ResponseReasoningTextDoneEvent (class)

Emitted when a reasoning text is completed.

Signature

declare class ResponseReasoningTextDoneEvent

Source

Since v1.0.0

ResponseRefusalDeltaEvent (class)

Emitted when there is a partial refusal text.

Signature

declare class ResponseRefusalDeltaEvent

Source

Since v1.0.0

ResponseRefusalDoneEvent (class)

Emitted when refusal text is finalized.

Signature

declare class ResponseRefusalDoneEvent

Source

Since v1.0.0

ResponseStreamEvent

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
  ]
>

Source

Since v1.0.0

ResponseWebSearchCallCompletedEvent (class)

Emitted when a web search call is completed.

Signature

declare class ResponseWebSearchCallCompletedEvent

Source

Since v1.0.0

ResponseWebSearchCallInProgressEvent (class)

Emitted when a web search call is initiated.

Signature

declare class ResponseWebSearchCallInProgressEvent

Source

Since v1.0.0

ResponseWebSearchCallSearchingEvent (class)

Emitted when a web search call is executing.

Signature

declare class ResponseWebSearchCallSearchingEvent

Source

Since v1.0.0

SummaryPart (class)

Signature

declare class SummaryPart

Source

Since v1.0.0