/**
* @stability unstable
* @since 1.0.0
*/
import * as Data from "effect/Data"
import * as Effect from "effect/Effect"
import * as Sse from "effect/encoding/Sse"
import * as HttpClient from "effect/http/HttpClient"
import * as HttpClientError from "effect/http/HttpClientError"
import * as HttpClientRequest from "effect/http/HttpClientRequest"
import * as HttpClientResponse from "effect/http/HttpClientResponse"
import type { SchemaError } from "effect/Schema"
import * as Schema from "effect/Schema"
import * as Stream from "effect/Stream"
// recursive declarations
export type CompoundFilter = {
readonly "type": "and" | "or"
readonly "filters": ReadonlyArray<ComparisonFilter | CompoundFilter>
}
export const CompoundFilter = Schema.suspend((): Schema.Codec<CompoundFilter> => __recursive_CompoundFilter)
export type BetaCompoundFilter = {
readonly "type": "and" | "or"
readonly "filters": ReadonlyArray<BetaComparisonFilter | BetaCompoundFilter>
}
export const BetaCompoundFilter = Schema.suspend((): Schema.Codec<BetaCompoundFilter> => __recursive_BetaCompoundFilter)
// non-recursive definitions
export type AssistantToolsCode = { readonly "type": "code_interpreter" }
export const AssistantToolsCode = Schema.Struct({
"type": Schema.Literal("code_interpreter").annotate({
"description": "The type of tool being defined: `code_interpreter`"
})
}).annotate({ "title": "Code interpreter tool", "identifier": "AssistantToolsCode" })
export type FileSearchRanker = "auto" | "default_2024_08_21"
export const FileSearchRanker = Schema.Literals(["auto", "default_2024_08_21"]).annotate({
"description": "The ranker to use for the file search. If not specified will use the `auto` ranker.",
"identifier": "FileSearchRanker"
})
export type FunctionParameters = { readonly [x: string]: Schema.Json }
export const FunctionParameters = Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" }))
.annotate({
"description":
"The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://developers.openai.com/api/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.\n\nOmitting `parameters` defines a function with an empty parameter list.",
"identifier": "FunctionParameters"
})
export type Metadata = { readonly [x: string]: string } | null
export const Metadata = Schema.Union([
Schema.Record(Schema.String, Schema.String).annotate({
"description":
"Set of 16 key-value pairs that can be attached to an object. This can be\nuseful for storing additional information about the object in a structured\nformat, and querying for objects via API or the dashboard.\n\nKeys are strings with a maximum length of 64 characters. Values are strings\nwith a maximum length of 512 characters.\n"
}),
Schema.Null
]).annotate({ "identifier": "Metadata" })
export type ResponseFormatText = { readonly "type": "text" }
export const ResponseFormatText = Schema.Struct({
"type": Schema.Literal("text").annotate({
"description": "The type of response format being defined. Always `text`."
})
}).annotate({
"title": "Text",
"description": "Default response format. Used to generate text responses.\n",
"identifier": "ResponseFormatText"
})
export type ResponseFormatJsonObject = { readonly "type": "json_object" }
export const ResponseFormatJsonObject = Schema.Struct({
"type": Schema.Literal("json_object").annotate({
"description": "The type of response format being defined. Always `json_object`."
})
}).annotate({
"title": "JSON object",
"description":
"JSON object response format. An older method of generating JSON responses.\nUsing `json_schema` is recommended for models that support it. Note that the\nmodel will not generate JSON without a system or user message instructing it\nto do so.\n",
"identifier": "ResponseFormatJsonObject"
})
export type ResponseFormatJsonSchemaSchema = { readonly [x: string]: Schema.Json }
export const ResponseFormatJsonSchemaSchema = Schema.Record(
Schema.String,
Schema.Json.annotate({ "expected": "JSON value" })
).annotate({
"title": "JSON schema",
"description":
"The schema for the response format, described as a JSON Schema object.\nLearn how to build JSON schemas [here](https://json-schema.org/).\n",
"identifier": "ResponseFormatJsonSchemaSchema"
})
export type _MisalignmentErrorType =
| string
| "potentially_unintended_data_transfer"
| "potentially_unintended_data_access"
| "potentially_unintended_destructive_activity"
| "other"
export const _MisalignmentErrorType = Schema.Union([
Schema.String,
Schema.Literals([
"potentially_unintended_data_transfer",
"potentially_unintended_data_access",
"potentially_unintended_destructive_activity",
"other"
])
]).annotate({ "identifier": "_MisalignmentErrorType" })
export type _MisalignmentSteer = { readonly "message": string }
export const _MisalignmentSteer = Schema.Struct({
"message": Schema.String.annotate({ "description": "The public continuation instruction." })
}).annotate({ "identifier": "_MisalignmentSteer" })
export type AssistantSupportedModels =
| "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"
export const AssistantSupportedModels = Schema.Literals([
"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"
]).annotate({ "identifier": "AssistantSupportedModels" })
export type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | null
export const ReasoningEffort = Schema.Union([
Schema.Literals(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).annotate({
"description":
"Constrains effort on reasoning for reasoning models. Currently supported\nvalues are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.\nReducing reasoning effort can result in faster responses and fewer tokens\nused on reasoning in a response. Not all reasoning models support every\nvalue. See the\n[reasoning guide](https://developers.openai.com/api/docs/guides/reasoning)\nfor model-specific support.\n"
}),
Schema.Null
]).annotate({ "identifier": "ReasoningEffort" })
export type DeleteAssistantResponse = {
readonly "id": string
readonly "deleted": boolean
readonly "object": "assistant.deleted"
}
export const DeleteAssistantResponse = Schema.Struct({
"id": Schema.String,
"deleted": Schema.Boolean,
"object": Schema.Literal("assistant.deleted")
}).annotate({ "identifier": "DeleteAssistantResponse" })
export type VoiceIdsShared =
| string
| "alloy"
| "ash"
| "ballad"
| "coral"
| "echo"
| "sage"
| "shimmer"
| "verse"
| "marin"
| "cedar"
export const VoiceIdsShared = Schema.Union([
Schema.String,
Schema.Literals(["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse", "marin", "cedar"])
]).annotate({ "identifier": "VoiceIdsShared" })
export type SpeechAudioDeltaEvent = { readonly "type": "speech.audio.delta"; readonly "audio": string }
export const SpeechAudioDeltaEvent = Schema.Struct({
"type": Schema.Literal("speech.audio.delta").annotate({
"description": "The type of the event. Always `speech.audio.delta`.\n"
}),
"audio": Schema.String.annotate({ "description": "A chunk of Base64-encoded audio data.\n" })
}).annotate({
"description": "Emitted for each chunk of audio data generated during speech synthesis.",
"identifier": "SpeechAudioDeltaEvent"
})
export type SpeechAudioDoneEvent = {
readonly "type": "speech.audio.done"
readonly "usage": {
readonly "input_tokens": number
readonly "output_tokens": number
readonly "total_tokens": number
}
}
export const SpeechAudioDoneEvent = Schema.Struct({
"type": Schema.Literal("speech.audio.done").annotate({
"description": "The type of the event. Always `speech.audio.done`.\n"
}),
"usage": Schema.Struct({
"input_tokens": Schema.Number.annotate({ "description": "Number of input tokens in the prompt." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"output_tokens": Schema.Number.annotate({ "description": "Number of output tokens generated." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (input + output)." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
}).annotate({ "description": "Token usage statistics for the request.\n" })
}).annotate({
"description": "Emitted when the speech synthesis is complete and all audio has been streamed.",
"identifier": "SpeechAudioDoneEvent"
})
export type __ClientMultipartFile = globalThis.File | globalThis.Blob
export const __ClientMultipartFile = Schema.instanceOf(globalThis.Blob, { expected: "File | Blob" })
export type AudioResponseFormat = "json" | "text" | "srt" | "verbose_json" | "vtt" | "diarized_json"
export const AudioResponseFormat = Schema.Literals(["json", "text", "srt", "verbose_json", "vtt", "diarized_json"])
.annotate({
"description":
"The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`. For `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and `diarized_json`, with `diarized_json` required to receive speaker annotations.\n",
"identifier": "AudioResponseFormat"
})
export type TranscriptionInclude = "logprobs"
export const TranscriptionInclude = Schema.Literal("logprobs").annotate({ "identifier": "TranscriptionInclude" })
export type VadConfig = {
readonly "type": "server_vad"
readonly "prefix_padding_ms"?: number
readonly "silence_duration_ms"?: number
readonly "threshold"?: number
}
export const VadConfig = Schema.Struct({
"type": Schema.Literal("server_vad").annotate({
"description": "Must be set to `server_vad` to enable manual chunking using server side VAD."
}),
"prefix_padding_ms": Schema.optionalKey(
Schema.Number.annotate({
"description": "Amount of audio to include before the VAD detected speech (in \nmilliseconds).\n"
}).check(Schema.isInt().annotate({ "expected": "an integer" }))
),
"silence_duration_ms": Schema.optionalKey(
Schema.Number.annotate({
"description":
"Duration of silence to detect speech stop (in milliseconds).\nWith shorter values the model will respond more quickly, \nbut may jump in on short pauses from the user.\n"
}).check(Schema.isInt().annotate({ "expected": "an integer" }))
),
"threshold": Schema.optionalKey(
Schema.Number.annotate({
"description":
"Sensitivity threshold (0.0 to 1.0) for voice activity detection. A \nhigher threshold will require louder audio to activate the model, and \nthus might perform better in noisy environments.\n"
}).check(Schema.isFinite().annotate({ "expected": "a finite number" }))
)
}).annotate({ "identifier": "VadConfig" })
export type TranscriptionLanguage = { readonly "code": string }
export const TranscriptionLanguage = Schema.Struct({
"code": Schema.String.annotate({ "description": "The code of a language detected in the audio." })
}).annotate({ "description": "A language detected in transcribed audio.", "identifier": "TranscriptionLanguage" })
export type TranscriptTextUsageTokens = {
readonly "type": "tokens"
readonly "input_tokens": number
readonly "input_token_details"?: { readonly "text_tokens"?: number; readonly "audio_tokens"?: number }
readonly "output_tokens": number
readonly "total_tokens": number
}
export const TranscriptTextUsageTokens = Schema.Struct({
"type": Schema.Literal("tokens").annotate({
"description": "The type of the usage object. Always `tokens` for this variant."
}),
"input_tokens": Schema.Number.annotate({ "description": "Number of input tokens billed for this request." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"input_token_details": Schema.optionalKey(
Schema.Struct({
"text_tokens": Schema.optionalKey(
Schema.Number.annotate({ "description": "Number of text tokens billed for this request." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
),
"audio_tokens": Schema.optionalKey(
Schema.Number.annotate({ "description": "Number of audio tokens billed for this request." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
)
}).annotate({ "description": "Details about the input tokens billed for this request." })
),
"output_tokens": Schema.Number.annotate({ "description": "Number of output tokens generated." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"total_tokens": Schema.Number.annotate({ "description": "Total number of tokens used (input + output)." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
}).annotate({
"title": "Token Usage",
"description": "Usage statistics for models billed by token usage.",
"identifier": "TranscriptTextUsageTokens"
})
export type TranscriptTextUsageDuration = { readonly "type": "duration"; readonly "seconds": number }
export const TranscriptTextUsageDuration = Schema.Struct({
"type": Schema.Literal("duration").annotate({
"description": "The type of the usage object. Always `duration` for this variant."
}),
"seconds": Schema.Number.annotate({ "description": "Duration of the input audio in seconds.", "format": "double" })
.check(Schema.isFinite().annotate({ "expected": "a finite number" }))
}).annotate({
"title": "Duration Usage",
"description": "Usage statistics for models billed by audio input duration.",
"identifier": "TranscriptTextUsageDuration"
})
export type TranscriptionDiarizedSegment = {
readonly "type": "transcript.text.segment"
readonly "id": string
readonly "start": number
readonly "end": number
readonly "text": string
readonly "speaker": string
}
export const TranscriptionDiarizedSegment = Schema.Struct({
"type": Schema.Literal("transcript.text.segment").annotate({
"description": "The type of the segment. Always `transcript.text.segment`.\n"
}),
"id": Schema.String.annotate({ "description": "Unique identifier for the segment." }),
"start": Schema.Number.annotate({ "description": "Start timestamp of the segment in seconds.", "format": "double" })
.check(Schema.isFinite().annotate({ "expected": "a finite number" })),
"end": Schema.Number.annotate({ "description": "End timestamp of the segment in seconds.", "format": "double" })
.check(Schema.isFinite().annotate({ "expected": "a finite number" })),
"text": Schema.String.annotate({ "description": "Transcript text for this segment." }),
"speaker": Schema.String.annotate({
"description":
"Speaker label for this segment. When known speakers are provided, the label matches `known_speaker_names[]`. Otherwise speakers are labeled sequentially using capital letters (`A`, `B`, ...).\n"
})
}).annotate({
"description": "A segment of diarized transcript text with speaker metadata.",
"identifier": "TranscriptionDiarizedSegment"
})
export type TranscriptionWord = { readonly "word": string; readonly "start": number; readonly "end": number }
export const TranscriptionWord = Schema.Struct({
"word": Schema.String.annotate({ "description": "The text content of the word." }),
"start": Schema.Number.annotate({ "description": "Start time of the word in seconds.", "format": "double" }).check(
Schema.isFinite().annotate({ "expected": "a finite number" })
),
"end": Schema.Number.annotate({ "description": "End time of the word in seconds.", "format": "double" }).check(
Schema.isFinite().annotate({ "expected": "a finite number" })
)
}).annotate({ "identifier": "TranscriptionWord" })
export type TranscriptionSegment = {
readonly "id": number
readonly "seek": number
readonly "start": number
readonly "end": number
readonly "text": string
readonly "tokens": ReadonlyArray<number>
readonly "temperature": number
readonly "avg_logprob": number
readonly "compression_ratio": number
readonly "no_speech_prob": number
}
export const TranscriptionSegment = Schema.Struct({
"id": Schema.Number.annotate({ "description": "Unique identifier of the segment." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"seek": Schema.Number.annotate({ "description": "Seek offset of the segment." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"start": Schema.Number.annotate({ "description": "Start time of the segment in seconds.", "format": "double" }).check(
Schema.isFinite().annotate({ "expected": "a finite number" })
),
"end": Schema.Number.annotate({ "description": "End time of the segment in seconds.", "format": "double" }).check(
Schema.isFinite().annotate({ "expected": "a finite number" })
),
"text": Schema.String.annotate({ "description": "Text content of the segment." }),
"tokens": Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({
"description": "Array of token IDs for the text content."
}),
"temperature": Schema.Number.annotate({
"description": "Temperature parameter used for generating the segment.",
"format": "float"
}).check(Schema.isFinite().annotate({ "expected": "a finite number" })),
"avg_logprob": Schema.Number.annotate({
"description": "Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.",
"format": "float"
}).check(Schema.isFinite().annotate({ "expected": "a finite number" })),
"compression_ratio": Schema.Number.annotate({
"description":
"Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.",
"format": "float"
}).check(Schema.isFinite().annotate({ "expected": "a finite number" })),
"no_speech_prob": Schema.Number.annotate({
"description":
"Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.",
"format": "float"
}).check(Schema.isFinite().annotate({ "expected": "a finite number" }))
}).annotate({ "identifier": "TranscriptionSegment" })
export type TranscriptTextSegmentEvent = {
readonly "type": "transcript.text.segment"
readonly "id": string
readonly "start": number
readonly "end": number
readonly "text": string
readonly "speaker": string
}
export const TranscriptTextSegmentEvent = Schema.Struct({
"type": Schema.Literal("transcript.text.segment").annotate({
"description": "The type of the event. Always `transcript.text.segment`."
}),
"id": Schema.String.annotate({ "description": "Unique identifier for the segment." }),
"start": Schema.Number.annotate({ "description": "Start timestamp of the segment in seconds.", "format": "double" })
.check(Schema.isFinite().annotate({ "expected": "a finite number" })),
"end": Schema.Number.annotate({ "description": "End timestamp of the segment in seconds.", "format": "double" })
.check(Schema.isFinite().annotate({ "expected": "a finite number" })),
"text": Schema.String.annotate({ "description": "Transcript text for this segment." }),
"speaker": Schema.String.annotate({ "description": "Speaker label for this segment." })
}).annotate({
"description":
"Emitted when a diarized transcription returns a completed segment with speaker information. Only emitted when you [create a transcription](https://developers.openai.com/api/reference/resources/audio/subresources/transcriptions/methods/create) with `stream` set to `true` and `response_format` set to `diarized_json`.\n",
"identifier": "TranscriptTextSegmentEvent"
})
export type TranscriptTextDeltaEvent = {
readonly "type": "transcript.text.delta"
readonly "delta": string
readonly "logprobs"?: ReadonlyArray<
{ readonly "token"?: string; readonly "logprob"?: number; readonly "bytes"?: ReadonlyArray<number> }
>
readonly "segment_id"?: string
}
export const TranscriptTextDeltaEvent = Schema.Struct({
"type": Schema.Literal("transcript.text.delta").annotate({
"description": "The type of the event. Always `transcript.text.delta`.\n"
}),
"delta": Schema.String.annotate({ "description": "The text delta that was additionally transcribed.\n" }),
"logprobs": Schema.optionalKey(
Schema.Array(Schema.Struct({
"token": Schema.optionalKey(
Schema.String.annotate({ "description": "The token that was used to generate the log probability.\n" })
),
"logprob": Schema.optionalKey(
Schema.Number.annotate({ "description": "The log probability of the token.\n" }).check(
Schema.isFinite().annotate({ "expected": "a finite number" })
)
),
"bytes": Schema.optionalKey(
Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({
"description": "The bytes that were used to generate the log probability.\n"
})
)
})).annotate({
"description":
"The log probabilities of the delta. Only included if you [create a transcription](https://developers.openai.com/api/reference/resources/audio/subresources/transcriptions/methods/create) with the `include[]` parameter set to `logprobs`.\n"
})
),
"segment_id": Schema.optionalKey(
Schema.String.annotate({
"description":
"Identifier of the diarized segment that this delta belongs to. Only present when using `gpt-4o-transcribe-diarize`.\n"
})
)
}).annotate({
"description":
"Emitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you [create a transcription](https://developers.openai.com/api/reference/resources/audio/subresources/transcriptions/methods/create) with the `Stream` parameter set to `true`.",
"identifier": "TranscriptTextDeltaEvent"
})
export type CreateTranslationResponseJson = { readonly "text": string }
export const CreateTranslationResponseJson = Schema.Struct({ "text": Schema.String }).annotate({
"identifier": "CreateTranslationResponseJson"
})
export type VoiceConsentResource = {
readonly "object": "audio.voice_consent"
readonly "id": string
readonly "name": string
readonly "language": string
readonly "created_at": number
}
export const VoiceConsentResource = Schema.Struct({
"object": Schema.Literal("audio.voice_consent").annotate({
"description": "The object type, which is always `audio.voice_consent`."
}),
"id": Schema.String.annotate({ "description": "The consent recording identifier." }),
"name": Schema.String.annotate({ "description": "The label provided when the consent recording was uploaded." }),
"language": Schema.String.annotate({
"description": "The BCP 47 language tag for the consent phrase (for example, `en-US`)."
}),
"created_at": Schema.Number.annotate({
"description": "The Unix timestamp (in seconds) for when the consent recording was created.",
"format": "unixtime"
}).check(Schema.isInt().annotate({ "expected": "an integer" }))
}).annotate({
"title": "Voice consent",
"description": "A consent recording used to authorize creation of a custom voice.",
"identifier": "VoiceConsentResource"
})
export type UpdateVoiceConsentRequest = { readonly "name": string }
export const UpdateVoiceConsentRequest = Schema.Struct({
"name": Schema.String.annotate({ "description": "The updated label for this consent recording." })
}).annotate({ "identifier": "UpdateVoiceConsentRequest" })
export type VoiceConsentDeletedResource = {
readonly "id": string
readonly "object": "audio.voice_consent"
readonly "deleted": boolean
}
export const VoiceConsentDeletedResource = Schema.Struct({
"id": Schema.String.annotate({ "description": "The consent recording identifier." }),
"object": Schema.Literal("audio.voice_consent"),
"deleted": Schema.Boolean
}).annotate({ "identifier": "VoiceConsentDeletedResource" })
export type VoiceResource = {
readonly "object": "audio.voice"
readonly "id": string
readonly "type": "audio_sample"
readonly "name": string
readonly "created_at": number
}
export const VoiceResource = Schema.Struct({
"object": Schema.Literal("audio.voice").annotate({
"description": "The object type, which is always `audio.voice`."
}),
"id": Schema.String.annotate({ "description": "The voice identifier, which can be referenced in API endpoints." }),
"type": Schema.Literal("audio_sample").annotate({ "description": "How the voice was created." }),
"name": Schema.String.annotate({ "description": "The name of the voice." }),
"created_at": Schema.Number.annotate({
"description": "The Unix timestamp (in seconds) for when the voice was created.",
"format": "unixtime"
}).check(Schema.isInt().annotate({ "expected": "an integer" }))
}).annotate({
"title": "Voice",
"description": "A custom voice that can be used for audio output.",
"identifier": "VoiceResource"
})
export type BatchError = {
readonly "code"?: string
readonly "message"?: string
readonly "param"?: string | null
readonly "line"?: number | null
}
export const BatchError = Schema.Struct({
"code": Schema.optionalKey(Schema.String.annotate({ "description": "An error code identifying the error type." })),
"message": Schema.optionalKey(
Schema.String.annotate({ "description": "A human-readable message providing more details about the error." })
),
"param": Schema.optionalKey(
Schema.Union([
Schema.String.annotate({ "description": "The name of the parameter that caused the error, if applicable." }),
Schema.Null
])
),
"line": Schema.optionalKey(
Schema.Union([
Schema.Number.annotate({
"description": "The line number of the input file where the error occurred, if applicable."
}).check(Schema.isInt().annotate({ "expected": "an integer" })),
Schema.Null
])
)
}).annotate({ "identifier": "BatchError" })
export type BatchRequestCounts = { readonly "total": number; readonly "completed": number; readonly "failed": number }
export const BatchRequestCounts = Schema.Struct({
"total": Schema.Number.annotate({ "description": "Total number of requests in the batch." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"completed": Schema.Number.annotate({ "description": "Number of requests that have been completed successfully." })
.check(Schema.isInt().annotate({ "expected": "an integer" })),
"failed": Schema.Number.annotate({ "description": "Number of requests that have failed." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
}).annotate({
"description": "The request counts for different statuses within the batch.",
"identifier": "BatchRequestCounts"
})
export type BatchFileExpirationAfter = { readonly "anchor": "created_at"; readonly "seconds": number }
export const BatchFileExpirationAfter = Schema.Struct({
"anchor": Schema.Literal("created_at").annotate({
"description":
"Anchor timestamp after which the expiration policy applies. Supported anchors: `created_at`. Note that the anchor is the file creation time, not the time the batch is created."
}),
"seconds": Schema.Number.annotate({
"description":
"The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).",
"format": "int64"
}).check(Schema.isInt().annotate({ "expected": "an integer" })).check(
Schema.isGreaterThanOrEqualTo(3600).annotate({ "expected": "a value greater than or equal to 3600" })
).check(Schema.isLessThanOrEqualTo(2592000).annotate({ "expected": "a value less than or equal to 2592000" }))
}).annotate({
"title": "File expiration policy",
"description": "The expiration policy for the output and/or error file that are generated for a batch.",
"identifier": "BatchFileExpirationAfter"
})
export type ChatCompletionMessageToolCall = {
readonly "id": string
readonly "type": "function"
readonly "function": { readonly "name": string; readonly "arguments": string }
}
export const ChatCompletionMessageToolCall = Schema.Struct({
"id": Schema.String.annotate({ "description": "The ID of the tool call." }),
"type": Schema.Literal("function").annotate({
"description": "The type of the tool. Currently, only `function` is supported."
}),
"function": Schema.Struct({
"name": Schema.String.annotate({ "description": "The name of the function to call." }),
"arguments": Schema.String.annotate({
"description":
"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."
})
}).annotate({ "description": "The function that the model called." })
}).annotate({
"title": "Function tool call",
"description": "A call to a function tool created by the model.\n",
"identifier": "ChatCompletionMessageToolCall"
})
export type ChatCompletionMessageCustomToolCall = {
readonly "id": string
readonly "type": "custom"
readonly "custom": { readonly "name": string; readonly "input": string }
}
export const ChatCompletionMessageCustomToolCall = Schema.Struct({
"id": Schema.String.annotate({ "description": "The ID of the tool call." }),
"type": Schema.Literal("custom").annotate({ "description": "The type of the tool. Always `custom`." }),
"custom": Schema.Struct({
"name": Schema.String.annotate({ "description": "The name of the custom tool to call." }),
"input": Schema.String.annotate({ "description": "The input for the custom tool call generated by the model." })
}).annotate({ "description": "The custom tool that the model called." })
}).annotate({
"title": "Custom tool call",
"description": "A call to a custom tool created by the model.\n",
"identifier": "ChatCompletionMessageCustomToolCall"
})
export type ChatCompletionTokenLogprob = {
readonly "token": string
readonly "logprob": number
readonly "bytes": ReadonlyArray<number> | null
readonly "top_logprobs": ReadonlyArray<
{ readonly "token": string; readonly "logprob": number; readonly "bytes": ReadonlyArray<number> | null }
>
}
export const ChatCompletionTokenLogprob = Schema.Struct({
"token": Schema.String.annotate({ "description": "The token." }),
"logprob": Schema.Number.annotate({
"description":
"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely."
}).check(Schema.isFinite().annotate({ "expected": "a finite number" })),
"bytes": Schema.Union([
Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({
"description":
"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token."
}),
Schema.Null
]),
"top_logprobs": Schema.Array(Schema.Struct({
"token": Schema.String.annotate({ "description": "The token." }),
"logprob": Schema.Number.annotate({
"description":
"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely."
}).check(Schema.isFinite().annotate({ "expected": "a finite number" })),
"bytes": Schema.Union([
Schema.Array(Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" }))).annotate({
"description":
"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token."
}),
Schema.Null
])
})).annotate({
"description":
"List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`."
})
}).annotate({ "identifier": "ChatCompletionTokenLogprob" })
export type ServiceTier = "auto" | "default" | "flex" | "scale" | "priority" | "fast" | null
export const ServiceTier = Schema.Union([
Schema.Literals(["auto", "default", "flex", "scale", "priority", "fast"]).annotate({
"description":
"Specifies the processing type used for serving the request.\n - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.\n - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.\n - If set to '[flex](https://developers.openai.com/api/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.\n - To opt-in to [Fast mode](https://developers.openai.com/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request.\n - When not set, the default behavior is 'auto'.\n\n When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.\n"
}),
Schema.Null
]).annotate({ "identifier": "ServiceTier" })
export type CompletionUsage = {
readonly "completion_tokens": number
readonly "prompt_tokens": number
readonly "total_tokens": number
readonly "completion_tokens_details"?: {
readonly "accepted_prediction_tokens"?: number
readonly "audio_tokens"?: number
readonly "reasoning_tokens"?: number
readonly "text_tokens"?: number
readonly "rejected_prediction_tokens"?: number
}
readonly "prompt_tokens_details"?: {
readonly "audio_tokens"?: number
readonly "cached_tokens"?: number
readonly "text_tokens"?: number
readonly "image_tokens"?: number
readonly "cache_write_tokens"?: number
}
}
export const CompletionUsage = Schema.Struct({
"completion_tokens": Schema.Number.annotate({ "description": "Number of tokens in the generated completion." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"prompt_tokens": Schema.Number.annotate({ "description": "Number of tokens in the prompt." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
),
"total_tokens": Schema.Number.annotate({
"description": "Total number of tokens used in the request (prompt + completion)."
}).check(Schema.isInt().annotate({ "expected": "an integer" })),
"completion_tokens_details": Schema.optionalKey(
Schema.Struct({
"accepted_prediction_tokens": Schema.optionalKey(
Schema.Number.annotate({
"description":
"When using Predicted Outputs, the number of tokens in the\nprediction that appeared in the completion.\n"
}).check(Schema.isInt().annotate({ "expected": "an integer" }))
),
"audio_tokens": Schema.optionalKey(
Schema.Number.annotate({ "description": "Audio input tokens generated by the model." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
),
"reasoning_tokens": Schema.optionalKey(
Schema.Number.annotate({ "description": "Tokens generated by the model for reasoning." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
),
"text_tokens": Schema.optionalKey(
Schema.Number.annotate({ "description": "Text output tokens generated by the model." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
),
"rejected_prediction_tokens": Schema.optionalKey(
Schema.Number.annotate({
"description":
"When using Predicted Outputs, the number of tokens in the\nprediction that did not appear in the completion. However, like\nreasoning tokens, these tokens are still counted in the total\ncompletion tokens for purposes of billing, output, and context window\nlimits.\n"
}).check(Schema.isInt().annotate({ "expected": "an integer" }))
)
}).annotate({ "description": "Breakdown of tokens used in a completion." })
),
"prompt_tokens_details": Schema.optionalKey(
Schema.Struct({
"audio_tokens": Schema.optionalKey(
Schema.Number.annotate({ "description": "Audio input tokens present in the prompt." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
),
"cached_tokens": Schema.optionalKey(
Schema.Number.annotate({ "description": "Cached tokens present in the prompt." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
),
"text_tokens": Schema.optionalKey(
Schema.Number.annotate({ "description": "Text input tokens present in the prompt." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
),
"image_tokens": Schema.optionalKey(
Schema.Number.annotate({ "description": "Image input tokens present in the prompt." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
),
"cache_write_tokens": Schema.optionalKey(
Schema.Number.annotate({ "description": "The unadjusted number of prompt tokens written to cache." }).check(
Schema.isInt().annotate({ "expected": "an integer" })
)
)
}).annotate({ "description": "Breakdown of tokens used in the prompt." })
)
}).annotate({ "description": "Usage statistics for the completion request.", "identifier": "CompletionUsage" })
export type ModerationInputType = "text" | "image"
export const ModerationInputType = Schema.Literals(["text", "image"]).annotate({ "identifier": "ModerationInputType" })
export type ChatCompletionModerationError = {
readonly "type": "error"
readonly "code": string
readonly "message": string
}
export const ChatCompletionModerationError = Schema.Struct({
"type": Schema.Literal("error").annotate({ "description": "The object type, which is always `error`." }),
"code": Schema.String.annotate({ "description": "The error code." }),
"message": Schema.String.annotate({ "description": "The error message." })
}).annotate({
"description": "An error produced while attempting moderation.",
"identifier": "ChatCompletionModerationError"
})
export type PromptCacheTTLEnum = "30m"
export const PromptCacheTTLEnum = Schema.Literal("30m").annotate({ "identifier": "PromptCacheTTLEnum" })
export type PromptCacheModeEnum = "implicit" | "explicit"
export const PromptCacheModeEnum = Schema.Literals(["implicit", "explicit"]).annotate({
"identifier": "PromptCacheModeEnum"
})
export type PromptCacheBreakpointParam = { readonly "mode": "explicit" }
export const PromptCacheBreakpointParam = Schema.Struct({
"mode": Schema.Literal("explicit").annotate({ "description": "The breakpoint mode. Always `explicit`." })
}).annotate({
"title": "Prompt cache breakpoint",
"description":
"Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.",
"identifier": "PromptCacheBreakpointParam"
})
export type ChatCompletionRequestMessageContentPartRefusal = { readonly "type": "refusal"; readonly "refusal": string }
export const ChatCompletionRequestMessageContentPartRefusal = Schema.Struct({
"type": Schema.Literal("refusal").annotate({ "description": "The type of the content part." }),
"refusal": Schema.String.annotate({ "description": "The refusal message generated by the model." })
}).annotate({ "title": "Refusal content part", "identifier": "ChatCompletionRequestMessageContentPartRefusal" })
export type ChatCompletionRequestFunctionMessage = {
readonly "role": "function"
readonly "content": string | null
readonly "name": string
}
export const ChatCompletionRequestFunctionMessage = Schema.Struct({
"role": Schema.Literal("function").annotate({
"description": "The role of the messages author, in this case `function`."
}),
"content": Schema.Union([
Schema.String.annotate({ "description": "The contents of the function message." }),
Schema.Null
]),
"name": Schema.String.annotate({ "description": "The name of the function to call." })
}).annotate({ "title": "Function message", "identifier": "ChatCompletionRequestFunctionMessage" })
export type ModelIdsShared =
| string
| "gpt-6-astra"
| "gpt-6.1-sol"
| "gpt-6-sol"
| "gpt-6-luna"
| "gpt-5.6-sol"
| "gpt-5.6-terra"
| "gpt-5.6-luna"
| "gpt-5.5"
| "gpt-5.5-2026-04-23"
| "gpt-5.4"
| "gpt-5.4-mini"
| "gpt-5.4-nano"
| "gpt-5.4-mini-2026-03-17"
| "gpt-5.4-nano-2026-03-17"
| "gpt-5.3-chat-latest"
| "gpt-5.2"
| "gpt-5.2-2025-12-11"
| "gpt-5.2-chat-latest"
| "gpt-5.2-pro"
| "gpt-5.2-pro-2025-12-11"
| "gpt-5.1"
| "gpt-5.1-2025-11-13"
| "gpt-5.1-codex"
| "gpt-5.1-mini"
| "gpt-5.1-chat-latest"
| "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-5-chat-latest"
| "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"
| "o4-mini"
| "o4-mini-2025-04-16"
| "o3"
| "o3-2025-04-16"
| "o3-mini"
| "o3-mini-2025-01-31"
| "o1"
| "o1-2024-12-17"
| "o1-preview"
| "o1-preview-2024-09-12"
| "o1-mini"
| "o1-mini-2024-09-12"
| "gpt-4o"
| "gpt-4o-2024-11-20"
| "gpt-4o-2024-08-06"
| "gpt-4o-2024-05-13"
| "gpt-audio-mini"
| "gpt-audio-mini-2025-12-15"
| "gpt-4o-audio-preview"
| "gpt-4o-audio-preview-2024-10-01"
| "gpt-4o-audio-preview-2024-12-17"
| "gpt-4o-audio-preview-2025-06-03"
| "gpt-4o-mini-audio-preview"
| "gpt-4o-mini-audio-preview-2024-12-17"
| "gpt-4o-search-preview"
| "gpt-4o-mini-search-preview"
| "gpt-4o-search-preview-2025-03-11"
| "gpt-4o-mini-search-preview-2025-03-11"
| "chatgpt-4o-latest"
| "codex-mini-latest"
| "gpt-4o-mini"
| "gpt-4o-mini-2024-07-18"
| "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-0301"
| "gpt-3.5-turbo-0613"
| "gpt-3.5-turbo-1106"
| "gpt-3.5-turbo-0125"
| "gpt-3.5-turbo-16k-0613"
export const ModelIdsShared = Schema.Union([
Schema.String,
Schema.Literals([
"gpt-6-astra",
"gpt-6.1-sol",
"gpt-6-sol",
"gpt-6-luna",
"gpt-5.6-sol",
"gpt-5.6-terra",
"gpt-5.6-luna",
"gpt-5.5",
"gpt-5.5-2026-04-23",
"gpt-5.4",
"gpt-5.4-mini",
"gpt-5.4-nano",
"gpt-5.4-mini-2026-03-17",
"gpt-5.4-nano-2026-03-17",
"gpt-5.3-chat-latest",
"gpt-5.2",
"gpt-5.2-2025-12-11",
"gpt-5.2-chat-latest",
"gpt-5.2-pro",
"gpt-5.2-pro-2025-12-11",
"gpt-5.1",
"gpt-5.1-2025-11-13",
"gpt-5.1-codex",
"gpt-5.1-mini",
"gpt-5.1-chat-latest",
"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-5-chat-latest",
"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",
"o4-mini",
"o4-mini-2025-04-16",
"o3",
"o3-2025-04-16",
"o3-mini",
"o3-mini-2025-01-31",
"o1",
"o1-2024-12-17",
"o1-preview",
"o1-preview-2024-09-12",
"o1-mini",
"o1-mini-2024-09-12",
"gpt-4o",
"gpt-4o-2024-11-20",
"gpt-4o-2024-08-06",
"gpt-4o-2024-05-13",
"gpt-audio-mini",
"gpt-audio-mini-2025-12-15",
"gpt-4o-audio-preview",
"gpt-4o-audio-preview-2024-10-01",
"gpt-4o-audio-preview-2024-12-17",
"gpt-4o-audio-preview-2025-06-03",
"gpt-4o-mini-audio-preview",
"gpt-4o-mini-audio-preview-2024-12-17",
"gpt-4o-search-preview",
"gpt-4o-mini-search-preview",
"gpt-4o-search-preview-2025-03-11",
"gpt-4o-mini-search-preview-2025-03-11",
"chatgpt-4o-latest",
"codex-mini-latest",
"gpt-4o-mini",
"gpt-4o-mini-2024-07-18",
"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-0301",
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo-1106",
"gpt-3.5-turbo-0125",
"gpt-3.5-turbo-16k-0613"
])
]).annotate({ "identifier": "ModelIdsShared" })
export type ResponseModalities = ReadonlyArray<"text" | "audio"> | null
export const ResponseModalities = Schema.Union([
Schema.Array(Schema.Literals(["text", "audio"])).annotate({
"description":
"Output types that you would like the model to generate.\nMost models are capable of generating text, which is the default:\n\n`[\"text\"]`\n\nThe `gpt-4o-audio-preview` model can also be used to\n[generate audio](https://developers.openai.com/api/docs/guides/audio). To request that this model generate\nboth text and audio responses, you can use:\n\n`[\"text\", \"audio\"]`\n"
}),
Schema.Null
]).annotate({ "identifier": "ResponseModalities" })
export type Verbosity = "low" | "medium" | "high" | null
export const Verbosity = Schema.Union([
Schema.Literals(["low", "medium", "high"]).annotate({
"description":
"Constrains the verbosity of the model's response. Lower values will result in\nmore concise responses, while higher values will result in more verbose responses.\nCurrently supported values are `low`, `medium`, and `high`. The default is\n`medium`.\n"
}),
Schema.Null
]).annotate({ "identifier": "Verbosity" })
export type WebSearchLocation = {
readonly "country"?: string
readonly "region"?: string
readonly "city"?: string
readonly "timezone"?: string
}
export const WebSearchLocation = Schema.Struct({
"country": Schema.optionalKey(
Schema.String.annotate({
"description":
"The two-letter \n[ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user,\ne.g. `US`.\n"
})
),
"region": Schema.optionalKey(
Schema.String.annotate({ "description": "Free text input for the region of the user, e.g. `California`.\n" })
),
"city": Schema.optionalKey(
Schema.String.annotate({ "description": "Free text input for the city of the user, e.g. `San Francisco`.\n" })
),
"timezone": Schema.optionalKey(
Schema.String.annotate({
"description":
"The [IANA timezone](https://timeapi.io/documentation/iana-timezones) \nof the user, e.g. `America/Los_Angeles`.\n"
})
)
}).annotate({
"title": "Web search location",
"description": "Approximate location parameters for the search.",
"identifier": "WebSearchLocation"
})
export type WebSearchContextSize = "low" | "medium" | "high"
export const WebSearchContextSize = Schema.Literals(["low", "medium", "high"]).annotate({
"description":
"High level guidance for the amount of context window space to use for the \nsearch. One of `low`, `medium`, or `high`. `medium` is the default.\n",
"identifier": "WebSearchContextSize"
})
export type ModerationMode = "score" | "block"
export const ModerationMode = Schema.Literals(["score", "block"]).annotate({ "identifier": "ModerationMode" })
export type StopConfiguration = string | ReadonlyArray<string> | null
export const StopConfiguration = Schema.Union([
Schema.String,
Schema.Array(Schema.String).check(
Schema.isMinLength(1).annotate({ "expected": "a value with a length of at least 1" })
).check(Schema.isMaxLength(4).annotate({ "expected": "a value with a length of at most 4" })),
Schema.Null
], { mode: "oneOf" }).annotate({
"description":
"Not supported with latest reasoning models `o3` and `o4-mini`.\n\nUp to 4 sequences where the API will stop generating further tokens. The\nreturned text will not contain the stop sequence.\n",
"identifier": "StopConfiguration"
})
export type ChatCompletionStreamOptions = {
readonly "include_usage"?: boolean
readonly "include_obfuscation"?: boolean
} | null
export const ChatCompletionStreamOptions = Schema.Union([
Schema.Struct({
"include_usage": Schema.optionalKey(Schema.Boolean.annotate({
"description":
"If set, an additional chunk will be streamed before the `data: [DONE]`\nmessage. The `usage` field on this chunk shows the token usage statistics\nfor the entire request, and the `choices` field will always be an empty\narray.\n\nAll other chunks will also include a `usage` field, but with a null\nvalue. **NOTE:** If the stream is interrupted, you may not receive the\nfinal usage chunk which contains the total token usage for the request.\n"
})),
"include_obfuscation": Schema.optionalKey(Schema.Boolean.annotate({
"description":
"When true, stream obfuscation will be enabled. Stream obfuscation adds\nrandom characters to an `obfuscation` field on streaming delta events to\nnormalize payload sizes as a mitigation to certain side-channel attacks.\nThese obfuscation fields are included by default, but add a small amount\nof overhead to the data stream. You can set `include_obfuscation` to\nfalse to optimize for bandwidth if you trust the network links between\nyour application and the OpenAI API.\n"
}))
}).annotate({ "description": "Options for streaming response. Only set this when you set `stream: true`.\n" }),
Schema.Null
]).annotate({ "identifier": "ChatCompletionStreamOptions" })
export type CustomToolChatCompletions = {
readonly "type": "custom"
readonly "custom": {
readonly "name": string
readonly "description"?: string
readonly "format"?: { readonly "type": "text" } | {
readonly "type": "grammar"
readonly "grammar": { readonly "definition": string; readonly "syntax": "lark" | "regex" }
}
}
}
export const CustomToolChatCompletions = Schema.Struct({
"type": Schema.Literal("custom").annotate({ "description": "The type of the custom tool. Always `custom`." }),
"custom": Schema.Struct({
"name": Schema.String.annotate({
"description": "The name of the custom tool, used to identify it in tool calls."
}),
"description": Schema.optionalKey(
Schema.String.annotate({
"description": "Optional description of the custom tool, used to provide more context.\n"
})
),
"format": Schema.optionalKey(
Schema.Union([
Schema.Struct({
"type": Schema.Literal("text").annotate({ "description": "Unconstrained text format. Always `text`." })
}).annotate({ "title": "Text format", "description": "Unconstrained free-form text." }),
Schema.Struct({
"type": Schema.Literal("grammar").annotate({ "description": "Grammar format. Always `grammar`." }),
"grammar": Schema.Struct({
"definition": Schema.String.annotate({ "description": "The grammar definition." }),
"syntax": Schema.Literals(["lark", "regex"]).annotate({
"description": "The syntax of the grammar definition. One of `lark` or `regex`."
})
}).annotate({ "title": "Grammar format", "description": "Your chosen grammar." })
}).annotate({ "title": "Grammar format", "description": "A grammar defined by the user." })
], { mode: "oneOf" }).annotate({
"description": "The input format for the custom tool. Default is unconstrained text.\n"
})
)
}).annotate({ "title": "Custom tool properties", "description": "Properties of the custom tool.\n" })
}).annotate({
"title": "Custom tool",
"description": "A custom tool that processes input using a specified format.\n",
"identifier": "CustomToolChatCompletions"
})
export type ChatCompletionAllowedTools = {
readonly "mode": "auto" | "required"
readonly "tools": ReadonlyArray<{ readonly [x: string]: Schema.Json }>
}
export const ChatCompletionAllowedTools = Schema.Struct({
"mode": Schema.Literals(["auto", "required"]).annotate({
"description":
"Constrains the tools available to the model to a pre-defined set.\n\n`auto` allows the model to pick from among the allowed tools and generate a\nmessage.\n\n`required` requires the model to call one or more of the allowed tools.\n"
}),
"tools": Schema.Array(
Schema.Record(Schema.String, Schema.Json.annotate({ "expected": "JSON value" })).annotate({
"description": "A tool definition that the model should be allowed to call.\n"
})
).annotate({
"description":
"A list of tool definitions that the model should be allowed to call.\n\nFor the Chat Completions API, the list of tool definitions might look like:\n```json\n[\n { \"type\": \"function\", \"function\": { \"name\": \"get_weather\" } },\n { \"type\": \"function\", \"function\": { \"name\": \"get_time\" } }\n]\n```\n"
})
}).annotate({
"title": "Allowed tools",
"description": "Constrains the tools available to the model to a pre-defined set.\n",
"identifier": "ChatCompletionAllowedTools"
})
export type ChatCompletionNamedToolChoice = {
readonly "type": "function"
readonly "function": { readonly "name": string }
}
export const ChatCompletionNamedToolChoice = Schema.Struct({
"type": Schema.Literal("function").annotate({
"description": "For function calling, the type is always `function`."
}),
"function": Schema.Struct({ "name": Schema.String.annotate({ "description": "The name of the function to call." }) })
}).annotate({
"title": "Function tool choice",
"description": "Specifies a tool the model should use. Use to force the model to call a specific function.",
"identifier": "ChatCompletionNamedToolChoice"
})
export type ChatCompletionNamedToolChoiceCustom = {
readonly "type": "custom"
readonly "custom": { readonly "name": string }
}
export const ChatCompletionNamedToolChoiceCustom = Schema.Struct({
"type": Schema.Literal("custom").annotate({ "description": "For custom tool calling, the type is always `custom`." }),
"custom": Schema.Struct({
"name": Schema.String.annotate({ "description": "The name of the custom tool to call." })
})
}).annotate({
"title": "Custom tool choice",
"description": "Specifies a tool the model should use. Use to force the model to call a specific custom tool.",
"identifier": "ChatCompletionNamedToolChoiceCustom"
})
export type ParallelToolCalls = boolean
export const ParallelToolCalls = Schema.Boolean.annotate({
"description":
"Whether to enable [parallel function calling](https://developers.openai.com/api/docs/guides/function-calling#parallel-function-calling) during tool use.",
"identifier": "ParallelToolCalls"
})
export type ChatCompletionFunctionCallOption = { readonly "name": string }
export const ChatCompletionFunctionCallOption = Schema.Struct({
"name": Schema.String.annotate({ "description": "The name of the function to call." })
}).annotate({
"description":
"Specifying a particular function via `{\"name\": \"my_function\"}` forces the model to call that function.\n",
"identifier": "ChatCompletionFunctionCallOption"
})
export type ChatCompletionMessageToolCallChunk = {
readonly "index": number
readonly "id"?: string
readonly "type"?: "function"
readonly "function"?: { readonly "name"?: string; readonly "arguments"?: string }
}
export const ChatCompletionMessageToolCallChunk = Schema.Struct({
"index": Schema.Number.check(Schema.isInt().annotate({ "expected": "an integer" })),
"id": Schema.optionalKey(Schema.String.annotate({ "description": "The ID of the tool call." })),
"type": Schema.optionalKey(
Schema.Literal("function").annotate({
"description": "The type of the tool. Currently, only `function` is supported."
})
),
"function": Schema.optionalKey(Schema.Struct({
"name": Schema.optionalKey(Schema.String.annotate({ "description": "The name of the function to call." })),
"arguments": Schema.optionalKey(Schema.String.annotate({
"description":
"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."
}))
}))
}).annotate({ "identifier": "ChatCompletionMessageToolCallChunk" })
export type ChatCompletionDeleted = {
readonly "object": "chat.completion.deleted"
readonly "id": string
readonly "deleted": boolean
}
export const ChatCompletionDeleted = Schema.Struct({
"object": Schema.Literal("chat.completion.deleted").annotate({ "description": "The type of object being deleted." }),
"id": Schema.String.annotate({ "description": "The ID of the chat completion that was deleted." }),
"deleted": Schema.Boolean.annotate({ "description": "Whether the chat completion was deleted." })
}).annotate({ "identifier": "ChatCompletionDeleted" })
export type ChatCompletionMessageList = {
readonly "object": "list"
readonly "data": ReadonlyArray<
{
readonly "id": string
readonly "role": "user" | "assistant" | "tool" | "system" | "function" | "developer"
readonly "content": string | null
readonly "content_parts":
| ReadonlyArray<
{
readonly "type": "text" | "image_url" | "input_audio" | "file"
readonly "text"?: string | null
readonly "image_url"?: { readonly "url": string; readonly "detail"?: string | null } | null
readonly "input_audio"?: { readonly "data": string; readonly "format": string } | null
readonly "file"?: {
readonly "file_data"?: string | null
readonly "filename"?: string | null
readonly "file_id"?: string | null
} | null
}
>
| null
readonly "name"?: string | null
}
>
readonly "first_id": string | null
readonly "last_id": string | null
readonly "has_more": boolean
}
export const ChatCompletionMessageList = Schema.Struct({
"object": Schema.Literal("list").annotate({
"description": "The type of this object. It is always set to \"list\".\n"
}),
"data": Schema.Array(Schema.Struct({
"id": Schema.String,
"role": Schema.Literals(["user", "assistant", "tool", "system", "function", "developer"]),
"content": Schema.Union([Schema.String, Schema.Null]),
"content_parts": Schema.Union([
Schema.Array(Schema.Struct({
"type": Schema.Literals(["text", "image_url", "input_audio", "file"]),
"text": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
"image_url": Schema.optionalKey(
Schema.Union([
Schema.Struct({
"url": Schema.String,
"detail": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]))
}),
Schema.Null
])
),
"input_audio": Schema.optionalKey(
Schema.Union([Schema.Struct({ "data": Schema.String, "format": Schema.String }), Schema.Null])
),
"file": Schema.optionalKey(
Schema.Union([
Schema.Struct({
"file_data": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
"filename": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null])),
"file_id": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]))
}),
Schema.Null
])
)
})),
Schema.Null
]),
"name": Schema.optionalKey(Schema.Union([Schema.String, Schema.Null]))
})).annotate({ "description": "An array of chat completion message objects.\n" }),
"first_id": Schema.Union([Schema.String, Schema.Null]).annotate({
"description": "The identifier of the first chat message in the data array."
}),
"last_id": Schema.Union([Schema.String, Schema.Null]).annotate({
"description": "The identifier of the last chat message in the data array."
}),
"has_more": Schema.Boolean.annotate({ "description": "Indicates whether there are more chat messages available." })
}).annotate({
"title": "ChatCompletionMessageList",
"description": "An object representing a list of chat completion messages.\n",
"identifier": "ChatCompletionMessageList"
})
export type ContainerResource = {
readonly "id": string
readonly "object": string
readonly "name": string
readonly "created_at": number
readonly "status": string
readonly "last_active_at"?: number
readonly "expires_after"?: { readonly "anchor"?: "last_active_at"; readonly "minutes"?: number }
readonly "memory_limit"?: "1g" | "4g" | "16g" | "64g"
readonly "network_policy"?: {
readonly "type": "allowlist" | "disabled"
readonly "allowed_domains"?: ReadonlyArray<string>
}
}
export const ContainerResource = Schema.Struct({
"id": Schema.String.annotate({ "description": "Unique identifier for the container." }),
"object": Schema.String.annotate({ "description": "The type of this object." }),
"name": Schema.String.annotate({ "description": "Name of the container." }),
"created_at": Schema.Number.annotate({
"description": "Unix timestamp (in seconds) when the container was created.",
"format": "unixtime"
}).check(Schema.isInt().annotate({ "expected": "an integer" })),
"status": Schema.String.annotate({ "description": "Status of the container (e.g., active, deleted)." }),
"last_active_at": Schema.optionalKey(
Schema.Number.annotate({
"description": "Unix timestamp (in seconds) when the container was last active.",
"format": "unixtime"
}).check(Schema.isInt().annotate({ "expected": "an integer" }))
),
"expires_after": Schema.optionalKey(
Schema.Struct({
"anchor": Schema.optionalKey(
Schema.Literal("last_active_at").annotate({ "description": "The reference point for the expiration." })
),
"minutes": Schema.optionalKey(
Schema.Number.annotate({
"description": "The number of minutes after the anchor before the container expires."
}).check(Schema.isInt().annotate({ "expected": "an integer" }))
)
}).annotate({
"description":
"The container will expire after this time period.\nThe anchor is the reference point for the expiration.\nThe minutes is the number of minutes after the anchor before the container expires.\n"
})
),
"memory_limit": Schema.optionalKey(
Schema.Literals(["1g", "4g", "16g", "64g"]).annotate({
"description": "The memory limit configured for the container."
})
),
"network_policy": Schema.optionalKey(
Schema.Struct({
"type": Schema.Literals(["allowlist", "disabled"]).annotate({ "description": "The network policy mode." }),
"allowed_domains": Schema.optionalKey(