@songtonyli/dsh-cli 0.1.56 → 0.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/package.json +6 -6
- package/node_modules/@aws-sdk/token-providers/package.json +6 -6
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-llm-pi-ai/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-llm-pi-ai/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-llm-pi-ai/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-llm-pi-ai/lib/index.js +1 -182
- package/node_modules/@deepseek-ai/dsh-llm-pi-ai/package.json +1 -1
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +1 -1
- package/node_modules/@earendil-works/pi-ai/README.md +207 -27
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +6 -5
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-workers-ai-system-one.js +43 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-workers-ai-system-one.lazy.js +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/llama-cpp-classify.js +365 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/llama-cpp-classify.lazy.js +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +18 -17
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +20 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +4 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +14 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +26 -9
- package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +2 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.js +183 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.js +19 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.lazy.js +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js +19 -128
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/callback-server.js +146 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-chatgpt.js +266 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js +20 -124
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js +19 -138
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js +21 -89
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +3 -19
- package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/cli.js +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.js +14 -13
- package/node_modules/@earendil-works/pi-ai/dist/images.js +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.js +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/model-catalog.js +14 -2
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +131 -41
- package/node_modules/@earendil-works/pi-ai/dist/models.js +157 -30
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +25 -21
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/baseten.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-stream.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.js +10 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/ant-ling.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/deepseek.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/typesafe.json +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/meta.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.js +11 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.js +5 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +11 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/radius.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/typesafe.js +18 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/typesafe.models.js +8 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.js +5 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/utils/headers.js +10 -8
- package/node_modules/@earendil-works/pi-ai/dist/utils/model-operations.js +47 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/models-error.js +19 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +7 -0
- package/node_modules/@earendil-works/pi-ai/package.json +4 -4
- package/node_modules/@earendil-works/pi-telemetry/package.json +2 -2
- package/node_modules/openai/CHANGELOG.md +1089 -1
- package/node_modules/openai/README.md +201 -102
- package/node_modules/openai/_vendor/partial-json-parser/parser.js +55 -38
- package/node_modules/openai/_vendor/partial-json-parser/parser.mjs +55 -38
- package/node_modules/openai/_vendor/zod-to-json-schema/Options.js +11 -2
- package/node_modules/openai/_vendor/zod-to-json-schema/Options.mjs +11 -2
- package/node_modules/openai/_vendor/zod-to-json-schema/Refs.js +4 -4
- package/node_modules/openai/_vendor/zod-to-json-schema/Refs.mjs +4 -4
- package/node_modules/openai/_vendor/zod-to-json-schema/errorMessages.js +2 -1
- package/node_modules/openai/_vendor/zod-to-json-schema/errorMessages.mjs +2 -1
- package/node_modules/openai/_vendor/zod-to-json-schema/index.js +1 -1
- package/node_modules/openai/_vendor/zod-to-json-schema/index.mjs +1 -1
- package/node_modules/openai/_vendor/zod-to-json-schema/parseDef.js +139 -54
- package/node_modules/openai/_vendor/zod-to-json-schema/parseDef.mjs +139 -54
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/array.js +1 -1
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/array.mjs +1 -1
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/bigint.js +10 -4
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/bigint.mjs +10 -4
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/branded.js +2 -2
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/branded.mjs +2 -2
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/catch.js +1 -3
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/catch.mjs +1 -3
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/date.js +10 -5
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/date.mjs +10 -5
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/default.js +2 -2
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/default.mjs +2 -2
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/intersection.js +6 -5
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/intersection.mjs +6 -5
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/literal.js +5 -0
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/literal.mjs +5 -0
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nativeEnum.js +7 -9
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nativeEnum.mjs +7 -9
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/null.js +3 -2
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/null.mjs +3 -2
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nullable.js +8 -3
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nullable.mjs +8 -3
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/number.js +12 -5
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/number.mjs +12 -5
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/object.js +43 -38
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/object.mjs +43 -38
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/optional.js +11 -12
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/optional.mjs +11 -12
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/pipeline.js +3 -3
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/pipeline.mjs +3 -3
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/promise.js +2 -2
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/promise.mjs +2 -2
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/readonly.js +1 -3
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/readonly.mjs +1 -3
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/record.js +7 -5
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/record.mjs +7 -5
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/string.js +57 -34
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/string.mjs +57 -34
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/tuple.js +24 -19
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/tuple.mjs +24 -19
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/union.js +46 -24
- package/node_modules/openai/_vendor/zod-to-json-schema/parsers/union.mjs +46 -24
- package/node_modules/openai/_vendor/zod-to-json-schema/util.js +7 -5
- package/node_modules/openai/_vendor/zod-to-json-schema/util.mjs +7 -5
- package/node_modules/openai/_vendor/zod-to-json-schema/zodToJsonSchema.js +110 -38
- package/node_modules/openai/_vendor/zod-to-json-schema/zodToJsonSchema.mjs +110 -38
- package/node_modules/openai/auth/subject-token-providers.js +235 -10
- package/node_modules/openai/auth/subject-token-providers.mjs +235 -10
- package/node_modules/openai/auth/workload-identity-auth.js +185 -24
- package/node_modules/openai/auth/workload-identity-auth.mjs +186 -25
- package/node_modules/openai/auth/x509-transport.js +273 -0
- package/node_modules/openai/auth/x509-transport.mjs +268 -0
- package/node_modules/openai/azure.js +74 -21
- package/node_modules/openai/azure.mjs +75 -22
- package/node_modules/openai/bedrock.js +174 -0
- package/node_modules/openai/bedrock.mjs +169 -0
- package/node_modules/openai/beta/realtime/internal-base.js +71 -10
- package/node_modules/openai/beta/realtime/internal-base.mjs +70 -10
- package/node_modules/openai/beta/realtime/websocket.js +180 -33
- package/node_modules/openai/beta/realtime/websocket.mjs +181 -34
- package/node_modules/openai/beta/realtime/ws.js +93 -14
- package/node_modules/openai/beta/realtime/ws.mjs +94 -15
- package/node_modules/openai/client.js +745 -99
- package/node_modules/openai/client.mjs +747 -101
- package/node_modules/openai/core/EventEmitter.js +127 -16
- package/node_modules/openai/core/EventEmitter.mjs +128 -17
- package/node_modules/openai/core/api-promise.js +0 -1
- package/node_modules/openai/core/api-promise.mjs +0 -1
- package/node_modules/openai/core/error.js +5 -5
- package/node_modules/openai/core/error.mjs +5 -5
- package/node_modules/openai/core/pagination.js +33 -3
- package/node_modules/openai/core/pagination.mjs +31 -2
- package/node_modules/openai/core/resource.js +0 -1
- package/node_modules/openai/core/resource.mjs +0 -1
- package/node_modules/openai/core/streaming.js +453 -88
- package/node_modules/openai/core/streaming.mjs +454 -89
- package/node_modules/openai/core/uploads.js +3 -1
- package/node_modules/openai/core/uploads.mjs +1 -0
- package/node_modules/openai/helpers/audio.js +198 -28
- package/node_modules/openai/helpers/audio.mjs +199 -29
- package/node_modules/openai/helpers/live.js +6 -0
- package/node_modules/openai/helpers/live.mjs +2 -0
- package/node_modules/openai/helpers/standard-schema.js +393 -0
- package/node_modules/openai/helpers/standard-schema.mjs +387 -0
- package/node_modules/openai/helpers/zod-v3-strict-schema.js +408 -0
- package/node_modules/openai/helpers/zod-v3-strict-schema.mjs +404 -0
- package/node_modules/openai/helpers/zod.js +221 -24
- package/node_modules/openai/helpers/zod.mjs +222 -26
- package/node_modules/openai/index.js +8 -7
- package/node_modules/openai/index.mjs +2 -2
- package/node_modules/openai/internal/assistant-stream-delta.js +316 -0
- package/node_modules/openai/internal/assistant-stream-delta.mjs +308 -0
- package/node_modules/openai/internal/auth/x509-api-origin.js +28 -0
- package/node_modules/openai/internal/auth/x509-api-origin.mjs +24 -0
- package/node_modules/openai/internal/auth/x509-credential-options.js +125 -0
- package/node_modules/openai/internal/auth/x509-credential-options.mjs +121 -0
- package/node_modules/openai/internal/auth/x509-token-exchange.js +248 -0
- package/node_modules/openai/internal/auth/x509-token-exchange.mjs +245 -0
- package/node_modules/openai/internal/auth/x509-transport-capability.js +171 -0
- package/node_modules/openai/internal/auth/x509-transport-capability.mjs +166 -0
- package/node_modules/openai/internal/auth/x509-transport-registry.js +53 -0
- package/node_modules/openai/internal/auth/x509-transport-registry.mjs +48 -0
- package/node_modules/openai/internal/auth/x509-transport-state-browser.js +35 -0
- package/node_modules/openai/internal/auth/x509-transport-state-browser.mjs +32 -0
- package/node_modules/openai/internal/auth/x509-transport-state.cjs +35 -0
- package/node_modules/openai/internal/auth/x509-transport-state.js +36 -0
- package/node_modules/openai/internal/auth/x509-transport-state.mjs +20 -0
- package/node_modules/openai/internal/auth/x509-workload-identity-auth.js +787 -0
- package/node_modules/openai/internal/auth/x509-workload-identity-auth.mjs +778 -0
- package/node_modules/openai/internal/bedrock.js +438 -0
- package/node_modules/openai/internal/bedrock.mjs +424 -0
- package/node_modules/openai/internal/builtin-types.js +0 -1
- package/node_modules/openai/internal/builtin-types.mjs +0 -1
- package/node_modules/openai/internal/data-residency.js +34 -0
- package/node_modules/openai/internal/data-residency.mjs +30 -0
- package/node_modules/openai/internal/decoders/line.js +140 -54
- package/node_modules/openai/internal/decoders/line.mjs +141 -55
- package/node_modules/openai/internal/detect-platform.js +3 -4
- package/node_modules/openai/internal/detect-platform.mjs +3 -4
- package/node_modules/openai/internal/errors.js +3 -3
- package/node_modules/openai/internal/errors.mjs +3 -3
- package/node_modules/openai/internal/headers.js +11 -9
- package/node_modules/openai/internal/headers.mjs +11 -9
- package/node_modules/openai/internal/multipart-encoding.js +51 -0
- package/node_modules/openai/internal/multipart-encoding.mjs +48 -0
- package/node_modules/openai/internal/parse.js +35 -11
- package/node_modules/openai/internal/parse.mjs +35 -11
- package/node_modules/openai/internal/provider.js +50 -0
- package/node_modules/openai/internal/provider.mjs +46 -0
- package/node_modules/openai/internal/qs/formats.js +1 -2
- package/node_modules/openai/internal/qs/formats.mjs +1 -1
- package/node_modules/openai/internal/qs/stringify.js +60 -51
- package/node_modules/openai/internal/qs/stringify.mjs +60 -51
- package/node_modules/openai/internal/qs/utils.js +368 -50
- package/node_modules/openai/internal/qs/utils.mjs +368 -50
- package/node_modules/openai/internal/realtime-credentials.js +23 -0
- package/node_modules/openai/internal/realtime-credentials.mjs +19 -0
- package/node_modules/openai/internal/request-options.js +43 -2
- package/node_modules/openai/internal/request-options.mjs +42 -2
- package/node_modules/openai/internal/responses/canonical-output-text.js +123 -0
- package/node_modules/openai/internal/responses/canonical-output-text.mjs +115 -0
- package/node_modules/openai/internal/responses/output-text-index.js +77 -0
- package/node_modules/openai/internal/responses/output-text-index.mjs +73 -0
- package/node_modules/openai/internal/responses/response-accumulator.js +942 -0
- package/node_modules/openai/internal/responses/response-accumulator.mjs +938 -0
- package/node_modules/openai/internal/shim-types.js +6 -1
- package/node_modules/openai/internal/shim-types.mjs +6 -1
- package/node_modules/openai/internal/shims.js +6 -1
- package/node_modules/openai/internal/shims.mjs +6 -1
- package/node_modules/openai/internal/stream-utils.js +35 -7
- package/node_modules/openai/internal/stream-utils.mjs +35 -7
- package/node_modules/openai/internal/to-file.js +47 -24
- package/node_modules/openai/internal/to-file.mjs +47 -24
- package/node_modules/openai/internal/tslib.js +6 -0
- package/node_modules/openai/internal/tslib.mjs +6 -1
- package/node_modules/openai/internal/types.js +0 -1
- package/node_modules/openai/internal/types.mjs +0 -1
- package/node_modules/openai/internal/uploads.js +377 -43
- package/node_modules/openai/internal/uploads.mjs +376 -44
- package/node_modules/openai/internal/utils/abort.js +94 -0
- package/node_modules/openai/internal/utils/abort.mjs +90 -0
- package/node_modules/openai/internal/utils/base64.js +3 -1
- package/node_modules/openai/internal/utils/base64.mjs +3 -1
- package/node_modules/openai/internal/utils/bytes.js +5 -0
- package/node_modules/openai/internal/utils/bytes.mjs +5 -0
- package/node_modules/openai/internal/utils/env.js +9 -5
- package/node_modules/openai/internal/utils/env.mjs +9 -5
- package/node_modules/openai/internal/utils/log.js +73 -11
- package/node_modules/openai/internal/utils/log.mjs +70 -11
- package/node_modules/openai/internal/utils/path.js +50 -30
- package/node_modules/openai/internal/utils/path.mjs +50 -30
- package/node_modules/openai/internal/utils/query.js +0 -1
- package/node_modules/openai/internal/utils/query.mjs +0 -1
- package/node_modules/openai/internal/utils/sleep.js +51 -2
- package/node_modules/openai/internal/utils/sleep.mjs +51 -2
- package/node_modules/openai/internal/utils/uuid.js +0 -1
- package/node_modules/openai/internal/utils/uuid.mjs +0 -1
- package/node_modules/openai/internal/utils/values.js +0 -1
- package/node_modules/openai/internal/utils/values.mjs +0 -1
- package/node_modules/openai/internal/utils.js +0 -1
- package/node_modules/openai/internal/utils.mjs +0 -1
- package/node_modules/openai/internal/ws-adapter-browser.js +66 -21
- package/node_modules/openai/internal/ws-adapter-browser.mjs +66 -21
- package/node_modules/openai/internal/ws-adapter-node.js +90 -24
- package/node_modules/openai/internal/ws-adapter-node.mjs +90 -24
- package/node_modules/openai/internal/ws-adapter.js +4 -0
- package/node_modules/openai/internal/ws-adapter.mjs +4 -0
- package/node_modules/openai/internal/ws.js +193 -48
- package/node_modules/openai/internal/ws.mjs +188 -49
- package/node_modules/openai/lib/AbstractChatCompletionRunner.js +254 -72
- package/node_modules/openai/lib/AbstractChatCompletionRunner.mjs +256 -74
- package/node_modules/openai/lib/AssistantStream.js +430 -259
- package/node_modules/openai/lib/AssistantStream.mjs +432 -261
- package/node_modules/openai/lib/ChatCompletionRunner.js +12 -5
- package/node_modules/openai/lib/ChatCompletionRunner.mjs +13 -6
- package/node_modules/openai/lib/ChatCompletionStream.js +1430 -189
- package/node_modules/openai/lib/ChatCompletionStream.mjs +1433 -193
- package/node_modules/openai/lib/ChatCompletionStreamingRunner.js +40 -2
- package/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs +41 -3
- package/node_modules/openai/lib/EventEmitter.js +124 -16
- package/node_modules/openai/lib/EventEmitter.mjs +125 -17
- package/node_modules/openai/lib/EventStream.js +1533 -55
- package/node_modules/openai/lib/EventStream.mjs +1534 -56
- package/node_modules/openai/lib/ResponsesParser.js +68 -29
- package/node_modules/openai/lib/ResponsesParser.mjs +69 -30
- package/node_modules/openai/lib/RunnableFunction.js +3 -0
- package/node_modules/openai/lib/RunnableFunction.mjs +3 -0
- package/node_modules/openai/lib/Util.js +7 -4
- package/node_modules/openai/lib/Util.mjs +7 -4
- package/node_modules/openai/lib/agents/agent-session-stream.js +274 -0
- package/node_modules/openai/lib/agents/agent-session-stream.mjs +270 -0
- package/node_modules/openai/lib/agents/output-text.js +8 -0
- package/node_modules/openai/lib/agents/output-text.mjs +5 -0
- package/node_modules/openai/lib/agents/turn-state.js +62 -0
- package/node_modules/openai/lib/agents/turn-state.mjs +58 -0
- package/node_modules/openai/lib/assistant-run-polling.js +17 -0
- package/node_modules/openai/lib/assistant-run-polling.mjs +14 -0
- package/node_modules/openai/lib/chatCompletionUtils.js +5 -6
- package/node_modules/openai/lib/chatCompletionUtils.mjs +5 -6
- package/node_modules/openai/lib/embeddings.js +58 -0
- package/node_modules/openai/lib/embeddings.mjs +55 -0
- package/node_modules/openai/lib/file-processing.js +31 -0
- package/node_modules/openai/lib/file-processing.mjs +28 -0
- package/node_modules/openai/lib/live/transcript-grouper.js +229 -0
- package/node_modules/openai/lib/live/transcript-grouper.mjs +225 -0
- package/node_modules/openai/lib/live/transcript-grouping.js +309 -0
- package/node_modules/openai/lib/live/transcript-grouping.mjs +305 -0
- package/node_modules/openai/lib/live/webrtc.js +16 -0
- package/node_modules/openai/lib/live/webrtc.mjs +10 -0
- package/node_modules/openai/lib/parser.js +142 -42
- package/node_modules/openai/lib/parser.mjs +140 -42
- package/node_modules/openai/lib/polling.js +131 -0
- package/node_modules/openai/lib/polling.mjs +128 -0
- package/node_modules/openai/lib/realtime/webrtc.js +16 -0
- package/node_modules/openai/lib/realtime/webrtc.mjs +10 -0
- package/node_modules/openai/lib/responses/ResponseAccumulator.js +15 -0
- package/node_modules/openai/lib/responses/ResponseAccumulator.mjs +12 -0
- package/node_modules/openai/lib/responses/ResponseInputItems.js +139 -0
- package/node_modules/openai/lib/responses/ResponseInputItems.mjs +135 -0
- package/node_modules/openai/lib/responses/ResponseStream.js +85 -159
- package/node_modules/openai/lib/responses/ResponseStream.mjs +86 -160
- package/node_modules/openai/lib/responses/responses-websocket-lane.js +314 -0
- package/node_modules/openai/lib/responses/responses-websocket-lane.mjs +309 -0
- package/node_modules/openai/lib/responses/responses-websocket-session.js +268 -0
- package/node_modules/openai/lib/responses/responses-websocket-session.mjs +263 -0
- package/node_modules/openai/lib/transform.js +1608 -82
- package/node_modules/openai/lib/transform.mjs +1602 -82
- package/node_modules/openai/lib/vector-store-polling.js +24 -0
- package/node_modules/openai/lib/vector-store-polling.mjs +20 -0
- package/node_modules/openai/lib/vector-store-upload.js +41 -0
- package/node_modules/openai/lib/vector-store-upload.mjs +38 -0
- package/node_modules/openai/lib/webhook-signature.js +125 -0
- package/node_modules/openai/lib/webhook-signature.mjs +121 -0
- package/node_modules/openai/lib/webrtc/connection.js +233 -0
- package/node_modules/openai/lib/webrtc/connection.mjs +229 -0
- package/node_modules/openai/lib/webrtc/data-channel.js +133 -0
- package/node_modules/openai/lib/webrtc/data-channel.mjs +129 -0
- package/node_modules/openai/lib/webrtc/errors.js +18 -0
- package/node_modules/openai/lib/webrtc/errors.mjs +14 -0
- package/node_modules/openai/lib/webrtc/subscriptions.js +64 -0
- package/node_modules/openai/lib/webrtc/subscriptions.mjs +60 -0
- package/node_modules/openai/lib/webrtc/types.js +3 -0
- package/node_modules/openai/lib/webrtc/types.mjs +2 -0
- package/node_modules/openai/live/webrtc.js +8 -0
- package/node_modules/openai/live/webrtc.mjs +2 -0
- package/node_modules/openai/package.json +71 -11
- package/node_modules/openai/providers/bedrock/aws.js +211 -0
- package/node_modules/openai/providers/bedrock/aws.mjs +207 -0
- package/node_modules/openai/providers/bedrock.js +43 -0
- package/node_modules/openai/providers/bedrock.mjs +39 -0
- package/node_modules/openai/realtime/internal-base.js +118 -11
- package/node_modules/openai/realtime/internal-base.mjs +116 -11
- package/node_modules/openai/realtime/webrtc.js +8 -0
- package/node_modules/openai/realtime/webrtc.mjs +2 -0
- package/node_modules/openai/realtime/websocket.js +174 -39
- package/node_modules/openai/realtime/websocket.mjs +175 -40
- package/node_modules/openai/realtime/ws.js +86 -18
- package/node_modules/openai/realtime/ws.mjs +87 -19
- package/node_modules/openai/resources/admin/admin.js +1 -1
- package/node_modules/openai/resources/admin/admin.mjs +1 -1
- package/node_modules/openai/resources/admin/index.js +1 -1
- package/node_modules/openai/resources/admin/index.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/admin-api-keys.js +1 -1
- package/node_modules/openai/resources/admin/organization/admin-api-keys.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/audit-logs.js +1 -1
- package/node_modules/openai/resources/admin/organization/audit-logs.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/certificates.js +1 -1
- package/node_modules/openai/resources/admin/organization/certificates.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/data-retention.js +1 -1
- package/node_modules/openai/resources/admin/organization/data-retention.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/groups/groups.js +1 -1
- package/node_modules/openai/resources/admin/organization/groups/groups.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/groups/index.js +1 -1
- package/node_modules/openai/resources/admin/organization/groups/index.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/groups/roles.js +1 -1
- package/node_modules/openai/resources/admin/organization/groups/roles.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/groups/users.js +1 -1
- package/node_modules/openai/resources/admin/organization/groups/users.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/groups.js +1 -1
- package/node_modules/openai/resources/admin/organization/groups.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/index.js +4 -2
- package/node_modules/openai/resources/admin/organization/index.mjs +2 -1
- package/node_modules/openai/resources/admin/organization/invites.js +1 -1
- package/node_modules/openai/resources/admin/organization/invites.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/organization.js +5 -1
- package/node_modules/openai/resources/admin/organization/organization.mjs +5 -1
- package/node_modules/openai/resources/admin/organization/projects/api-keys.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/api-keys.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/certificates.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/certificates.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/data-retention.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/data-retention.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/groups/groups.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/groups/index.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/groups/index.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/groups/roles.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/groups.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/groups.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/index.js +8 -6
- package/node_modules/openai/resources/admin/organization/projects/index.mjs +3 -2
- package/node_modules/openai/resources/admin/organization/projects/model-permissions.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/projects.js +7 -3
- package/node_modules/openai/resources/admin/organization/projects/projects.mjs +7 -3
- package/node_modules/openai/resources/admin/organization/projects/rate-limits.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/roles.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/roles.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/service-accounts/api-keys.js +26 -0
- package/node_modules/openai/resources/admin/organization/projects/service-accounts/api-keys.mjs +22 -0
- package/node_modules/openai/resources/admin/organization/projects/service-accounts/index.js +9 -0
- package/node_modules/openai/resources/admin/organization/projects/service-accounts/index.mjs +4 -0
- package/node_modules/openai/resources/admin/organization/projects/service-accounts/service-accounts.js +109 -0
- package/node_modules/openai/resources/admin/organization/projects/service-accounts/service-accounts.mjs +104 -0
- package/node_modules/openai/resources/admin/organization/projects/service-accounts.js +3 -98
- package/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs +2 -96
- package/node_modules/openai/resources/admin/organization/projects/spend-alerts.js +20 -1
- package/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs +20 -1
- package/node_modules/openai/resources/admin/organization/projects/spend-limit.js +67 -0
- package/node_modules/openai/resources/admin/organization/projects/spend-limit.mjs +63 -0
- package/node_modules/openai/resources/admin/organization/projects/users/index.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/users/index.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/users/roles.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/users/roles.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/users/users.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/users/users.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects/users.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects/users.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/projects.js +1 -1
- package/node_modules/openai/resources/admin/organization/projects.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/roles.js +1 -1
- package/node_modules/openai/resources/admin/organization/roles.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/spend-alerts.js +18 -1
- package/node_modules/openai/resources/admin/organization/spend-alerts.mjs +18 -1
- package/node_modules/openai/resources/admin/organization/spend-limit.js +59 -0
- package/node_modules/openai/resources/admin/organization/spend-limit.mjs +55 -0
- package/node_modules/openai/resources/admin/organization/usage.js +1 -1
- package/node_modules/openai/resources/admin/organization/usage.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/users/index.js +1 -1
- package/node_modules/openai/resources/admin/organization/users/index.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/users/roles.js +1 -1
- package/node_modules/openai/resources/admin/organization/users/roles.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/users/users.js +1 -1
- package/node_modules/openai/resources/admin/organization/users/users.mjs +1 -1
- package/node_modules/openai/resources/admin/organization/users.js +1 -1
- package/node_modules/openai/resources/admin/organization/users.mjs +1 -1
- package/node_modules/openai/resources/admin/organization.js +1 -1
- package/node_modules/openai/resources/admin/organization.mjs +1 -1
- package/node_modules/openai/resources/admin.js +1 -1
- package/node_modules/openai/resources/admin.mjs +1 -1
- package/node_modules/openai/resources/audio/audio.js +1 -1
- package/node_modules/openai/resources/audio/audio.mjs +1 -1
- package/node_modules/openai/resources/audio/index.js +1 -1
- package/node_modules/openai/resources/audio/index.mjs +1 -1
- package/node_modules/openai/resources/audio/speech.js +1 -1
- package/node_modules/openai/resources/audio/speech.mjs +1 -1
- package/node_modules/openai/resources/audio/transcriptions.js +1 -1
- package/node_modules/openai/resources/audio/transcriptions.mjs +1 -1
- package/node_modules/openai/resources/audio/translations.js +1 -1
- package/node_modules/openai/resources/audio/translations.mjs +1 -1
- package/node_modules/openai/resources/audio.js +1 -1
- package/node_modules/openai/resources/audio.mjs +1 -1
- package/node_modules/openai/resources/batches.js +1 -1
- package/node_modules/openai/resources/batches.mjs +1 -1
- package/node_modules/openai/resources/beta/agents/agents.js +118 -0
- package/node_modules/openai/resources/beta/agents/agents.mjs +113 -0
- package/node_modules/openai/resources/beta/agents/environments/environments.js +43 -0
- package/node_modules/openai/resources/beta/agents/environments/environments.mjs +38 -0
- package/node_modules/openai/resources/beta/agents/environments/files.js +61 -0
- package/node_modules/openai/resources/beta/agents/environments/files.mjs +57 -0
- package/node_modules/openai/resources/beta/agents/environments/index.js +11 -0
- package/node_modules/openai/resources/beta/agents/environments/index.mjs +5 -0
- package/node_modules/openai/resources/beta/agents/environments/templates.js +112 -0
- package/node_modules/openai/resources/beta/agents/environments/templates.mjs +108 -0
- package/node_modules/openai/resources/beta/agents/environments.js +6 -0
- package/node_modules/openai/resources/beta/agents/environments.mjs +3 -0
- package/node_modules/openai/resources/beta/agents/index.js +13 -0
- package/node_modules/openai/resources/beta/agents/index.mjs +6 -0
- package/node_modules/openai/resources/beta/agents/sessions/artifacts.js +106 -0
- package/node_modules/openai/resources/beta/agents/sessions/artifacts.mjs +102 -0
- package/node_modules/openai/resources/beta/agents/sessions/events.js +75 -0
- package/node_modules/openai/resources/beta/agents/sessions/events.mjs +71 -0
- package/node_modules/openai/resources/beta/agents/sessions/index.js +17 -0
- package/node_modules/openai/resources/beta/agents/sessions/index.mjs +8 -0
- package/node_modules/openai/resources/beta/agents/sessions/items.js +35 -0
- package/node_modules/openai/resources/beta/agents/sessions/items.mjs +31 -0
- package/node_modules/openai/resources/beta/agents/sessions/sessions.js +127 -0
- package/node_modules/openai/resources/beta/agents/sessions/sessions.mjs +122 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/index.js +11 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/index.mjs +5 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/items.js +36 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/items.mjs +32 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/subagents.js +67 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/subagents.mjs +62 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/turns/index.js +9 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/turns/index.mjs +4 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/turns/items.js +36 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/turns/items.mjs +32 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/turns/turns.js +68 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/turns/turns.mjs +63 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/turns.js +6 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents/turns.mjs +3 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents.js +6 -0
- package/node_modules/openai/resources/beta/agents/sessions/subagents.mjs +3 -0
- package/node_modules/openai/resources/beta/agents/sessions/turns.js +57 -0
- package/node_modules/openai/resources/beta/agents/sessions/turns.mjs +53 -0
- package/node_modules/openai/resources/beta/agents/sessions.js +6 -0
- package/node_modules/openai/resources/beta/agents/sessions.mjs +3 -0
- package/node_modules/openai/resources/beta/agents/vaults/credentials.js +132 -0
- package/node_modules/openai/resources/beta/agents/vaults/credentials.mjs +128 -0
- package/node_modules/openai/resources/beta/agents/vaults/index.js +9 -0
- package/node_modules/openai/resources/beta/agents/vaults/index.mjs +4 -0
- package/node_modules/openai/resources/beta/agents/vaults/vaults.js +93 -0
- package/node_modules/openai/resources/beta/agents/vaults/vaults.mjs +88 -0
- package/node_modules/openai/resources/beta/agents/vaults.js +6 -0
- package/node_modules/openai/resources/beta/agents/vaults.mjs +3 -0
- package/node_modules/openai/resources/beta/agents.js +6 -0
- package/node_modules/openai/resources/beta/agents.mjs +3 -0
- package/node_modules/openai/resources/beta/assistants.js +1 -1
- package/node_modules/openai/resources/beta/assistants.mjs +1 -1
- package/node_modules/openai/resources/beta/beta.js +9 -1
- package/node_modules/openai/resources/beta/beta.mjs +9 -1
- package/node_modules/openai/resources/beta/chatkit/chatkit.js +1 -1
- package/node_modules/openai/resources/beta/chatkit/chatkit.mjs +1 -1
- package/node_modules/openai/resources/beta/chatkit/index.js +1 -1
- package/node_modules/openai/resources/beta/chatkit/index.mjs +1 -1
- package/node_modules/openai/resources/beta/chatkit/sessions.js +1 -1
- package/node_modules/openai/resources/beta/chatkit/sessions.mjs +1 -1
- package/node_modules/openai/resources/beta/chatkit/threads.js +1 -1
- package/node_modules/openai/resources/beta/chatkit/threads.mjs +1 -1
- package/node_modules/openai/resources/beta/chatkit.js +1 -1
- package/node_modules/openai/resources/beta/chatkit.mjs +1 -1
- package/node_modules/openai/resources/beta/index.js +12 -8
- package/node_modules/openai/resources/beta/index.mjs +3 -1
- package/node_modules/openai/resources/beta/realtime/index.js +0 -1
- package/node_modules/openai/resources/beta/realtime/index.mjs +0 -1
- package/node_modules/openai/resources/beta/realtime/realtime.js +0 -1
- package/node_modules/openai/resources/beta/realtime/realtime.mjs +0 -1
- package/node_modules/openai/resources/beta/realtime/sessions.js +0 -1
- package/node_modules/openai/resources/beta/realtime/sessions.mjs +0 -1
- package/node_modules/openai/resources/beta/realtime/transcription-sessions.js +0 -1
- package/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs +0 -1
- package/node_modules/openai/resources/beta/realtime.js +0 -1
- package/node_modules/openai/resources/beta/realtime.mjs +0 -1
- package/node_modules/openai/resources/beta/responses/index.js +11 -0
- package/node_modules/openai/resources/beta/responses/index.mjs +5 -0
- package/node_modules/openai/resources/beta/responses/input-items.js +37 -0
- package/node_modules/openai/resources/beta/responses/input-items.mjs +33 -0
- package/node_modules/openai/resources/beta/responses/input-tokens.js +34 -0
- package/node_modules/openai/resources/beta/responses/input-tokens.mjs +30 -0
- package/node_modules/openai/resources/beta/responses/internal-base.js +66 -0
- package/node_modules/openai/resources/beta/responses/internal-base.mjs +60 -0
- package/node_modules/openai/resources/beta/responses/responses.js +121 -0
- package/node_modules/openai/resources/beta/responses/responses.mjs +116 -0
- package/node_modules/openai/resources/beta/responses/ws-base.js +566 -0
- package/node_modules/openai/resources/beta/responses/ws-base.mjs +560 -0
- package/node_modules/openai/resources/beta/responses/ws.js +47 -0
- package/node_modules/openai/resources/beta/responses/ws.mjs +42 -0
- package/node_modules/openai/resources/beta/responses.js +6 -0
- package/node_modules/openai/resources/beta/responses.mjs +3 -0
- package/node_modules/openai/resources/beta/threads/index.js +1 -1
- package/node_modules/openai/resources/beta/threads/index.mjs +1 -1
- package/node_modules/openai/resources/beta/threads/messages.js +1 -1
- package/node_modules/openai/resources/beta/threads/messages.mjs +1 -1
- package/node_modules/openai/resources/beta/threads/runs/index.js +1 -1
- package/node_modules/openai/resources/beta/threads/runs/index.mjs +1 -1
- package/node_modules/openai/resources/beta/threads/runs/runs.js +3 -44
- package/node_modules/openai/resources/beta/threads/runs/runs.mjs +3 -44
- package/node_modules/openai/resources/beta/threads/runs/steps.js +1 -1
- package/node_modules/openai/resources/beta/threads/runs/steps.mjs +1 -1
- package/node_modules/openai/resources/beta/threads/runs.js +1 -1
- package/node_modules/openai/resources/beta/threads/runs.mjs +1 -1
- package/node_modules/openai/resources/beta/threads/threads.js +1 -1
- package/node_modules/openai/resources/beta/threads/threads.mjs +1 -1
- package/node_modules/openai/resources/beta/threads.js +1 -1
- package/node_modules/openai/resources/beta/threads.mjs +1 -1
- package/node_modules/openai/resources/beta.js +1 -1
- package/node_modules/openai/resources/beta.mjs +1 -1
- package/node_modules/openai/resources/chat/chat.js +1 -1
- package/node_modules/openai/resources/chat/chat.mjs +1 -1
- package/node_modules/openai/resources/chat/completions/completions.js +2 -5
- package/node_modules/openai/resources/chat/completions/completions.mjs +2 -5
- package/node_modules/openai/resources/chat/completions/index.js +1 -1
- package/node_modules/openai/resources/chat/completions/index.mjs +1 -1
- package/node_modules/openai/resources/chat/completions/messages.js +1 -1
- package/node_modules/openai/resources/chat/completions/messages.mjs +1 -1
- package/node_modules/openai/resources/chat/completions.js +1 -1
- package/node_modules/openai/resources/chat/completions.mjs +1 -1
- package/node_modules/openai/resources/chat/index.js +1 -1
- package/node_modules/openai/resources/chat/index.mjs +1 -1
- package/node_modules/openai/resources/chat.js +1 -1
- package/node_modules/openai/resources/chat.mjs +1 -1
- package/node_modules/openai/resources/completions.js +1 -1
- package/node_modules/openai/resources/completions.mjs +1 -1
- package/node_modules/openai/resources/containers/containers.js +1 -1
- package/node_modules/openai/resources/containers/containers.mjs +1 -1
- package/node_modules/openai/resources/containers/files/content.js +1 -1
- package/node_modules/openai/resources/containers/files/content.mjs +1 -1
- package/node_modules/openai/resources/containers/files/files.js +1 -1
- package/node_modules/openai/resources/containers/files/files.mjs +1 -1
- package/node_modules/openai/resources/containers/files/index.js +1 -1
- package/node_modules/openai/resources/containers/files/index.mjs +1 -1
- package/node_modules/openai/resources/containers/files.js +1 -1
- package/node_modules/openai/resources/containers/files.mjs +1 -1
- package/node_modules/openai/resources/containers/index.js +1 -1
- package/node_modules/openai/resources/containers/index.mjs +1 -1
- package/node_modules/openai/resources/containers.js +1 -1
- package/node_modules/openai/resources/containers.mjs +1 -1
- package/node_modules/openai/resources/content-provenance-checks.js +24 -0
- package/node_modules/openai/resources/content-provenance-checks.mjs +20 -0
- package/node_modules/openai/resources/conversations/conversations.js +1 -1
- package/node_modules/openai/resources/conversations/conversations.mjs +1 -1
- package/node_modules/openai/resources/conversations/index.js +1 -1
- package/node_modules/openai/resources/conversations/index.mjs +1 -1
- package/node_modules/openai/resources/conversations/items.js +1 -1
- package/node_modules/openai/resources/conversations/items.mjs +1 -1
- package/node_modules/openai/resources/conversations.js +1 -1
- package/node_modules/openai/resources/conversations.mjs +1 -1
- package/node_modules/openai/resources/embeddings.js +3 -47
- package/node_modules/openai/resources/embeddings.mjs +3 -47
- package/node_modules/openai/resources/evals/evals.js +2 -2
- package/node_modules/openai/resources/evals/evals.mjs +2 -2
- package/node_modules/openai/resources/evals/index.js +1 -1
- package/node_modules/openai/resources/evals/index.mjs +1 -1
- package/node_modules/openai/resources/evals/runs/index.js +1 -1
- package/node_modules/openai/resources/evals/runs/index.mjs +1 -1
- package/node_modules/openai/resources/evals/runs/output-items.js +1 -1
- package/node_modules/openai/resources/evals/runs/output-items.mjs +1 -1
- package/node_modules/openai/resources/evals/runs/runs.js +1 -1
- package/node_modules/openai/resources/evals/runs/runs.mjs +1 -1
- package/node_modules/openai/resources/evals/runs.js +1 -1
- package/node_modules/openai/resources/evals/runs.mjs +1 -1
- package/node_modules/openai/resources/evals.js +1 -1
- package/node_modules/openai/resources/evals.mjs +1 -1
- package/node_modules/openai/resources/files.js +9 -22
- package/node_modules/openai/resources/files.mjs +9 -22
- package/node_modules/openai/resources/fine-tuning/alpha/alpha.js +1 -1
- package/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/alpha/graders.js +1 -1
- package/node_modules/openai/resources/fine-tuning/alpha/graders.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/alpha/index.js +1 -1
- package/node_modules/openai/resources/fine-tuning/alpha/index.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/alpha.js +1 -1
- package/node_modules/openai/resources/fine-tuning/alpha.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.js +1 -1
- package/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/checkpoints/index.js +1 -1
- package/node_modules/openai/resources/fine-tuning/checkpoints/index.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/checkpoints/permissions.js +9 -5
- package/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs +9 -5
- package/node_modules/openai/resources/fine-tuning/checkpoints.js +1 -1
- package/node_modules/openai/resources/fine-tuning/checkpoints.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/fine-tuning.js +1 -1
- package/node_modules/openai/resources/fine-tuning/fine-tuning.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/index.js +1 -1
- package/node_modules/openai/resources/fine-tuning/index.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/jobs/checkpoints.js +1 -1
- package/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/jobs/index.js +1 -1
- package/node_modules/openai/resources/fine-tuning/jobs/index.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/jobs/jobs.js +3 -3
- package/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs +3 -3
- package/node_modules/openai/resources/fine-tuning/jobs.js +1 -1
- package/node_modules/openai/resources/fine-tuning/jobs.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning/methods.js +1 -1
- package/node_modules/openai/resources/fine-tuning/methods.mjs +1 -1
- package/node_modules/openai/resources/fine-tuning.js +1 -1
- package/node_modules/openai/resources/fine-tuning.mjs +1 -1
- package/node_modules/openai/resources/graders/grader-models.js +1 -1
- package/node_modules/openai/resources/graders/grader-models.mjs +1 -1
- package/node_modules/openai/resources/graders/graders.js +1 -1
- package/node_modules/openai/resources/graders/graders.mjs +1 -1
- package/node_modules/openai/resources/graders/index.js +1 -1
- package/node_modules/openai/resources/graders/index.mjs +1 -1
- package/node_modules/openai/resources/graders.js +1 -1
- package/node_modules/openai/resources/graders.mjs +1 -1
- package/node_modules/openai/resources/images.js +8 -2
- package/node_modules/openai/resources/images.mjs +8 -2
- package/node_modules/openai/resources/index.js +9 -3
- package/node_modules/openai/resources/index.mjs +5 -2
- package/node_modules/openai/resources/live/forks/forks.js +9 -0
- package/node_modules/openai/resources/live/forks/forks.mjs +5 -0
- package/node_modules/openai/resources/live/forks/index.js +7 -0
- package/node_modules/openai/resources/live/forks/index.mjs +3 -0
- package/node_modules/openai/resources/live/forks/internal-base.js +65 -0
- package/node_modules/openai/resources/live/forks/internal-base.mjs +59 -0
- package/node_modules/openai/resources/live/forks/ws-base.js +547 -0
- package/node_modules/openai/resources/live/forks/ws-base.mjs +543 -0
- package/node_modules/openai/resources/live/forks/ws.js +32 -0
- package/node_modules/openai/resources/live/forks/ws.mjs +27 -0
- package/node_modules/openai/resources/live/forks.js +6 -0
- package/node_modules/openai/resources/live/forks.mjs +3 -0
- package/node_modules/openai/resources/live/index.js +13 -0
- package/node_modules/openai/resources/live/index.mjs +6 -0
- package/node_modules/openai/resources/live/internal-base.js +64 -0
- package/node_modules/openai/resources/live/internal-base.mjs +58 -0
- package/node_modules/openai/resources/live/live.js +40 -0
- package/node_modules/openai/resources/live/live.mjs +35 -0
- package/node_modules/openai/resources/live/sessions.js +124 -0
- package/node_modules/openai/resources/live/sessions.mjs +120 -0
- package/node_modules/openai/resources/live/sideband/index.js +7 -0
- package/node_modules/openai/resources/live/sideband/index.mjs +3 -0
- package/node_modules/openai/resources/live/sideband/internal-base.js +65 -0
- package/node_modules/openai/resources/live/sideband/internal-base.mjs +59 -0
- package/node_modules/openai/resources/live/sideband/sideband.js +9 -0
- package/node_modules/openai/resources/live/sideband/sideband.mjs +5 -0
- package/node_modules/openai/resources/live/sideband/ws-base.js +547 -0
- package/node_modules/openai/resources/live/sideband/ws-base.mjs +543 -0
- package/node_modules/openai/resources/live/sideband/ws.js +32 -0
- package/node_modules/openai/resources/live/sideband/ws.mjs +27 -0
- package/node_modules/openai/resources/live/sideband.js +6 -0
- package/node_modules/openai/resources/live/sideband.mjs +3 -0
- package/node_modules/openai/resources/live/ws-base.js +547 -0
- package/node_modules/openai/resources/live/ws-base.mjs +543 -0
- package/node_modules/openai/resources/live/ws.js +32 -0
- package/node_modules/openai/resources/live/ws.mjs +27 -0
- package/node_modules/openai/resources/live.js +6 -0
- package/node_modules/openai/resources/live.mjs +3 -0
- package/node_modules/openai/resources/models.js +1 -1
- package/node_modules/openai/resources/models.mjs +1 -1
- package/node_modules/openai/resources/moderations.js +3 -2
- package/node_modules/openai/resources/moderations.mjs +3 -2
- package/node_modules/openai/resources/realtime/calls.js +25 -1
- package/node_modules/openai/resources/realtime/calls.mjs +25 -1
- package/node_modules/openai/resources/realtime/client-secrets.js +2 -2
- package/node_modules/openai/resources/realtime/client-secrets.mjs +2 -2
- package/node_modules/openai/resources/realtime/index.js +1 -1
- package/node_modules/openai/resources/realtime/index.mjs +2 -2
- package/node_modules/openai/resources/realtime/realtime.js +1 -1
- package/node_modules/openai/resources/realtime/realtime.mjs +1 -1
- package/node_modules/openai/resources/realtime.js +1 -1
- package/node_modules/openai/resources/realtime.mjs +1 -1
- package/node_modules/openai/resources/responses/index.js +1 -1
- package/node_modules/openai/resources/responses/index.mjs +1 -1
- package/node_modules/openai/resources/responses/input-items.js +1 -1
- package/node_modules/openai/resources/responses/input-items.mjs +1 -1
- package/node_modules/openai/resources/responses/input-tokens.js +1 -1
- package/node_modules/openai/resources/responses/input-tokens.mjs +1 -1
- package/node_modules/openai/resources/responses/internal-base.js +24 -6
- package/node_modules/openai/resources/responses/internal-base.mjs +24 -6
- package/node_modules/openai/resources/responses/responses.js +5 -5
- package/node_modules/openai/resources/responses/responses.mjs +5 -5
- package/node_modules/openai/resources/responses/ws-base.js +115 -23
- package/node_modules/openai/resources/responses/ws-base.mjs +115 -25
- package/node_modules/openai/resources/responses/ws.js +23 -7
- package/node_modules/openai/resources/responses/ws.mjs +23 -7
- package/node_modules/openai/resources/responses.js +1 -1
- package/node_modules/openai/resources/responses.mjs +1 -1
- package/node_modules/openai/resources/safety/alerts.js +16 -0
- package/node_modules/openai/resources/safety/alerts.mjs +12 -0
- package/node_modules/openai/resources/safety/index.js +9 -0
- package/node_modules/openai/resources/safety/index.mjs +4 -0
- package/node_modules/openai/resources/safety/safety.js +17 -0
- package/node_modules/openai/resources/safety/safety.mjs +12 -0
- package/node_modules/openai/resources/safety.js +6 -0
- package/node_modules/openai/resources/safety.mjs +3 -0
- package/node_modules/openai/resources/shared.js +1 -1
- package/node_modules/openai/resources/shared.mjs +1 -1
- package/node_modules/openai/resources/skills/content.js +1 -1
- package/node_modules/openai/resources/skills/content.mjs +1 -1
- package/node_modules/openai/resources/skills/index.js +1 -1
- package/node_modules/openai/resources/skills/index.mjs +1 -1
- package/node_modules/openai/resources/skills/skills.js +4 -2
- package/node_modules/openai/resources/skills/skills.mjs +4 -2
- package/node_modules/openai/resources/skills/versions/content.js +1 -1
- package/node_modules/openai/resources/skills/versions/content.mjs +1 -1
- package/node_modules/openai/resources/skills/versions/index.js +1 -1
- package/node_modules/openai/resources/skills/versions/index.mjs +1 -1
- package/node_modules/openai/resources/skills/versions/versions.js +4 -2
- package/node_modules/openai/resources/skills/versions/versions.mjs +4 -2
- package/node_modules/openai/resources/skills/versions.js +1 -1
- package/node_modules/openai/resources/skills/versions.mjs +1 -1
- package/node_modules/openai/resources/skills.js +1 -1
- package/node_modules/openai/resources/skills.mjs +1 -1
- package/node_modules/openai/resources/uploads/index.js +1 -1
- package/node_modules/openai/resources/uploads/index.mjs +1 -1
- package/node_modules/openai/resources/uploads/parts.js +6 -5
- package/node_modules/openai/resources/uploads/parts.mjs +6 -5
- package/node_modules/openai/resources/uploads/uploads.js +10 -10
- package/node_modules/openai/resources/uploads/uploads.mjs +10 -10
- package/node_modules/openai/resources/uploads.js +1 -1
- package/node_modules/openai/resources/uploads.mjs +1 -1
- package/node_modules/openai/resources/vector-stores/file-batches.js +6 -63
- package/node_modules/openai/resources/vector-stores/file-batches.mjs +6 -63
- package/node_modules/openai/resources/vector-stores/files.js +6 -39
- package/node_modules/openai/resources/vector-stores/files.mjs +6 -39
- package/node_modules/openai/resources/vector-stores/index.js +1 -1
- package/node_modules/openai/resources/vector-stores/index.mjs +1 -1
- package/node_modules/openai/resources/vector-stores/vector-stores.js +1 -1
- package/node_modules/openai/resources/vector-stores/vector-stores.mjs +1 -1
- package/node_modules/openai/resources/vector-stores.js +1 -1
- package/node_modules/openai/resources/vector-stores.mjs +1 -1
- package/node_modules/openai/resources/videos.js +24 -1
- package/node_modules/openai/resources/videos.mjs +24 -1
- package/node_modules/openai/resources/webhooks/event-types.js +21 -0
- package/node_modules/openai/resources/webhooks/event-types.mjs +17 -0
- package/node_modules/openai/resources/webhooks/index.js +4 -1
- package/node_modules/openai/resources/webhooks/index.mjs +2 -1
- package/node_modules/openai/resources/webhooks/webhooks.js +127 -43
- package/node_modules/openai/resources/webhooks/webhooks.mjs +127 -43
- package/node_modules/openai/resources/webhooks.js +1 -1
- package/node_modules/openai/resources/webhooks.mjs +1 -1
- package/node_modules/openai/src/_vendor/partial-json-parser/LICENSE +21 -0
- package/node_modules/openai/src/_vendor/partial-json-parser/README.md +11 -1
- package/node_modules/openai/src/_vendor/partial-json-parser/parser.ts +66 -35
- package/node_modules/openai/src/_vendor/zod-to-json-schema/Options.ts +32 -18
- package/node_modules/openai/src/_vendor/zod-to-json-schema/Refs.ts +7 -6
- package/node_modules/openai/src/_vendor/zod-to-json-schema/errorMessages.ts +5 -3
- package/node_modules/openai/src/_vendor/zod-to-json-schema/index.ts +3 -1
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts +194 -79
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/array.ts +8 -5
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/bigint.ts +20 -12
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/branded.ts +4 -4
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/catch.ts +4 -5
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/date.ts +16 -10
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/default.ts +10 -5
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/effects.ts +4 -3
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/enum.ts +1 -1
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/intersection.ts +12 -9
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/literal.ts +12 -2
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/map.ts +6 -4
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/nativeEnum.ts +10 -11
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/null.ts +4 -3
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/nullable.ts +25 -10
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/number.ts +17 -8
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/object.ts +57 -54
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/optional.ts +25 -17
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/pipeline.ts +8 -6
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/promise.ts +10 -5
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/readonly.ts +4 -5
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/record.ts +22 -19
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/set.ts +6 -4
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/string.ts +62 -37
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/tuple.ts +32 -25
- package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/union.ts +51 -33
- package/node_modules/openai/src/_vendor/zod-to-json-schema/util.ts +11 -6
- package/node_modules/openai/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts +133 -52
- package/node_modules/openai/src/auth/index.ts +7 -1
- package/node_modules/openai/src/auth/subject-token-providers.ts +281 -16
- package/node_modules/openai/src/auth/types.ts +48 -5
- package/node_modules/openai/src/auth/workload-identity-auth.ts +227 -26
- package/node_modules/openai/src/auth/x509-transport.ts +369 -0
- package/node_modules/openai/src/azure.ts +127 -28
- package/node_modules/openai/src/bedrock.ts +294 -0
- package/node_modules/openai/src/beta/realtime/internal-base.ts +136 -16
- package/node_modules/openai/src/beta/realtime/websocket.ts +264 -48
- package/node_modules/openai/src/beta/realtime/ws.ts +138 -25
- package/node_modules/openai/src/client.ts +975 -124
- package/node_modules/openai/src/core/EventEmitter.ts +162 -26
- package/node_modules/openai/src/core/api-promise.ts +0 -2
- package/node_modules/openai/src/core/error.ts +6 -8
- package/node_modules/openai/src/core/pagination.ts +67 -7
- package/node_modules/openai/src/core/resource.ts +0 -2
- package/node_modules/openai/src/core/streaming.ts +490 -100
- package/node_modules/openai/src/core/uploads.ts +6 -1
- package/node_modules/openai/src/helpers/audio.ts +215 -32
- package/node_modules/openai/src/helpers/live.ts +8 -0
- package/node_modules/openai/src/helpers/standard-schema.ts +819 -0
- package/node_modules/openai/src/helpers/zod-v3-strict-schema.ts +520 -0
- package/node_modules/openai/src/helpers/zod.ts +418 -56
- package/node_modules/openai/src/index.ts +4 -5
- package/node_modules/openai/src/internal/assistant-stream-delta.ts +440 -0
- package/node_modules/openai/src/internal/auth/x509-api-origin.ts +27 -0
- package/node_modules/openai/src/internal/auth/x509-credential-options.ts +149 -0
- package/node_modules/openai/src/internal/auth/x509-token-exchange.ts +319 -0
- package/node_modules/openai/src/internal/auth/x509-transport-capability.ts +227 -0
- package/node_modules/openai/src/internal/auth/x509-transport-registry.ts +127 -0
- package/node_modules/openai/src/internal/auth/x509-transport-state-browser.ts +43 -0
- package/node_modules/openai/src/internal/auth/x509-transport-state.cts +43 -0
- package/node_modules/openai/src/internal/auth/x509-workload-identity-auth.ts +972 -0
- package/node_modules/openai/src/internal/bedrock.ts +586 -0
- package/node_modules/openai/src/internal/builtin-types.ts +0 -2
- package/node_modules/openai/src/internal/data-residency.ts +44 -0
- package/node_modules/openai/src/internal/decoders/line.ts +145 -61
- package/node_modules/openai/src/internal/detect-platform.ts +3 -5
- package/node_modules/openai/src/internal/errors.ts +3 -4
- package/node_modules/openai/src/internal/headers.ts +14 -10
- package/node_modules/openai/src/internal/multipart-encoding.ts +53 -0
- package/node_modules/openai/src/internal/parse.ts +47 -19
- package/node_modules/openai/src/internal/provider.ts +92 -0
- package/node_modules/openai/src/internal/qs/formats.ts +1 -1
- package/node_modules/openai/src/internal/qs/stringify.ts +57 -53
- package/node_modules/openai/src/internal/qs/types.ts +1 -1
- package/node_modules/openai/src/internal/qs/utils.ts +443 -54
- package/node_modules/openai/src/internal/realtime-credentials.ts +27 -0
- package/node_modules/openai/src/internal/request-options.ts +52 -3
- package/node_modules/openai/src/internal/responses/canonical-output-text.ts +160 -0
- package/node_modules/openai/src/internal/responses/output-text-index.ts +84 -0
- package/node_modules/openai/src/internal/responses/response-accumulator.ts +1263 -0
- package/node_modules/openai/src/internal/shim-types.ts +3 -4
- package/node_modules/openai/src/internal/shims.ts +0 -2
- package/node_modules/openai/src/internal/stream-utils.ts +37 -5
- package/node_modules/openai/src/internal/to-file.ts +90 -35
- package/node_modules/openai/src/internal/types.ts +21 -29
- package/node_modules/openai/src/internal/uploads.ts +533 -59
- package/node_modules/openai/src/internal/utils/abort.ts +116 -0
- package/node_modules/openai/src/internal/utils/base64.ts +3 -2
- package/node_modules/openai/src/internal/utils/bytes.ts +7 -0
- package/node_modules/openai/src/internal/utils/env.ts +9 -7
- package/node_modules/openai/src/internal/utils/log.ts +77 -14
- package/node_modules/openai/src/internal/utils/path.ts +53 -32
- package/node_modules/openai/src/internal/utils/query.ts +0 -2
- package/node_modules/openai/src/internal/utils/sleep.ts +51 -2
- package/node_modules/openai/src/internal/utils/uuid.ts +0 -2
- package/node_modules/openai/src/internal/utils/values.ts +0 -2
- package/node_modules/openai/src/internal/utils.ts +0 -2
- package/node_modules/openai/src/internal/ws-adapter-browser.ts +83 -24
- package/node_modules/openai/src/internal/ws-adapter-node.ts +105 -26
- package/node_modules/openai/src/internal/ws-adapter.ts +23 -0
- package/node_modules/openai/src/internal/ws.ts +250 -51
- package/node_modules/openai/src/lib/.keep +2 -2
- package/node_modules/openai/src/lib/AbstractChatCompletionRunner.ts +349 -102
- package/node_modules/openai/src/lib/AssistantStream.ts +537 -268
- package/node_modules/openai/src/lib/ChatCompletionRunner.ts +75 -22
- package/node_modules/openai/src/lib/ChatCompletionStream.ts +2016 -268
- package/node_modules/openai/src/lib/ChatCompletionStreamingRunner.ts +115 -17
- package/node_modules/openai/src/lib/EventEmitter.ts +171 -26
- package/node_modules/openai/src/lib/EventStream.ts +1979 -64
- package/node_modules/openai/src/lib/ResponsesParser.ts +153 -56
- package/node_modules/openai/src/lib/RunnableFunction.ts +99 -37
- package/node_modules/openai/src/lib/Util.ts +7 -5
- package/node_modules/openai/src/lib/agents/agent-session-stream.ts +328 -0
- package/node_modules/openai/src/lib/agents/output-text.ts +6 -0
- package/node_modules/openai/src/lib/agents/turn-state.ts +61 -0
- package/node_modules/openai/src/lib/assistant-run-polling.ts +27 -0
- package/node_modules/openai/src/lib/chatCompletionUtils.ts +9 -10
- package/node_modules/openai/src/lib/embeddings.ts +73 -0
- package/node_modules/openai/src/lib/file-processing.ts +37 -0
- package/node_modules/openai/src/lib/jsonschema.ts +77 -34
- package/node_modules/openai/src/lib/live/transcript-grouper.ts +307 -0
- package/node_modules/openai/src/lib/live/transcript-grouping.ts +394 -0
- package/node_modules/openai/src/lib/live/webrtc.ts +23 -0
- package/node_modules/openai/src/lib/parser.ts +247 -69
- package/node_modules/openai/src/lib/polling.ts +145 -0
- package/node_modules/openai/src/lib/realtime/webrtc.ts +20 -0
- package/node_modules/openai/src/lib/responses/EventTypes.ts +9 -60
- package/node_modules/openai/src/lib/responses/ResponseAccumulator.ts +27 -0
- package/node_modules/openai/src/lib/responses/ResponseInputItems.ts +167 -0
- package/node_modules/openai/src/lib/responses/ResponseStream.ts +135 -179
- package/node_modules/openai/src/lib/responses/responses-websocket-lane.ts +388 -0
- package/node_modules/openai/src/lib/responses/responses-websocket-session.ts +317 -0
- package/node_modules/openai/src/lib/transform.ts +2015 -100
- package/node_modules/openai/src/lib/vector-store-polling.ts +46 -0
- package/node_modules/openai/src/lib/vector-store-upload.ts +57 -0
- package/node_modules/openai/src/lib/webhook-signature.ts +164 -0
- package/node_modules/openai/src/lib/webrtc/connection.ts +313 -0
- package/node_modules/openai/src/lib/webrtc/data-channel.ts +151 -0
- package/node_modules/openai/src/lib/webrtc/errors.ts +38 -0
- package/node_modules/openai/src/lib/webrtc/subscriptions.ts +65 -0
- package/node_modules/openai/src/lib/webrtc/types.ts +110 -0
- package/node_modules/openai/src/live/webrtc.ts +10 -0
- package/node_modules/openai/src/providers/bedrock/aws.ts +331 -0
- package/node_modules/openai/src/providers/bedrock.ts +51 -0
- package/node_modules/openai/src/realtime/internal-base.ts +265 -17
- package/node_modules/openai/src/realtime/webrtc.ts +10 -0
- package/node_modules/openai/src/realtime/websocket.ts +259 -54
- package/node_modules/openai/src/realtime/ws.ts +135 -29
- package/node_modules/openai/src/resources/admin/admin.ts +1 -1
- package/node_modules/openai/src/resources/admin/index.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/admin-api-keys.ts +18 -2
- package/node_modules/openai/src/resources/admin/organization/audit-logs.ts +327 -4
- package/node_modules/openai/src/resources/admin/organization/certificates.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/data-retention.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/groups/groups.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/groups/index.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/groups/roles.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/groups/users.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/groups.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/index.ts +9 -1
- package/node_modules/openai/src/resources/admin/organization/invites.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/organization.ts +21 -1
- package/node_modules/openai/src/resources/admin/organization/projects/api-keys.ts +22 -2
- package/node_modules/openai/src/resources/admin/organization/projects/certificates.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/data-retention.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/groups/groups.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/groups/index.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/groups/roles.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/groups.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/hosted-tool-permissions.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/index.ts +10 -2
- package/node_modules/openai/src/resources/admin/organization/projects/model-permissions.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/projects.ts +70 -19
- package/node_modules/openai/src/resources/admin/organization/projects/rate-limits.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/roles.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/service-accounts/api-keys.ts +91 -0
- package/node_modules/openai/src/resources/admin/organization/projects/service-accounts/index.ts +15 -0
- package/node_modules/openai/src/resources/admin/organization/projects/service-accounts/service-accounts.ts +299 -0
- package/node_modules/openai/src/resources/admin/organization/projects/service-accounts.ts +2 -265
- package/node_modules/openai/src/resources/admin/organization/projects/spend-alerts.ts +33 -1
- package/node_modules/openai/src/resources/admin/organization/projects/spend-limit.ts +156 -0
- package/node_modules/openai/src/resources/admin/organization/projects/users/index.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/users/roles.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/users/users.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects/users.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/projects.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/roles.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/spend-alerts.ts +19 -1
- package/node_modules/openai/src/resources/admin/organization/spend-limit.ts +144 -0
- package/node_modules/openai/src/resources/admin/organization/usage.ts +706 -89
- package/node_modules/openai/src/resources/admin/organization/users/index.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/users/roles.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/users/users.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization/users.ts +1 -1
- package/node_modules/openai/src/resources/admin/organization.ts +1 -1
- package/node_modules/openai/src/resources/admin.ts +1 -1
- package/node_modules/openai/src/resources/audio/audio.ts +4 -1
- package/node_modules/openai/src/resources/audio/index.ts +2 -1
- package/node_modules/openai/src/resources/audio/speech.ts +4 -3
- package/node_modules/openai/src/resources/audio/transcriptions.ts +51 -13
- package/node_modules/openai/src/resources/audio/translations.ts +5 -3
- package/node_modules/openai/src/resources/audio.ts +1 -1
- package/node_modules/openai/src/resources/batches.ts +10 -9
- package/node_modules/openai/src/resources/beta/agents/agents.ts +4627 -0
- package/node_modules/openai/src/resources/beta/agents/environments/environments.ts +111 -0
- package/node_modules/openai/src/resources/beta/agents/environments/files.ts +169 -0
- package/node_modules/openai/src/resources/beta/agents/environments/index.ts +19 -0
- package/node_modules/openai/src/resources/beta/agents/environments/templates.ts +535 -0
- package/node_modules/openai/src/resources/beta/agents/environments.ts +3 -0
- package/node_modules/openai/src/resources/beta/agents/index.ts +127 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/artifacts.ts +249 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/events.ts +94 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/index.ts +24 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/items.ts +59 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/sessions.ts +403 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/subagents/index.ts +5 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/subagents/items.ts +65 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/subagents/subagents.ts +113 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/subagents/turns/index.ts +4 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/subagents/turns/items.ts +70 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/subagents/turns/turns.ts +111 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/subagents/turns.ts +3 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/subagents.ts +3 -0
- package/node_modules/openai/src/resources/beta/agents/sessions/turns.ts +159 -0
- package/node_modules/openai/src/resources/beta/agents/sessions.ts +3 -0
- package/node_modules/openai/src/resources/beta/agents/vaults/credentials.ts +693 -0
- package/node_modules/openai/src/resources/beta/agents/vaults/index.ts +29 -0
- package/node_modules/openai/src/resources/beta/agents/vaults/vaults.ts +243 -0
- package/node_modules/openai/src/resources/beta/agents/vaults.ts +3 -0
- package/node_modules/openai/src/resources/beta/agents.ts +3 -0
- package/node_modules/openai/src/resources/beta/assistants.ts +154 -172
- package/node_modules/openai/src/resources/beta/beta.ts +578 -3
- package/node_modules/openai/src/resources/beta/chatkit/chatkit.ts +1 -1
- package/node_modules/openai/src/resources/beta/chatkit/index.ts +1 -1
- package/node_modules/openai/src/resources/beta/chatkit/sessions.ts +1 -1
- package/node_modules/openai/src/resources/beta/chatkit/threads.ts +1 -1
- package/node_modules/openai/src/resources/beta/chatkit.ts +1 -1
- package/node_modules/openai/src/resources/beta/index.ts +290 -1
- package/node_modules/openai/src/resources/beta/realtime/index.ts +0 -2
- package/node_modules/openai/src/resources/beta/realtime/realtime.ts +0 -2
- package/node_modules/openai/src/resources/beta/realtime/sessions.ts +0 -2
- package/node_modules/openai/src/resources/beta/realtime/transcription-sessions.ts +0 -2
- package/node_modules/openai/src/resources/beta/realtime.ts +0 -2
- package/node_modules/openai/src/resources/beta/responses/index.ts +189 -0
- package/node_modules/openai/src/resources/beta/responses/input-items.ts +105 -0
- package/node_modules/openai/src/resources/beta/responses/input-tokens.ts +249 -0
- package/node_modules/openai/src/resources/beta/responses/internal-base.ts +136 -0
- package/node_modules/openai/src/resources/beta/responses/responses.ts +15060 -0
- package/node_modules/openai/src/resources/beta/responses/ws-base.ts +729 -0
- package/node_modules/openai/src/resources/beta/responses/ws.ts +62 -0
- package/node_modules/openai/src/resources/beta/responses.ts +3 -0
- package/node_modules/openai/src/resources/beta/threads/index.ts +1 -1
- package/node_modules/openai/src/resources/beta/threads/messages.ts +30 -24
- package/node_modules/openai/src/resources/beta/threads/runs/index.ts +2 -2
- package/node_modules/openai/src/resources/beta/threads/runs/runs.ts +47 -93
- package/node_modules/openai/src/resources/beta/threads/runs/steps.ts +15 -16
- package/node_modules/openai/src/resources/beta/threads/runs.ts +1 -1
- package/node_modules/openai/src/resources/beta/threads/threads.ts +54 -51
- package/node_modules/openai/src/resources/beta/threads.ts +1 -1
- package/node_modules/openai/src/resources/beta.ts +1 -1
- package/node_modules/openai/src/resources/chat/chat.ts +1 -1
- package/node_modules/openai/src/resources/chat/completions/completions.ts +762 -108
- package/node_modules/openai/src/resources/chat/completions/index.ts +1 -1
- package/node_modules/openai/src/resources/chat/completions/messages.ts +1 -1
- package/node_modules/openai/src/resources/chat/completions.ts +1 -1
- package/node_modules/openai/src/resources/chat/index.ts +1 -1
- package/node_modules/openai/src/resources/chat.ts +1 -1
- package/node_modules/openai/src/resources/completions.ts +36 -15
- package/node_modules/openai/src/resources/containers/containers.ts +1 -1
- package/node_modules/openai/src/resources/containers/files/content.ts +1 -1
- package/node_modules/openai/src/resources/containers/files/files.ts +1 -1
- package/node_modules/openai/src/resources/containers/files/index.ts +1 -1
- package/node_modules/openai/src/resources/containers/files.ts +1 -1
- package/node_modules/openai/src/resources/containers/index.ts +1 -1
- package/node_modules/openai/src/resources/containers.ts +1 -1
- package/node_modules/openai/src/resources/content-provenance-checks.ts +132 -0
- package/node_modules/openai/src/resources/conversations/conversations.ts +23 -2
- package/node_modules/openai/src/resources/conversations/index.ts +1 -1
- package/node_modules/openai/src/resources/conversations/items.ts +93 -5
- package/node_modules/openai/src/resources/conversations.ts +1 -1
- package/node_modules/openai/src/resources/embeddings.ts +22 -49
- package/node_modules/openai/src/resources/evals/evals.ts +6 -6
- package/node_modules/openai/src/resources/evals/index.ts +1 -1
- package/node_modules/openai/src/resources/evals/runs/index.ts +1 -1
- package/node_modules/openai/src/resources/evals/runs/output-items.ts +1 -1
- package/node_modules/openai/src/resources/evals/runs/runs.ts +119 -191
- package/node_modules/openai/src/resources/evals/runs.ts +1 -1
- package/node_modules/openai/src/resources/evals.ts +1 -1
- package/node_modules/openai/src/resources/files.ts +9 -26
- package/node_modules/openai/src/resources/fine-tuning/alpha/alpha.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning/alpha/graders.ts +6 -5
- package/node_modules/openai/src/resources/fine-tuning/alpha/index.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning/alpha.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning/checkpoints/checkpoints.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning/checkpoints/index.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning/checkpoints/permissions.ts +9 -5
- package/node_modules/openai/src/resources/fine-tuning/checkpoints.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning/fine-tuning.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning/index.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning/jobs/checkpoints.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning/jobs/index.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning/jobs/jobs.ts +14 -13
- package/node_modules/openai/src/resources/fine-tuning/jobs.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning/methods.ts +1 -1
- package/node_modules/openai/src/resources/fine-tuning.ts +1 -1
- package/node_modules/openai/src/resources/graders/grader-models.ts +7 -14
- package/node_modules/openai/src/resources/graders/graders.ts +1 -1
- package/node_modules/openai/src/resources/graders/index.ts +1 -1
- package/node_modules/openai/src/resources/graders.ts +1 -1
- package/node_modules/openai/src/resources/images.ts +100 -85
- package/node_modules/openai/src/resources/index.ts +9 -2
- package/node_modules/openai/src/resources/live/api.md +87 -0
- package/node_modules/openai/src/resources/live/forks/forks.ts +169 -0
- package/node_modules/openai/src/resources/live/forks/index.ts +5 -0
- package/node_modules/openai/src/resources/live/forks/internal-base.ts +126 -0
- package/node_modules/openai/src/resources/live/forks/ws-base.ts +700 -0
- package/node_modules/openai/src/resources/live/forks/ws.ts +47 -0
- package/node_modules/openai/src/resources/live/forks.ts +3 -0
- package/node_modules/openai/src/resources/live/index.ts +20 -0
- package/node_modules/openai/src/resources/live/internal-base.ts +123 -0
- package/node_modules/openai/src/resources/live/live.ts +2296 -0
- package/node_modules/openai/src/resources/live/sessions.ts +343 -0
- package/node_modules/openai/src/resources/live/sideband/index.ts +10 -0
- package/node_modules/openai/src/resources/live/sideband/internal-base.ts +126 -0
- package/node_modules/openai/src/resources/live/sideband/sideband.ts +58 -0
- package/node_modules/openai/src/resources/live/sideband/ws-base.ts +710 -0
- package/node_modules/openai/src/resources/live/sideband/ws.ts +47 -0
- package/node_modules/openai/src/resources/live/sideband.ts +3 -0
- package/node_modules/openai/src/resources/live/ws-base.ts +696 -0
- package/node_modules/openai/src/resources/live/ws.ts +43 -0
- package/node_modules/openai/src/resources/live.ts +3 -0
- package/node_modules/openai/src/resources/models.ts +6 -1
- package/node_modules/openai/src/resources/moderations.ts +6 -5
- package/node_modules/openai/src/resources/realtime/api.md +1 -0
- package/node_modules/openai/src/resources/realtime/calls.ts +50 -2
- package/node_modules/openai/src/resources/realtime/client-secrets.ts +27 -10
- package/node_modules/openai/src/resources/realtime/index.ts +8 -2
- package/node_modules/openai/src/resources/realtime/realtime.ts +93 -35
- package/node_modules/openai/src/resources/realtime.ts +1 -1
- package/node_modules/openai/src/resources/responses/api.md +20 -0
- package/node_modules/openai/src/resources/responses/index.ts +1 -1
- package/node_modules/openai/src/resources/responses/input-items.ts +1 -1
- package/node_modules/openai/src/resources/responses/input-tokens.ts +26 -16
- package/node_modules/openai/src/resources/responses/internal-base.ts +33 -14
- package/node_modules/openai/src/resources/responses/responses.ts +4150 -792
- package/node_modules/openai/src/resources/responses/ws-base.ts +147 -31
- package/node_modules/openai/src/resources/responses/ws.ts +33 -9
- package/node_modules/openai/src/resources/responses.ts +1 -1
- package/node_modules/openai/src/resources/safety/alerts.ts +51 -0
- package/node_modules/openai/src/resources/safety/index.ts +4 -0
- package/node_modules/openai/src/resources/safety/safety.ts +15 -0
- package/node_modules/openai/src/resources/safety.ts +3 -0
- package/node_modules/openai/src/resources/shared.ts +98 -41
- package/node_modules/openai/src/resources/skills/content.ts +1 -1
- package/node_modules/openai/src/resources/skills/index.ts +1 -1
- package/node_modules/openai/src/resources/skills/skills.ts +4 -2
- package/node_modules/openai/src/resources/skills/versions/content.ts +1 -1
- package/node_modules/openai/src/resources/skills/versions/index.ts +1 -1
- package/node_modules/openai/src/resources/skills/versions/versions.ts +4 -2
- package/node_modules/openai/src/resources/skills/versions.ts +1 -1
- package/node_modules/openai/src/resources/skills.ts +1 -1
- package/node_modules/openai/src/resources/uploads/index.ts +1 -1
- package/node_modules/openai/src/resources/uploads/parts.ts +6 -5
- package/node_modules/openai/src/resources/uploads/uploads.ts +12 -12
- package/node_modules/openai/src/resources/uploads.ts +1 -1
- package/node_modules/openai/src/resources/vector-stores/file-batches.ts +24 -89
- package/node_modules/openai/src/resources/vector-stores/files.ts +12 -52
- package/node_modules/openai/src/resources/vector-stores/index.ts +1 -1
- package/node_modules/openai/src/resources/vector-stores/vector-stores.ts +4 -4
- package/node_modules/openai/src/resources/vector-stores.ts +1 -1
- package/node_modules/openai/src/resources/videos.ts +63 -2
- package/node_modules/openai/src/resources/webhooks/api.md +40 -17
- package/node_modules/openai/src/resources/webhooks/event-types.ts +21 -0
- package/node_modules/openai/src/resources/webhooks/index.ts +2 -1
- package/node_modules/openai/src/resources/webhooks/webhooks.ts +694 -69
- package/node_modules/openai/src/resources/webhooks.ts +1 -1
- package/node_modules/openai/src/tsconfig.json +6 -3
- package/node_modules/openai/src/version.ts +2 -1
- package/node_modules/openai/version.js +2 -1
- package/node_modules/openai/version.mjs +2 -1
- package/package.json +5 -5
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +0 -832
- package/node_modules/@earendil-works/pi-ai/dist/images-models.js +0 -143
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.js +0 -22
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/LICENSE +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/README.md +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-es/constants.js +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-es/fromEnvSigningName.js +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-es/fromStatic.js +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-es/getNewSsoOidcToken.js +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-es/getSsoOidcClient.js +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-es/index.js +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-es/nodeProvider.js +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-es/validateTokenExpiry.js +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-es/validateTokenKey.js +0 -0
- /package/node_modules/@aws-sdk/{credential-provider-sso → client-bedrock-runtime}/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js +0 -0
- /package/node_modules/@earendil-works/pi-ai/dist/{auth/oauth → utils}/oauth-page.js +0 -0
|
@@ -1,25 +1,40 @@
|
|
|
1
|
-
// File generated from our OpenAPI spec by
|
|
1
|
+
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import type { RequestInit, RequestInfo, BodyInit } from './internal/builtin-types';
|
|
4
4
|
import type { HTTPMethod, PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from './internal/types';
|
|
5
5
|
import { uuid4 } from './internal/utils/uuid';
|
|
6
|
-
import { validatePositiveInteger, isAbsoluteURL, safeJSON } from './internal/utils/values';
|
|
6
|
+
import { validatePositiveInteger, isAbsoluteURL, safeJSON, hasOwn } from './internal/utils/values';
|
|
7
7
|
import { sleep } from './internal/utils/sleep';
|
|
8
|
+
import { addRequestAbortListener, retainRequestAbortCallback } from './internal/utils/abort';
|
|
8
9
|
export type { Logger, LogLevel } from './internal/utils/log';
|
|
9
10
|
import { castToError, isAbortError } from './internal/errors';
|
|
10
|
-
import type
|
|
11
|
+
import { addRequestID, defaultParseResponse, type APIResponseProps } from './internal/parse';
|
|
11
12
|
import { getPlatformHeaders } from './internal/detect-platform';
|
|
12
13
|
import * as Shims from './internal/shims';
|
|
13
14
|
import * as Opts from './internal/request-options';
|
|
14
15
|
import { stringifyQuery } from './internal/utils/query';
|
|
15
16
|
import { VERSION } from './version';
|
|
17
|
+
import { resolveDataResidency, type DataResidency } from './internal/data-residency';
|
|
18
|
+
export type { DataResidency } from './internal/data-residency';
|
|
16
19
|
import * as Errors from './core/error';
|
|
17
20
|
import * as Pagination from './core/pagination';
|
|
18
|
-
import type { WorkloadIdentity } from './auth/types';
|
|
21
|
+
import type { WorkloadIdentity, X509Credential, X509WorkloadIdentity } from './auth/types';
|
|
19
22
|
import { WorkloadIdentityAuth } from './auth/workload-identity-auth';
|
|
23
|
+
import { X509_API_BASE_URL, assertX509APIOrigin } from './internal/auth/x509-api-origin';
|
|
24
|
+
import {
|
|
25
|
+
X509WorkloadIdentityAuth,
|
|
26
|
+
assertX509RequestOptions,
|
|
27
|
+
isX509WorkloadIdentity,
|
|
28
|
+
snapshotX509RequestOptions,
|
|
29
|
+
} from './internal/auth/x509-workload-identity-auth';
|
|
30
|
+
import type { X509Transport } from './internal/auth/x509-transport-registry';
|
|
31
|
+
import {
|
|
32
|
+
normalizeX509CredentialOptions,
|
|
33
|
+
prepareX509ClientClone,
|
|
34
|
+
} from './internal/auth/x509-credential-options';
|
|
35
|
+
import { isTransientX509ConnectionError, markApprovedX509Client } from '#x509-transport-state';
|
|
20
36
|
import { OAuthError, SubjectTokenProviderError } from './core/error';
|
|
21
37
|
import {
|
|
22
|
-
AbstractPage,
|
|
23
38
|
type ConversationCursorPageParams,
|
|
24
39
|
ConversationCursorPageResponse,
|
|
25
40
|
type CursorPageParams,
|
|
@@ -27,10 +42,13 @@ import {
|
|
|
27
42
|
type NextCursorPageParams,
|
|
28
43
|
NextCursorPageResponse,
|
|
29
44
|
PageResponse,
|
|
45
|
+
type TokenPageParams,
|
|
46
|
+
TokenPageResponse,
|
|
30
47
|
} from './core/pagination';
|
|
31
48
|
import * as Uploads from './core/uploads';
|
|
32
49
|
import * as API from './resources/index';
|
|
33
50
|
import { APIPromise } from './core/api-promise';
|
|
51
|
+
import { resolveRealtimeAPIKey } from './internal/realtime-credentials';
|
|
34
52
|
import {
|
|
35
53
|
Batch,
|
|
36
54
|
BatchCreateParams,
|
|
@@ -50,6 +68,11 @@ import {
|
|
|
50
68
|
CompletionUsage,
|
|
51
69
|
Completions,
|
|
52
70
|
} from './resources/completions';
|
|
71
|
+
import {
|
|
72
|
+
ContentProvenanceCheck,
|
|
73
|
+
ContentProvenanceCheckCreateParams,
|
|
74
|
+
ContentProvenanceChecks,
|
|
75
|
+
} from './resources/content-provenance-checks';
|
|
53
76
|
import {
|
|
54
77
|
CreateEmbeddingResponse,
|
|
55
78
|
Embedding,
|
|
@@ -147,8 +170,10 @@ import {
|
|
|
147
170
|
} from './resources/evals/evals';
|
|
148
171
|
import { FineTuning } from './resources/fine-tuning/fine-tuning';
|
|
149
172
|
import { Graders } from './resources/graders/graders';
|
|
173
|
+
import { Live } from './resources/live/live';
|
|
150
174
|
import { Realtime } from './resources/realtime/realtime';
|
|
151
175
|
import { Responses } from './resources/responses/responses';
|
|
176
|
+
import { Safety } from './resources/safety/safety';
|
|
152
177
|
import {
|
|
153
178
|
DeletedSkill,
|
|
154
179
|
Skill,
|
|
@@ -233,6 +258,7 @@ import {
|
|
|
233
258
|
import { type Fetch } from './internal/builtin-types';
|
|
234
259
|
import { isRunningInBrowser } from './internal/detect-platform';
|
|
235
260
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
261
|
+
import { configureProvider, type Provider, type ProviderRuntime } from './internal/provider';
|
|
236
262
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
237
263
|
import { readEnv } from './internal/utils/env';
|
|
238
264
|
import {
|
|
@@ -241,10 +267,32 @@ import {
|
|
|
241
267
|
formatRequestDetails,
|
|
242
268
|
loggerFor,
|
|
243
269
|
parseLogLevel,
|
|
270
|
+
redactURL,
|
|
244
271
|
} from './internal/utils/log';
|
|
245
272
|
import { isEmptyObj } from './internal/utils/values';
|
|
246
273
|
|
|
274
|
+
function isRunningInBrowserOrBrowserWorker(): boolean {
|
|
275
|
+
if (isRunningInBrowser()) return true;
|
|
276
|
+
|
|
277
|
+
const scope = globalThis as any;
|
|
278
|
+
return (
|
|
279
|
+
typeof scope.WorkerGlobalScope === 'function' &&
|
|
280
|
+
scope instanceof scope.WorkerGlobalScope &&
|
|
281
|
+
typeof scope.WorkerNavigator === 'function' &&
|
|
282
|
+
scope.navigator instanceof scope.WorkerNavigator &&
|
|
283
|
+
typeof scope.navigator?.userAgent === 'string' &&
|
|
284
|
+
scope.navigator.userAgent !== 'Cloudflare-Workers' &&
|
|
285
|
+
scope.process?.versions?.node === undefined &&
|
|
286
|
+
scope.Deno === undefined &&
|
|
287
|
+
scope.Bun === undefined &&
|
|
288
|
+
scope.EdgeRuntime === undefined &&
|
|
289
|
+
scope.WebSocketPair === undefined
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
247
293
|
const WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER = 'workload-identity-auth';
|
|
294
|
+
const inheritedDataResidencySelection = Symbol('inheritedDataResidencySelection');
|
|
295
|
+
type InternalClientOptions = ClientOptions & { [inheritedDataResidencySelection]?: boolean };
|
|
248
296
|
|
|
249
297
|
export type ApiKeySetter = () => Promise<string>;
|
|
250
298
|
|
|
@@ -254,8 +302,9 @@ export interface ClientOptions {
|
|
|
254
302
|
*
|
|
255
303
|
* - Accepts either a static string or an async function that resolves to a string.
|
|
256
304
|
* - Defaults to process.env['OPENAI_API_KEY'].
|
|
257
|
-
* - When a function is provided, it is invoked
|
|
258
|
-
*
|
|
305
|
+
* - When a function is provided, it is invoked when building bearer authentication
|
|
306
|
+
* headers for each attempt, including retries and direct `buildRequest()` calls.
|
|
307
|
+
* Each invocation's result is used for its own request.
|
|
259
308
|
* - The function must return a non-empty string; otherwise an OpenAIError is thrown.
|
|
260
309
|
* - If the function throws, the error is wrapped in an OpenAIError with the original
|
|
261
310
|
* error available as `cause`.
|
|
@@ -290,6 +339,14 @@ export interface ClientOptions {
|
|
|
290
339
|
*/
|
|
291
340
|
baseURL?: string | null | undefined;
|
|
292
341
|
|
|
342
|
+
/**
|
|
343
|
+
* Select an OpenAI regional endpoint. This overrides an inherited or environment
|
|
344
|
+
* base URL and is mutually exclusive with an explicit `baseURL` or `provider`.
|
|
345
|
+
* Availability depends on your project and model; no fallback is performed.
|
|
346
|
+
* `null` and `undefined` leave ordinary base URL resolution unchanged.
|
|
347
|
+
*/
|
|
348
|
+
dataResidency?: DataResidency | null | undefined;
|
|
349
|
+
|
|
293
350
|
/**
|
|
294
351
|
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
295
352
|
* from the server before timing out a single request.
|
|
@@ -297,6 +354,23 @@ export interface ClientOptions {
|
|
|
297
354
|
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
298
355
|
* much longer than this timeout before the promise succeeds or fails.
|
|
299
356
|
*
|
|
357
|
+
* Node.js fetch enforces independent response-header and body-inactivity timeouts, typically
|
|
358
|
+
* defaulting to five minutes, even when this timeout is longer. To increase them, install
|
|
359
|
+
* `undici` and configure an Agent with the matching fetch implementation:
|
|
360
|
+
*
|
|
361
|
+
* ```ts
|
|
362
|
+
* import { Agent, fetch } from 'undici';
|
|
363
|
+
*
|
|
364
|
+
* const timeout = 20 * 60 * 1000;
|
|
365
|
+
* const client = new OpenAI({
|
|
366
|
+
* timeout,
|
|
367
|
+
* fetch,
|
|
368
|
+
* fetchOptions: {
|
|
369
|
+
* dispatcher: new Agent({ headersTimeout: timeout, bodyTimeout: timeout }),
|
|
370
|
+
* },
|
|
371
|
+
* });
|
|
372
|
+
* ```
|
|
373
|
+
*
|
|
300
374
|
* @unit milliseconds
|
|
301
375
|
*/
|
|
302
376
|
timeout?: number | undefined;
|
|
@@ -362,7 +436,19 @@ export interface ClientOptions {
|
|
|
362
436
|
* Workload identity configuration for OAuth2 token exchange authentication.
|
|
363
437
|
* Mutually exclusive with `apiKey`.
|
|
364
438
|
*/
|
|
365
|
-
workloadIdentity?: WorkloadIdentity | undefined;
|
|
439
|
+
workloadIdentity?: WorkloadIdentity | X509WorkloadIdentity | undefined;
|
|
440
|
+
|
|
441
|
+
/** Approved, frozen Node.js certificate transport required only for X.509 workload identity. */
|
|
442
|
+
x509Transport?: X509Transport | undefined;
|
|
443
|
+
|
|
444
|
+
/** First-class certificate credential created with `fromX509` from `openai/auth/x509-transport`. */
|
|
445
|
+
credential?: X509Credential | undefined;
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Configure this client to use a third-party API provider.
|
|
449
|
+
* Mutually exclusive with top-level authentication and `baseURL` options.
|
|
450
|
+
*/
|
|
451
|
+
provider?: Provider | undefined;
|
|
366
452
|
}
|
|
367
453
|
|
|
368
454
|
/**
|
|
@@ -384,9 +470,26 @@ export class OpenAI {
|
|
|
384
470
|
|
|
385
471
|
private fetch: Fetch;
|
|
386
472
|
#encoder: Opts.RequestEncoder;
|
|
473
|
+
#x509Authentication: X509WorkloadIdentityAuth | undefined;
|
|
474
|
+
#x509Credential: X509Credential | undefined;
|
|
475
|
+
#x509Fetch: Fetch | undefined;
|
|
476
|
+
// Preserve an explicit global selection without storing a second routing URL.
|
|
477
|
+
#explicitDataResidency = false;
|
|
478
|
+
#responseAttempts = new WeakMap<
|
|
479
|
+
AbortController,
|
|
480
|
+
{
|
|
481
|
+
timeout: number;
|
|
482
|
+
retriesRemaining: number;
|
|
483
|
+
hasStreamingBody: boolean;
|
|
484
|
+
authentication?: X509WorkloadIdentityAuth;
|
|
485
|
+
helperMethod?: unknown;
|
|
486
|
+
continueRequest?: <T>(operation: () => Promise<T>) => Promise<T>;
|
|
487
|
+
}
|
|
488
|
+
>();
|
|
387
489
|
protected idempotencyHeader?: string;
|
|
388
490
|
protected _options: ClientOptions;
|
|
389
|
-
private
|
|
491
|
+
private _provider: ProviderRuntime | undefined;
|
|
492
|
+
private _workloadIdentityAuth?: WorkloadIdentityAuth | X509WorkloadIdentityAuth;
|
|
390
493
|
|
|
391
494
|
/**
|
|
392
495
|
* API Client for interfacing with the OpenAI API.
|
|
@@ -397,6 +500,7 @@ export class OpenAI {
|
|
|
397
500
|
* @param {string | null | undefined} [opts.project=process.env['OPENAI_PROJECT_ID'] ?? null]
|
|
398
501
|
* @param {string | null | undefined} [opts.webhookSecret=process.env['OPENAI_WEBHOOK_SECRET'] ?? null]
|
|
399
502
|
* @param {string} [opts.baseURL=process.env['OPENAI_BASE_URL'] ?? https://api.openai.com/v1] - Override the default base URL for the API.
|
|
503
|
+
* @param {Provider} [opts.provider] - Configure a third-party API provider. Mutually exclusive with top-level authentication and base URL options.
|
|
400
504
|
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
401
505
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
402
506
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -405,16 +509,43 @@ export class OpenAI {
|
|
|
405
509
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
406
510
|
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
407
511
|
*/
|
|
408
|
-
constructor({
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
512
|
+
constructor(clientOptions: ClientOptions = {}) {
|
|
513
|
+
const { credential, options: normalizedOptions } = normalizeX509CredentialOptions(clientOptions);
|
|
514
|
+
clientOptions = normalizedOptions;
|
|
515
|
+
const residencyBaseURL = resolveDataResidency(clientOptions);
|
|
516
|
+
const provider = clientOptions.provider;
|
|
517
|
+
const {
|
|
518
|
+
baseURL = provider ? null : readEnv('OPENAI_BASE_URL'),
|
|
519
|
+
dataResidency: _dataResidency,
|
|
520
|
+
[inheritedDataResidencySelection]: inheritedResidencySelection = false,
|
|
521
|
+
apiKey = provider ? null : (readEnv('OPENAI_API_KEY') ?? null),
|
|
522
|
+
adminAPIKey = provider ? null : (readEnv('OPENAI_ADMIN_KEY') ?? null),
|
|
523
|
+
organization = provider ? null : (readEnv('OPENAI_ORG_ID') ?? null),
|
|
524
|
+
project = provider ? null : (readEnv('OPENAI_PROJECT_ID') ?? null),
|
|
525
|
+
webhookSecret = readEnv('OPENAI_WEBHOOK_SECRET') ?? null,
|
|
526
|
+
workloadIdentity,
|
|
527
|
+
x509Transport,
|
|
528
|
+
credential: _credential,
|
|
529
|
+
...opts
|
|
530
|
+
} = clientOptions as InternalClientOptions;
|
|
531
|
+
if (provider) {
|
|
532
|
+
const conflictingOptions = (
|
|
533
|
+
['apiKey', 'adminAPIKey', 'workloadIdentity', 'x509Transport', 'baseURL', 'dataResidency'] as const
|
|
534
|
+
).filter((key) => (key === 'workloadIdentity' ? workloadIdentity : clientOptions[key]) != null);
|
|
535
|
+
if (conflictingOptions.length) {
|
|
536
|
+
throw new Errors.OpenAIError(
|
|
537
|
+
`The \`provider\` option cannot be used with ${conflictingOptions
|
|
538
|
+
.map((key) => `\`${key}\``)
|
|
539
|
+
.join(', ')}. Configure authentication and the base URL through the provider instead.`,
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
const identity = isX509WorkloadIdentity(workloadIdentity)
|
|
544
|
+
? { x509: workloadIdentity, legacy: undefined }
|
|
545
|
+
: { x509: undefined, legacy: workloadIdentity };
|
|
546
|
+
const x509Identity = identity.x509;
|
|
547
|
+
const usesX509Identity = x509Identity !== undefined;
|
|
548
|
+
const providerRuntime = provider ? configureProvider(provider) : undefined;
|
|
418
549
|
const options: ClientOptions = {
|
|
419
550
|
apiKey,
|
|
420
551
|
adminAPIKey,
|
|
@@ -422,28 +553,59 @@ export class OpenAI {
|
|
|
422
553
|
project,
|
|
423
554
|
webhookSecret,
|
|
424
555
|
workloadIdentity,
|
|
556
|
+
x509Transport,
|
|
557
|
+
provider,
|
|
425
558
|
...opts,
|
|
426
|
-
baseURL:
|
|
559
|
+
baseURL:
|
|
560
|
+
providerRuntime?.baseURL ??
|
|
561
|
+
residencyBaseURL ??
|
|
562
|
+
(baseURL || (usesX509Identity ? X509_API_BASE_URL : `https://api.openai.com/v1`)),
|
|
427
563
|
};
|
|
428
564
|
|
|
565
|
+
if (x509Transport && !usesX509Identity) {
|
|
566
|
+
throw new Errors.OpenAIError('An X.509 transport requires an X.509 workload identity.');
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (usesX509Identity) {
|
|
570
|
+
if (residencyBaseURL !== undefined || inheritedResidencySelection) {
|
|
571
|
+
throw new Errors.OpenAIError('X.509 workload identity does not support data residency selection.');
|
|
572
|
+
}
|
|
573
|
+
if (clientOptions.fetch !== undefined) {
|
|
574
|
+
throw new Errors.OpenAIError(
|
|
575
|
+
'X.509 workload identity does not support a custom fetch implementation.',
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
assertX509APIOrigin(options.baseURL!);
|
|
579
|
+
assertX509RequestOptions(options.fetchOptions);
|
|
580
|
+
if (
|
|
581
|
+
this.fetchWithAuth !== OpenAI.prototype.fetchWithAuth ||
|
|
582
|
+
this.fetchWithTimeout !== OpenAI.prototype.fetchWithTimeout
|
|
583
|
+
) {
|
|
584
|
+
throw new Errors.OpenAIError(
|
|
585
|
+
'X.509 workload identity does not support overridden fetch dispatch hooks.',
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
429
590
|
if (apiKey && workloadIdentity) {
|
|
430
591
|
throw new Errors.OpenAIError('The `apiKey` and `workloadIdentity` options are mutually exclusive');
|
|
431
592
|
}
|
|
432
593
|
|
|
433
|
-
if (!apiKey && !adminAPIKey && !workloadIdentity) {
|
|
594
|
+
if (!providerRuntime && !apiKey && !adminAPIKey && !workloadIdentity) {
|
|
434
595
|
throw new Errors.OpenAIError(
|
|
435
596
|
'Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.',
|
|
436
597
|
);
|
|
437
598
|
}
|
|
438
599
|
|
|
439
|
-
if (!options.dangerouslyAllowBrowser &&
|
|
600
|
+
if (!options.dangerouslyAllowBrowser && isRunningInBrowserOrBrowserWorker()) {
|
|
440
601
|
throw new Errors.OpenAIError(
|
|
441
602
|
"It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n",
|
|
442
603
|
);
|
|
443
604
|
}
|
|
444
605
|
|
|
445
606
|
this.baseURL = options.baseURL!;
|
|
446
|
-
this
|
|
607
|
+
this.#explicitDataResidency = residencyBaseURL !== undefined || inheritedResidencySelection;
|
|
608
|
+
this.timeout = options.timeout ?? OpenAI.DEFAULT_TIMEOUT; /* 10 minutes */
|
|
447
609
|
this.logger = options.logger ?? console;
|
|
448
610
|
const defaultLogLevel = 'warn';
|
|
449
611
|
// Set default logLevel early so that we can log a warning in parseLogLevel.
|
|
@@ -457,7 +619,7 @@ export class OpenAI {
|
|
|
457
619
|
this.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
458
620
|
this.#encoder = Opts.FallbackEncoder;
|
|
459
621
|
|
|
460
|
-
const customHeadersEnv = readEnv('OPENAI_CUSTOM_HEADERS');
|
|
622
|
+
const customHeadersEnv = provider || credential ? undefined : readEnv('OPENAI_CUSTOM_HEADERS');
|
|
461
623
|
if (customHeadersEnv) {
|
|
462
624
|
const parsed: Record<string, string> = {};
|
|
463
625
|
for (const line of customHeadersEnv.split('\n')) {
|
|
@@ -470,9 +632,18 @@ export class OpenAI {
|
|
|
470
632
|
}
|
|
471
633
|
|
|
472
634
|
this._options = options;
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
635
|
+
this._provider = providerRuntime;
|
|
636
|
+
|
|
637
|
+
if (x509Identity) {
|
|
638
|
+
const authentication = new X509WorkloadIdentityAuth(x509Identity, x509Transport, organization, project);
|
|
639
|
+
this._workloadIdentityAuth = authentication;
|
|
640
|
+
this.#x509Authentication = authentication;
|
|
641
|
+
this.#x509Credential = credential;
|
|
642
|
+
this.#x509Fetch = authentication.fetch();
|
|
643
|
+
this.fetch = this.#x509Fetch;
|
|
644
|
+
markApprovedX509Client(this);
|
|
645
|
+
} else if (identity.legacy) {
|
|
646
|
+
this._workloadIdentityAuth = new WorkloadIdentityAuth(identity.legacy, this.fetch);
|
|
476
647
|
}
|
|
477
648
|
|
|
478
649
|
this.apiKey = typeof apiKey === 'string' ? apiKey : null;
|
|
@@ -486,23 +657,70 @@ export class OpenAI {
|
|
|
486
657
|
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
487
658
|
*/
|
|
488
659
|
withOptions(options: Partial<ClientOptions>): this {
|
|
489
|
-
const
|
|
660
|
+
const residencyBaseURL = resolveDataResidency(options);
|
|
661
|
+
const x509Authentication = this.#x509Authentication;
|
|
662
|
+
const inheritedOptions: ClientOptions = {
|
|
490
663
|
...this._options,
|
|
491
664
|
baseURL: this.baseURL,
|
|
492
665
|
maxRetries: this.maxRetries,
|
|
493
666
|
timeout: this.timeout,
|
|
494
667
|
logger: this.logger,
|
|
495
668
|
logLevel: this.logLevel,
|
|
496
|
-
fetch: this.fetch,
|
|
669
|
+
fetch: this.#x509Authentication ? undefined : this.fetch,
|
|
497
670
|
fetchOptions: this.fetchOptions,
|
|
498
671
|
apiKey: this._options.apiKey,
|
|
499
672
|
adminAPIKey: this.adminAPIKey,
|
|
500
|
-
workloadIdentity: this._options.workloadIdentity,
|
|
673
|
+
workloadIdentity: x509Authentication?.identitySnapshot() ?? this._options.workloadIdentity,
|
|
674
|
+
x509Transport: this._options.x509Transport,
|
|
501
675
|
organization: this.organization,
|
|
502
676
|
project: this.project,
|
|
503
677
|
webhookSecret: this.webhookSecret,
|
|
678
|
+
};
|
|
679
|
+
const { credential, provider } = prepareX509ClientClone(
|
|
680
|
+
inheritedOptions,
|
|
681
|
+
options,
|
|
682
|
+
this.#x509Credential,
|
|
683
|
+
x509Authentication !== undefined,
|
|
684
|
+
);
|
|
685
|
+
if (residencyBaseURL !== undefined) {
|
|
686
|
+
delete inheritedOptions.baseURL;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
const clientOptions: InternalClientOptions = {
|
|
690
|
+
...inheritedOptions,
|
|
504
691
|
...options,
|
|
505
|
-
|
|
692
|
+
credential,
|
|
693
|
+
provider,
|
|
694
|
+
[inheritedDataResidencySelection]:
|
|
695
|
+
this.#explicitDataResidency &&
|
|
696
|
+
residencyBaseURL === undefined &&
|
|
697
|
+
!hasOwn(options, 'baseURL') &&
|
|
698
|
+
options.credential === undefined &&
|
|
699
|
+
!provider,
|
|
700
|
+
};
|
|
701
|
+
const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)(clientOptions);
|
|
702
|
+
if (provider && new URL(client.baseURL).origin !== new URL(this.baseURL).origin) {
|
|
703
|
+
Object.assign(client._options, {
|
|
704
|
+
defaultHeaders: options.defaultHeaders,
|
|
705
|
+
defaultQuery: options.defaultQuery,
|
|
706
|
+
fetchOptions: options.fetchOptions,
|
|
707
|
+
fetch: options.fetch,
|
|
708
|
+
});
|
|
709
|
+
client.fetchOptions = options.fetchOptions;
|
|
710
|
+
client.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
711
|
+
client.organization = options.organization ?? null;
|
|
712
|
+
client.project = options.project ?? null;
|
|
713
|
+
}
|
|
714
|
+
if (
|
|
715
|
+
this.#x509Authentication &&
|
|
716
|
+
client.#x509Authentication &&
|
|
717
|
+
this.baseURL === client.baseURL &&
|
|
718
|
+
this.#x509Authentication.matches(client.#x509Authentication)
|
|
719
|
+
) {
|
|
720
|
+
client._workloadIdentityAuth = this.#x509Authentication;
|
|
721
|
+
client.#x509Authentication = this.#x509Authentication;
|
|
722
|
+
client.#x509Fetch = this.#x509Fetch;
|
|
723
|
+
}
|
|
506
724
|
return client;
|
|
507
725
|
}
|
|
508
726
|
|
|
@@ -510,13 +728,32 @@ export class OpenAI {
|
|
|
510
728
|
* Check whether the base URL is set to its default.
|
|
511
729
|
*/
|
|
512
730
|
#baseURLOverridden(): boolean {
|
|
513
|
-
return
|
|
731
|
+
return (
|
|
732
|
+
this.#explicitDataResidency ||
|
|
733
|
+
this._provider !== undefined ||
|
|
734
|
+
this.baseURL !== 'https://api.openai.com/v1'
|
|
735
|
+
);
|
|
514
736
|
}
|
|
515
737
|
|
|
516
738
|
protected defaultQuery(): Record<string, string | undefined> | undefined {
|
|
517
739
|
return this._options.defaultQuery;
|
|
518
740
|
}
|
|
519
741
|
|
|
742
|
+
/** @internal Client request headers for each new WebSocket handshake. */
|
|
743
|
+
_buildWebSocketHeaders(authHeaders: Record<string, string>): Record<string, string> {
|
|
744
|
+
return Object.fromEntries(
|
|
745
|
+
buildHeaders([
|
|
746
|
+
{
|
|
747
|
+
'User-Agent': this.getUserAgent(),
|
|
748
|
+
'OpenAI-Organization': this.organization,
|
|
749
|
+
'OpenAI-Project': this.project,
|
|
750
|
+
},
|
|
751
|
+
authHeaders,
|
|
752
|
+
this._options.defaultHeaders,
|
|
753
|
+
]).values,
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
|
|
520
757
|
protected validateHeaders(
|
|
521
758
|
{ values, nulls }: NullableHeaders,
|
|
522
759
|
schemes: { bearerAuth?: boolean; adminAPIKeyAuth?: boolean } = {
|
|
@@ -547,6 +784,14 @@ export class OpenAI {
|
|
|
547
784
|
adminAPIKeyAuth: true,
|
|
548
785
|
},
|
|
549
786
|
): Promise<NullableHeaders | undefined> {
|
|
787
|
+
const authentication = this.#x509Authentication ?? this._workloadIdentityAuth;
|
|
788
|
+
if (
|
|
789
|
+
authentication instanceof X509WorkloadIdentityAuth &&
|
|
790
|
+
schemes.adminAPIKeyAuth &&
|
|
791
|
+
this.adminAPIKey !== null
|
|
792
|
+
) {
|
|
793
|
+
return await this.adminAPIKeyAuth(opts);
|
|
794
|
+
}
|
|
550
795
|
return buildHeaders([
|
|
551
796
|
schemes.bearerAuth ? await this.bearerAuth(opts) : null,
|
|
552
797
|
schemes.adminAPIKeyAuth ? await this.adminAPIKeyAuth(opts) : null,
|
|
@@ -554,13 +799,46 @@ export class OpenAI {
|
|
|
554
799
|
}
|
|
555
800
|
|
|
556
801
|
protected async bearerAuth(opts: FinalRequestOptions): Promise<NullableHeaders | undefined> {
|
|
557
|
-
|
|
558
|
-
|
|
802
|
+
const authentication = this.#x509Authentication ?? this._workloadIdentityAuth;
|
|
803
|
+
if (authentication) {
|
|
804
|
+
if (authentication instanceof X509WorkloadIdentityAuth) {
|
|
805
|
+
if (
|
|
806
|
+
authentication === this._workloadIdentityAuth &&
|
|
807
|
+
(this.fetchWithAuth !== OpenAI.prototype.fetchWithAuth ||
|
|
808
|
+
this.fetchWithTimeout !== OpenAI.prototype.fetchWithTimeout)
|
|
809
|
+
) {
|
|
810
|
+
throw new Errors.OpenAIError(
|
|
811
|
+
'X.509 workload identity does not support overridden fetch dispatch hooks.',
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
const snapshots = authentication.headerSnapshots();
|
|
815
|
+
if (
|
|
816
|
+
!X509WorkloadIdentityAuth.shouldAuthenticate(
|
|
817
|
+
opts,
|
|
818
|
+
snapshots.defaultHeaders,
|
|
819
|
+
snapshots.requestHeaders,
|
|
820
|
+
)
|
|
821
|
+
) {
|
|
822
|
+
return undefined;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
const token =
|
|
826
|
+
authentication instanceof X509WorkloadIdentityAuth
|
|
827
|
+
? await authentication.getToken(opts, {
|
|
828
|
+
apiURL: authentication.requestAPIURL(),
|
|
829
|
+
...authentication.headerSnapshots(),
|
|
830
|
+
...authentication.requestSnapshot(),
|
|
831
|
+
signal: authentication.effectiveSignal(),
|
|
832
|
+
...authentication.tenantSnapshot(),
|
|
833
|
+
})
|
|
834
|
+
: await authentication.getToken();
|
|
835
|
+
return buildHeaders([{ Authorization: `Bearer ${token}` }]);
|
|
559
836
|
}
|
|
560
|
-
|
|
837
|
+
const { apiKey } = await resolveRealtimeAPIKey(this);
|
|
838
|
+
if (apiKey == null) {
|
|
561
839
|
return undefined;
|
|
562
840
|
}
|
|
563
|
-
return buildHeaders([{ Authorization: `Bearer ${
|
|
841
|
+
return buildHeaders([{ Authorization: `Bearer ${apiKey}` }]);
|
|
564
842
|
}
|
|
565
843
|
|
|
566
844
|
protected async adminAPIKeyAuth(opts: FinalRequestOptions): Promise<NullableHeaders | undefined> {
|
|
@@ -588,12 +866,34 @@ export class OpenAI {
|
|
|
588
866
|
message: string | undefined,
|
|
589
867
|
headers: Headers,
|
|
590
868
|
): Errors.APIError {
|
|
591
|
-
|
|
869
|
+
const normalizedError =
|
|
870
|
+
error && typeof error === 'object' && (error as { error?: unknown }).error == null ? { error } : error;
|
|
871
|
+
return Errors.APIError.generate(status, normalizedError, message, headers);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
_hasApiKeyProvider(): boolean {
|
|
875
|
+
return typeof this._options.apiKey === 'function';
|
|
592
876
|
}
|
|
593
877
|
|
|
594
|
-
|
|
878
|
+
/**
|
|
879
|
+
* Resolves a function-based API key and retains the resolved value on this client.
|
|
880
|
+
* Returns whether a provider was invoked. Internal callers can capture this
|
|
881
|
+
* invocation's key before another request updates the shared `apiKey` property.
|
|
882
|
+
* Overrides should forward `capture` or invoke it with their own resolved key
|
|
883
|
+
* to preserve invocation-local credentials in concurrent requests and Realtime factories.
|
|
884
|
+
* @internal
|
|
885
|
+
*/
|
|
886
|
+
async _callApiKey(capture?: (apiKey: string | null) => void): Promise<boolean> {
|
|
887
|
+
if (this._provider) {
|
|
888
|
+
capture?.(this.apiKey);
|
|
889
|
+
return false;
|
|
890
|
+
}
|
|
891
|
+
|
|
595
892
|
const apiKey = this._options.apiKey;
|
|
596
|
-
if (typeof apiKey !== 'function')
|
|
893
|
+
if (typeof apiKey !== 'function') {
|
|
894
|
+
capture?.(this.apiKey);
|
|
895
|
+
return false;
|
|
896
|
+
}
|
|
597
897
|
|
|
598
898
|
let token: unknown;
|
|
599
899
|
try {
|
|
@@ -613,6 +913,7 @@ export class OpenAI {
|
|
|
613
913
|
);
|
|
614
914
|
}
|
|
615
915
|
this.apiKey = token;
|
|
916
|
+
capture?.(this.apiKey);
|
|
616
917
|
return true;
|
|
617
918
|
}
|
|
618
919
|
|
|
@@ -622,9 +923,8 @@ export class OpenAI {
|
|
|
622
923
|
defaultBaseURL?: string | undefined,
|
|
623
924
|
): string {
|
|
624
925
|
const baseURL = (!this.#baseURLOverridden() && defaultBaseURL) || this.baseURL;
|
|
625
|
-
const url =
|
|
626
|
-
|
|
627
|
-
new URL(path)
|
|
926
|
+
const url = isAbsoluteURL(path)
|
|
927
|
+
? new URL(path)
|
|
628
928
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
629
929
|
|
|
630
930
|
const defaultQuery = this.defaultQuery();
|
|
@@ -642,13 +942,11 @@ export class OpenAI {
|
|
|
642
942
|
|
|
643
943
|
/**
|
|
644
944
|
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
945
|
+
* Function-based credentials are resolved later, when building authentication
|
|
946
|
+
* headers, including for direct `buildRequest()` calls. Overriding this hook
|
|
947
|
+
* does not bypass that resolution.
|
|
645
948
|
*/
|
|
646
|
-
protected async prepareOptions(options: FinalRequestOptions): Promise<void> {
|
|
647
|
-
const security = options.__security ?? { bearerAuth: true };
|
|
648
|
-
if (security.bearerAuth) {
|
|
649
|
-
await this._callApiKey();
|
|
650
|
-
}
|
|
651
|
-
}
|
|
949
|
+
protected async prepareOptions(options: FinalRequestOptions): Promise<void> {}
|
|
652
950
|
|
|
653
951
|
/**
|
|
654
952
|
* Used as a callback for mutating the given `RequestInit` object.
|
|
@@ -697,7 +995,193 @@ export class OpenAI {
|
|
|
697
995
|
options: PromiseOrValue<FinalRequestOptions>,
|
|
698
996
|
remainingRetries: number | null = null,
|
|
699
997
|
): APIPromise<Rsp> {
|
|
700
|
-
|
|
998
|
+
const authentication = this.#x509Authentication ?? this._workloadIdentityAuth;
|
|
999
|
+
const request =
|
|
1000
|
+
authentication instanceof X509WorkloadIdentityAuth
|
|
1001
|
+
? Promise.resolve(options).then((resolved) =>
|
|
1002
|
+
authentication.runRequest(() => this.makeRequest(resolved, remainingRetries, undefined), this),
|
|
1003
|
+
)
|
|
1004
|
+
: this.makeRequest(options, remainingRetries, undefined);
|
|
1005
|
+
return this.responsePromise<Rsp>(request);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
private responsePromise<Rsp>(
|
|
1009
|
+
request: Promise<APIResponseProps>,
|
|
1010
|
+
parse: (client: OpenAI, props: APIResponseProps) => Promise<any> = (client, props) =>
|
|
1011
|
+
this.parseResponseWithTimeout<Rsp>(client, props),
|
|
1012
|
+
): APIPromise<Rsp> {
|
|
1013
|
+
const promise = new APIPromise<Rsp>(this, request, (client, props) => {
|
|
1014
|
+
const resume = this.#responseAttempts.get(props.controller)?.continueRequest;
|
|
1015
|
+
return resume ? resume(() => parse(client, props)) : parse(client, props);
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
// A body timeout can retry after the original raw response has arrived. Wait for
|
|
1019
|
+
// parsing before selecting the response so withResponse() reports the retry.
|
|
1020
|
+
promise.withResponse = async () => {
|
|
1021
|
+
const data = await promise;
|
|
1022
|
+
const { response } = await request;
|
|
1023
|
+
return { data, response, request_id: response.headers.get('x-request-id') };
|
|
1024
|
+
};
|
|
1025
|
+
promise._thenUnwrap = <Next>(transform: (data: Rsp, props: APIResponseProps) => Next) =>
|
|
1026
|
+
this.responsePromise<Next>(request, async (client, props) =>
|
|
1027
|
+
addRequestID(transform(await parse(client, props), props), props.response),
|
|
1028
|
+
);
|
|
1029
|
+
|
|
1030
|
+
return promise;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
private async parseResponseWithTimeout<Rsp>(client: OpenAI, props: APIResponseProps): Promise<any> {
|
|
1034
|
+
if (
|
|
1035
|
+
props.options.stream ||
|
|
1036
|
+
props.options.__binaryResponse ||
|
|
1037
|
+
props.response.status === 204 ||
|
|
1038
|
+
props.response.headers.get('content-length') === '0'
|
|
1039
|
+
) {
|
|
1040
|
+
return defaultParseResponse<Rsp>(client, props);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
while (true) {
|
|
1044
|
+
const attempt = this.#responseAttempts.get(props.controller);
|
|
1045
|
+
const timeout = attempt?.timeout ?? props.options.timeout ?? this.timeout;
|
|
1046
|
+
const x509Authentication = attempt?.authentication;
|
|
1047
|
+
const callerSignal = x509Authentication ? props.controller.signal : props.options.signal;
|
|
1048
|
+
const abortError = () =>
|
|
1049
|
+
x509Authentication && callerSignal
|
|
1050
|
+
? this._makeUserAbortError(callerSignal)
|
|
1051
|
+
: new Errors.APIUserAbortError();
|
|
1052
|
+
let remaining: number;
|
|
1053
|
+
try {
|
|
1054
|
+
remaining =
|
|
1055
|
+
x509Authentication?.remainingTimeout(props.options, timeout) ??
|
|
1056
|
+
Math.max(0, props.startTime + timeout - Date.now());
|
|
1057
|
+
} catch (error) {
|
|
1058
|
+
const cancellation = callerSignal?.aborted ? abortError() : undefined;
|
|
1059
|
+
props.controller.abort();
|
|
1060
|
+
void Shims.CancelReadableStream(props.response.body).catch(() => undefined);
|
|
1061
|
+
throw cancellation ?? error;
|
|
1062
|
+
}
|
|
1063
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
1064
|
+
let abortListener: (() => void) | undefined;
|
|
1065
|
+
let timedOut = false;
|
|
1066
|
+
|
|
1067
|
+
try {
|
|
1068
|
+
// Tool runners preserve a completed buffered turn before cancellation stops the next request.
|
|
1069
|
+
if (callerSignal?.aborted && attempt?.helperMethod !== 'runTools') {
|
|
1070
|
+
throw abortError();
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
1074
|
+
timer = setTimeout(() => {
|
|
1075
|
+
timedOut = true;
|
|
1076
|
+
props.controller.abort();
|
|
1077
|
+
reject(new Errors.APIConnectionTimeoutError());
|
|
1078
|
+
}, remaining);
|
|
1079
|
+
|
|
1080
|
+
if (callerSignal) {
|
|
1081
|
+
abortListener = () => {
|
|
1082
|
+
if (!timedOut) reject(abortError());
|
|
1083
|
+
};
|
|
1084
|
+
callerSignal.addEventListener('abort', abortListener, { once: true });
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
return await Promise.race([defaultParseResponse<Rsp>(client, props), timeoutPromise]);
|
|
1089
|
+
} catch (error) {
|
|
1090
|
+
if (callerSignal?.aborted && !timedOut) {
|
|
1091
|
+
throw abortError();
|
|
1092
|
+
}
|
|
1093
|
+
if (!timedOut) {
|
|
1094
|
+
if (x509Authentication && error instanceof SyntaxError) {
|
|
1095
|
+
throw new SyntaxError('X.509 workload identity API response contains invalid JSON.');
|
|
1096
|
+
}
|
|
1097
|
+
if (x509Authentication && !(error instanceof Errors.OpenAIError)) {
|
|
1098
|
+
throw new Errors.APIConnectionError({
|
|
1099
|
+
message: 'X.509 workload identity API response body could not be read.',
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
throw error;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
const retriesRemaining = attempt?.retriesRemaining ?? 0;
|
|
1106
|
+
if (
|
|
1107
|
+
!retriesRemaining ||
|
|
1108
|
+
attempt?.hasStreamingBody ||
|
|
1109
|
+
props.options.__metadata?.['hasStreamingBody'] ||
|
|
1110
|
+
((globalThis as any).ReadableStream &&
|
|
1111
|
+
props.options.body instanceof (globalThis as any).ReadableStream) ||
|
|
1112
|
+
(typeof props.options.body === 'object' &&
|
|
1113
|
+
props.options.body !== null &&
|
|
1114
|
+
(Symbol.asyncIterator in props.options.body ||
|
|
1115
|
+
(Symbol.iterator in props.options.body &&
|
|
1116
|
+
'next' in props.options.body &&
|
|
1117
|
+
typeof props.options.body.next === 'function')))
|
|
1118
|
+
) {
|
|
1119
|
+
throw new Errors.APIConnectionTimeoutError();
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
if (timer !== undefined) clearTimeout(timer);
|
|
1123
|
+
if (abortListener) callerSignal?.removeEventListener('abort', abortListener);
|
|
1124
|
+
abortListener = undefined;
|
|
1125
|
+
|
|
1126
|
+
const next = await this.retryRequest(
|
|
1127
|
+
props.options,
|
|
1128
|
+
retriesRemaining,
|
|
1129
|
+
props.retryOfRequestLogID ?? props.requestLogID,
|
|
1130
|
+
undefined,
|
|
1131
|
+
props.requestSignal,
|
|
1132
|
+
);
|
|
1133
|
+
Object.assign(props, next);
|
|
1134
|
+
} finally {
|
|
1135
|
+
if (timer !== undefined) clearTimeout(timer);
|
|
1136
|
+
if (abortListener) callerSignal?.removeEventListener('abort', abortListener);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/** Keeps terminal X.509 error-body consumption inside the original logical request deadline. */
|
|
1142
|
+
private async readX509ResponseError(
|
|
1143
|
+
response: Response,
|
|
1144
|
+
options: FinalRequestOptions,
|
|
1145
|
+
timeout: number,
|
|
1146
|
+
controller: AbortController,
|
|
1147
|
+
authentication: X509WorkloadIdentityAuth,
|
|
1148
|
+
): Promise<string> {
|
|
1149
|
+
const deadline = new AbortController();
|
|
1150
|
+
const callerSignal = controller.signal;
|
|
1151
|
+
let timedOut = false;
|
|
1152
|
+
const cancel = () => deadline.abort(callerSignal.reason);
|
|
1153
|
+
callerSignal.addEventListener('abort', cancel, { once: true });
|
|
1154
|
+
if (callerSignal.aborted) {
|
|
1155
|
+
cancel();
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
try {
|
|
1159
|
+
const remaining = authentication.remainingTimeout(options, timeout);
|
|
1160
|
+
const expiration = authentication.waitForRetry(remaining, deadline.signal).then(() => {
|
|
1161
|
+
throw new Errors.APIConnectionTimeoutError();
|
|
1162
|
+
});
|
|
1163
|
+
const body = await Promise.race([
|
|
1164
|
+
response.text().catch(() => 'X.509 workload identity API response body could not be read.'),
|
|
1165
|
+
expiration,
|
|
1166
|
+
]);
|
|
1167
|
+
if (callerSignal.aborted) {
|
|
1168
|
+
throw this._makeUserAbortError(callerSignal);
|
|
1169
|
+
}
|
|
1170
|
+
return body;
|
|
1171
|
+
} catch (error) {
|
|
1172
|
+
if (error instanceof Errors.APIConnectionTimeoutError) {
|
|
1173
|
+
timedOut = !callerSignal.aborted;
|
|
1174
|
+
controller.abort();
|
|
1175
|
+
void Shims.CancelReadableStream(response.body).catch(() => undefined);
|
|
1176
|
+
}
|
|
1177
|
+
if (callerSignal.aborted && !timedOut) {
|
|
1178
|
+
throw this._makeUserAbortError(callerSignal);
|
|
1179
|
+
}
|
|
1180
|
+
throw error;
|
|
1181
|
+
} finally {
|
|
1182
|
+
callerSignal.removeEventListener('abort', cancel);
|
|
1183
|
+
deadline.abort();
|
|
1184
|
+
}
|
|
701
1185
|
}
|
|
702
1186
|
|
|
703
1187
|
private async makeRequest(
|
|
@@ -711,43 +1195,131 @@ export class OpenAI {
|
|
|
711
1195
|
retriesRemaining = maxRetries;
|
|
712
1196
|
}
|
|
713
1197
|
|
|
1198
|
+
const x509Authentication = this.#x509Authentication;
|
|
1199
|
+
x509Authentication?.beginRequestPreparation();
|
|
714
1200
|
await this.prepareOptions(options);
|
|
715
1201
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
1202
|
+
x509Authentication?.beginRequestPlanning();
|
|
1203
|
+
let built: { req: FinalizedRequestInit; url: string; timeout: number };
|
|
1204
|
+
try {
|
|
1205
|
+
const candidate = await this.buildRequest(options, {
|
|
1206
|
+
retryCount: maxRetries - retriesRemaining,
|
|
1207
|
+
});
|
|
1208
|
+
built = { req: candidate.req, url: candidate.url, timeout: candidate.timeout };
|
|
1209
|
+
if (x509Authentication) {
|
|
1210
|
+
validatePositiveInteger('timeout', built.timeout);
|
|
1211
|
+
x509Authentication.authorizePlannedRequest(built.url, built.req, built.timeout);
|
|
1212
|
+
if (X509WorkloadIdentityAuth.isStreamingRequestBody(built.req.body)) {
|
|
1213
|
+
options.__metadata = { ...options.__metadata, hasStreamingBody: true };
|
|
1214
|
+
}
|
|
1215
|
+
await this.prepareRequest(built.req, { url: built.url, options });
|
|
1216
|
+
await this._provider?.prepareRequest?.(built.req, { url: built.url, options });
|
|
1217
|
+
x509Authentication.beginRequestPlanning();
|
|
1218
|
+
x509Authentication.authorizePlannedRequest(built.url, built.req, built.timeout, true);
|
|
1219
|
+
if (X509WorkloadIdentityAuth.isStreamingRequestBody(built.req.body)) {
|
|
1220
|
+
options.__metadata = { ...options.__metadata, hasStreamingBody: true };
|
|
1221
|
+
}
|
|
1222
|
+
const callerSignal = x509Authentication.requestSnapshot().signal;
|
|
1223
|
+
if (callerSignal?.aborted || built.req.signal?.aborted) {
|
|
1224
|
+
throw this._makeUserAbortError(callerSignal?.aborted ? callerSignal : built.req.signal!);
|
|
1225
|
+
}
|
|
1226
|
+
x509Authentication.setEffectiveSignal(
|
|
1227
|
+
built.req.signal || callerSignal
|
|
1228
|
+
? createRequestController(built.req.signal ?? callerSignal, callerSignal).signal
|
|
1229
|
+
: undefined,
|
|
1230
|
+
);
|
|
1231
|
+
x509Authentication.beginRequestNetwork();
|
|
1232
|
+
const security = options.__security ?? { bearerAuth: true };
|
|
1233
|
+
const authenticationHeaders = await this.authHeaders(options, security);
|
|
1234
|
+
const suppliedHeaders = x509Authentication.headerSnapshots();
|
|
1235
|
+
const supplied = buildHeaders([suppliedHeaders.defaultHeaders, suppliedHeaders.requestHeaders]);
|
|
1236
|
+
for (const [name, value] of authenticationHeaders?.values ?? []) {
|
|
1237
|
+
if (!supplied.nulls.has(name) && !built.req.headers.has(name)) {
|
|
1238
|
+
built.req.headers.set(name, value);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
this.validateHeaders(buildHeaders([supplied, built.req.headers]), security);
|
|
1242
|
+
}
|
|
1243
|
+
} catch (error) {
|
|
1244
|
+
x509Authentication?.retireRequestBody();
|
|
1245
|
+
if (
|
|
1246
|
+
x509Authentication &&
|
|
1247
|
+
retriesRemaining &&
|
|
1248
|
+
!options.__metadata?.['hasStreamingBody'] &&
|
|
1249
|
+
X509WorkloadIdentityAuth.isRetryableFailure(error)
|
|
1250
|
+
) {
|
|
1251
|
+
return await this.retryRequest(
|
|
1252
|
+
options,
|
|
1253
|
+
retriesRemaining,
|
|
1254
|
+
retryOfRequestLogID ?? 'x509-token-exchange',
|
|
1255
|
+
X509WorkloadIdentityAuth.retryHeaders(error),
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
throw error;
|
|
1259
|
+
}
|
|
1260
|
+
const { req, url } = built;
|
|
1261
|
+
const timeout = x509Authentication
|
|
1262
|
+
? Math.min(built.timeout, x509Authentication.requestSnapshot().timeout)
|
|
1263
|
+
: built.timeout;
|
|
1264
|
+
x509Authentication?.bindRequest(options, req, this.adminAPIKey);
|
|
1265
|
+
let hasStreamingBody = options.__metadata?.['hasStreamingBody'] === true;
|
|
1266
|
+
|
|
1267
|
+
if (!x509Authentication) {
|
|
1268
|
+
await this.prepareRequest(req, { url, options });
|
|
1269
|
+
await this._provider?.prepareRequest?.(req, { url, options });
|
|
1270
|
+
}
|
|
1271
|
+
x509Authentication?.adoptRequestHeaders(req);
|
|
1272
|
+
if (x509Authentication && X509WorkloadIdentityAuth.isStreamingRequestBody(req.body)) {
|
|
1273
|
+
hasStreamingBody = true;
|
|
1274
|
+
}
|
|
721
1275
|
|
|
722
1276
|
/** Not an API request ID, just for correlating local log entries. */
|
|
723
1277
|
const requestLogID = 'log_' + ((Math.random() * (1 << 24)) | 0).toString(16).padStart(6, '0');
|
|
724
1278
|
const retryLogStr = retryOfRequestLogID === undefined ? '' : `, retryOf: ${retryOfRequestLogID}`;
|
|
725
|
-
const startTime = Date.now();
|
|
1279
|
+
const startTime = x509Authentication?.requestStartedAt(options) ?? Date.now();
|
|
726
1280
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
1281
|
+
if (this.logLevel === 'debug') {
|
|
1282
|
+
// Summarize serialized strings without reparsing or re-running caller serialization hooks.
|
|
1283
|
+
const body = typeof req.body === 'string' ? { type: 'string', length: req.body.length } : req.body;
|
|
1284
|
+
loggerFor(this).debug(
|
|
1285
|
+
`[${requestLogID}] sending request`,
|
|
1286
|
+
formatRequestDetails({
|
|
1287
|
+
retryOfRequestLogID,
|
|
1288
|
+
method: options.method,
|
|
1289
|
+
url,
|
|
1290
|
+
options: x509Authentication
|
|
1291
|
+
? { body, ...x509Authentication.requestSnapshot() }
|
|
1292
|
+
: { ...options, body },
|
|
1293
|
+
headers: req.headers,
|
|
1294
|
+
}),
|
|
1295
|
+
);
|
|
740
1296
|
}
|
|
741
1297
|
|
|
1298
|
+
const callerSignal = x509Authentication ? x509Authentication.requestSnapshot().signal : options.signal;
|
|
1299
|
+
if (callerSignal?.aborted || req.signal?.aborted) {
|
|
1300
|
+
throw this._makeUserAbortError(callerSignal?.aborted ? callerSignal : req.signal!);
|
|
1301
|
+
}
|
|
742
1302
|
const security = options.__security ?? { bearerAuth: true };
|
|
743
|
-
|
|
744
|
-
const
|
|
1303
|
+
// Request hooks may replace the caller signal before it reaches fetch.
|
|
1304
|
+
const controller =
|
|
1305
|
+
x509Authentication || this.fetchWithTimeout === OpenAI.prototype.fetchWithTimeout
|
|
1306
|
+
? createRequestController(
|
|
1307
|
+
req.signal ?? (x509Authentication ? callerSignal : undefined),
|
|
1308
|
+
x509Authentication ? callerSignal : undefined,
|
|
1309
|
+
)
|
|
1310
|
+
: new AbortController();
|
|
1311
|
+
const remainingTimeout = x509Authentication?.remainingTimeout(options, timeout) ?? timeout;
|
|
1312
|
+
const fetchWithAuth = x509Authentication ? OpenAI.prototype.fetchWithAuth : this.fetchWithAuth;
|
|
1313
|
+
x509Authentication?.releaseRequestBody(req.body);
|
|
1314
|
+
const response = await fetchWithAuth
|
|
1315
|
+
.call(this, url, req, remainingTimeout, controller, security)
|
|
1316
|
+
.catch(castToError);
|
|
745
1317
|
const headersTime = Date.now();
|
|
746
1318
|
|
|
747
1319
|
if (response instanceof globalThis.Error) {
|
|
748
1320
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
749
|
-
if (
|
|
750
|
-
throw
|
|
1321
|
+
if (callerSignal?.aborted || req.signal?.aborted) {
|
|
1322
|
+
throw this._makeUserAbortError(callerSignal?.aborted ? callerSignal : req.signal!);
|
|
751
1323
|
}
|
|
752
1324
|
// detect native connection timeout errors
|
|
753
1325
|
// deno throws "TypeError: error sending request for url (https://example/): client error (Connect): tcp connect error: Operation timed out (os error 60): Operation timed out (os error 60)"
|
|
@@ -756,7 +1328,11 @@ export class OpenAI {
|
|
|
756
1328
|
const isTimeout =
|
|
757
1329
|
isAbortError(response) ||
|
|
758
1330
|
/timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : ''));
|
|
759
|
-
if (
|
|
1331
|
+
if (
|
|
1332
|
+
retriesRemaining &&
|
|
1333
|
+
!hasStreamingBody &&
|
|
1334
|
+
(!x509Authentication || isTransientX509ConnectionError(response))
|
|
1335
|
+
) {
|
|
760
1336
|
loggerFor(this).info(
|
|
761
1337
|
`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`,
|
|
762
1338
|
);
|
|
@@ -766,28 +1342,56 @@ export class OpenAI {
|
|
|
766
1342
|
retryOfRequestLogID,
|
|
767
1343
|
url,
|
|
768
1344
|
durationMs: headersTime - startTime,
|
|
769
|
-
message: response.message,
|
|
1345
|
+
message: x509Authentication ? 'X.509 workload identity API connection failed.' : response.message,
|
|
770
1346
|
}),
|
|
771
1347
|
);
|
|
772
|
-
return this.retryRequest(
|
|
1348
|
+
return this.retryRequest(
|
|
1349
|
+
options,
|
|
1350
|
+
retriesRemaining,
|
|
1351
|
+
retryOfRequestLogID ?? requestLogID,
|
|
1352
|
+
undefined,
|
|
1353
|
+
req.signal,
|
|
1354
|
+
);
|
|
773
1355
|
}
|
|
1356
|
+
const terminalMessage = hasStreamingBody
|
|
1357
|
+
? 'error; streaming body cannot be retried'
|
|
1358
|
+
: 'error; no more retries left';
|
|
774
1359
|
loggerFor(this).info(
|
|
775
|
-
`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} -
|
|
1360
|
+
`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${terminalMessage}`,
|
|
776
1361
|
);
|
|
777
1362
|
loggerFor(this).debug(
|
|
778
|
-
`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (
|
|
1363
|
+
`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${terminalMessage})`,
|
|
779
1364
|
formatRequestDetails({
|
|
780
1365
|
retryOfRequestLogID,
|
|
781
1366
|
url,
|
|
782
1367
|
durationMs: headersTime - startTime,
|
|
783
|
-
message: response.message,
|
|
1368
|
+
message: x509Authentication ? 'X.509 workload identity API connection failed.' : response.message,
|
|
784
1369
|
}),
|
|
785
1370
|
);
|
|
786
1371
|
if (response instanceof OAuthError || response instanceof SubjectTokenProviderError) {
|
|
787
1372
|
throw response;
|
|
788
1373
|
}
|
|
789
1374
|
if (isTimeout) {
|
|
790
|
-
|
|
1375
|
+
const transportCause = 'cause' in response ? response.cause : undefined;
|
|
1376
|
+
const isHeadersTimeout =
|
|
1377
|
+
typeof transportCause === 'object' &&
|
|
1378
|
+
transportCause !== null &&
|
|
1379
|
+
'code' in transportCause &&
|
|
1380
|
+
transportCause.code === 'UND_ERR_HEADERS_TIMEOUT';
|
|
1381
|
+
const timeoutError = isHeadersTimeout
|
|
1382
|
+
? new Errors.APIConnectionTimeoutError({
|
|
1383
|
+
message:
|
|
1384
|
+
'Request timed out. Node.js fetch timed out waiting for response headers; ' +
|
|
1385
|
+
'configure a matching undici fetch and fetchOptions.dispatcher with an Agent whose headersTimeout is at least the SDK timeout.',
|
|
1386
|
+
})
|
|
1387
|
+
: new Errors.APIConnectionTimeoutError();
|
|
1388
|
+
if (x509Authentication) {
|
|
1389
|
+
throw new Errors.APIConnectionTimeoutError();
|
|
1390
|
+
}
|
|
1391
|
+
throw Object.assign(timeoutError, { cause: response });
|
|
1392
|
+
}
|
|
1393
|
+
if (x509Authentication) {
|
|
1394
|
+
throw new Errors.APIConnectionError({ message: 'X.509 workload identity API connection failed.' });
|
|
791
1395
|
}
|
|
792
1396
|
throw new Errors.APIConnectionError({
|
|
793
1397
|
message: getConnectionErrorMessage(response),
|
|
@@ -799,40 +1403,62 @@ export class OpenAI {
|
|
|
799
1403
|
.filter(([name]) => name === 'x-request-id')
|
|
800
1404
|
.map(([name, value]) => ', ' + name + ': ' + JSON.stringify(value))
|
|
801
1405
|
.join('');
|
|
802
|
-
const responseInfo = `[${requestLogID}${retryLogStr}${specialHeaders}] ${req.method} ${url} ${
|
|
1406
|
+
const responseInfo = `[${requestLogID}${retryLogStr}${specialHeaders}] ${req.method} ${redactURL(url)} ${
|
|
803
1407
|
response.ok ? 'succeeded' : 'failed'
|
|
804
1408
|
} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
805
1409
|
|
|
806
1410
|
if (!response.ok) {
|
|
1411
|
+
const rejectedX509Credential =
|
|
1412
|
+
response.status === 401 &&
|
|
1413
|
+
x509Authentication &&
|
|
1414
|
+
security.bearerAuth &&
|
|
1415
|
+
x509Authentication.usedWorkloadToken(options);
|
|
1416
|
+
if (rejectedX509Credential) {
|
|
1417
|
+
x509Authentication.invalidateToken();
|
|
1418
|
+
}
|
|
807
1419
|
if (
|
|
808
1420
|
response.status === 401 &&
|
|
809
|
-
this._workloadIdentityAuth &&
|
|
1421
|
+
(x509Authentication || this._workloadIdentityAuth) &&
|
|
810
1422
|
security.bearerAuth &&
|
|
811
|
-
!options
|
|
1423
|
+
(!x509Authentication || x509Authentication.usedWorkloadToken(options)) &&
|
|
1424
|
+
(!x509Authentication || retriesRemaining > 0) &&
|
|
1425
|
+
!hasStreamingBody &&
|
|
812
1426
|
!options.__metadata?.['workloadIdentityTokenRefreshed']
|
|
813
1427
|
) {
|
|
814
|
-
|
|
815
|
-
|
|
1428
|
+
if (x509Authentication) {
|
|
1429
|
+
void Shims.CancelReadableStream(response.body).catch(() => undefined);
|
|
1430
|
+
} else {
|
|
1431
|
+
await Shims.CancelReadableStream(response.body);
|
|
1432
|
+
this._workloadIdentityAuth?.invalidateToken();
|
|
1433
|
+
}
|
|
816
1434
|
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
__metadata
|
|
821
|
-
|
|
822
|
-
workloadIdentityTokenRefreshed: true,
|
|
823
|
-
},
|
|
1435
|
+
const replayOptions = {
|
|
1436
|
+
...options,
|
|
1437
|
+
__metadata: {
|
|
1438
|
+
...options.__metadata,
|
|
1439
|
+
workloadIdentityTokenRefreshed: true,
|
|
824
1440
|
},
|
|
825
|
-
|
|
1441
|
+
};
|
|
1442
|
+
return this.makeRequest(
|
|
1443
|
+
replayOptions,
|
|
1444
|
+
x509Authentication ? retriesRemaining - 1 : retriesRemaining,
|
|
826
1445
|
retryOfRequestLogID ?? requestLogID,
|
|
827
1446
|
);
|
|
828
1447
|
}
|
|
829
1448
|
|
|
830
|
-
const shouldRetry =
|
|
831
|
-
|
|
1449
|
+
const shouldRetry =
|
|
1450
|
+
rejectedX509Credential && options.__metadata?.['workloadIdentityTokenRefreshed']
|
|
1451
|
+
? false
|
|
1452
|
+
: await this.shouldRetry(response);
|
|
1453
|
+
if (retriesRemaining && shouldRetry && !hasStreamingBody) {
|
|
832
1454
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
833
1455
|
|
|
834
1456
|
// We don't need the body of this response.
|
|
835
|
-
|
|
1457
|
+
if (x509Authentication) {
|
|
1458
|
+
void Shims.CancelReadableStream(response.body).catch(() => undefined);
|
|
1459
|
+
} else {
|
|
1460
|
+
await Shims.CancelReadableStream(response.body);
|
|
1461
|
+
}
|
|
836
1462
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
837
1463
|
loggerFor(this).debug(
|
|
838
1464
|
`[${requestLogID}] response error (${retryMessage})`,
|
|
@@ -849,14 +1475,21 @@ export class OpenAI {
|
|
|
849
1475
|
retriesRemaining,
|
|
850
1476
|
retryOfRequestLogID ?? requestLogID,
|
|
851
1477
|
response.headers,
|
|
1478
|
+
req.signal,
|
|
852
1479
|
);
|
|
853
1480
|
}
|
|
854
1481
|
|
|
855
|
-
const retryMessage = shouldRetry
|
|
1482
|
+
const retryMessage = shouldRetry
|
|
1483
|
+
? hasStreamingBody
|
|
1484
|
+
? `error; streaming body cannot be retried`
|
|
1485
|
+
: `error; no more retries left`
|
|
1486
|
+
: `error; not retryable`;
|
|
856
1487
|
|
|
857
1488
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
858
1489
|
|
|
859
|
-
const errText =
|
|
1490
|
+
const errText = x509Authentication
|
|
1491
|
+
? await this.readX509ResponseError(response, options, timeout, controller, x509Authentication)
|
|
1492
|
+
: await response.text().catch((err: any) => castToError(err).message);
|
|
860
1493
|
const errJSON = safeJSON(errText) as any;
|
|
861
1494
|
const errMessage = errJSON ? undefined : errText;
|
|
862
1495
|
|
|
@@ -888,7 +1521,25 @@ export class OpenAI {
|
|
|
888
1521
|
}),
|
|
889
1522
|
);
|
|
890
1523
|
|
|
891
|
-
|
|
1524
|
+
const continueRequest = x509Authentication?.continuation();
|
|
1525
|
+
x509Authentication?.releaseRequestCredentials();
|
|
1526
|
+
this.#responseAttempts.set(controller, {
|
|
1527
|
+
timeout,
|
|
1528
|
+
retriesRemaining,
|
|
1529
|
+
hasStreamingBody,
|
|
1530
|
+
...(x509Authentication ? { authentication: x509Authentication } : {}),
|
|
1531
|
+
helperMethod: options.__metadata?.['helperMethod'],
|
|
1532
|
+
...(continueRequest ? { continueRequest } : {}),
|
|
1533
|
+
});
|
|
1534
|
+
return {
|
|
1535
|
+
response,
|
|
1536
|
+
options,
|
|
1537
|
+
controller,
|
|
1538
|
+
requestSignal: req.signal,
|
|
1539
|
+
requestLogID,
|
|
1540
|
+
retryOfRequestLogID,
|
|
1541
|
+
startTime,
|
|
1542
|
+
};
|
|
892
1543
|
}
|
|
893
1544
|
|
|
894
1545
|
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
|
|
@@ -898,9 +1549,9 @@ export class OpenAI {
|
|
|
898
1549
|
): Pagination.PagePromise<PageClass, Item> {
|
|
899
1550
|
return this.requestAPIList(
|
|
900
1551
|
Page,
|
|
901
|
-
opts && 'then' in opts
|
|
902
|
-
opts.then((opts) => ({ method: 'get', path, ...opts }))
|
|
903
|
-
|
|
1552
|
+
opts && 'then' in opts
|
|
1553
|
+
? opts.then((opts) => ({ method: 'get', path, ...opts }))
|
|
1554
|
+
: { method: 'get', path, ...opts },
|
|
904
1555
|
);
|
|
905
1556
|
}
|
|
906
1557
|
|
|
@@ -911,8 +1562,24 @@ export class OpenAI {
|
|
|
911
1562
|
Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
|
|
912
1563
|
options: PromiseOrValue<FinalRequestOptions>,
|
|
913
1564
|
): Pagination.PagePromise<PageClass, Item> {
|
|
914
|
-
const
|
|
915
|
-
|
|
1565
|
+
const authentication = this.#x509Authentication ?? this._workloadIdentityAuth;
|
|
1566
|
+
const request =
|
|
1567
|
+
authentication instanceof X509WorkloadIdentityAuth
|
|
1568
|
+
? Promise.resolve(options).then((resolved) =>
|
|
1569
|
+
authentication.runRequest(() => this.makeRequest(resolved, null, undefined), this),
|
|
1570
|
+
)
|
|
1571
|
+
: this.makeRequest(options, null, undefined);
|
|
1572
|
+
const page = new Pagination.PagePromise<PageClass, Item>(this as any as OpenAI, request, Page);
|
|
1573
|
+
const guarded = this.responsePromise<PageClass>(request, async (client, props) => {
|
|
1574
|
+
const body = await this.parseResponseWithTimeout(client, props);
|
|
1575
|
+
return new Page(client, props.response, body, props.options);
|
|
1576
|
+
});
|
|
1577
|
+
page.then = guarded.then.bind(guarded);
|
|
1578
|
+
page.catch = guarded.catch.bind(guarded);
|
|
1579
|
+
page.finally = guarded.finally.bind(guarded);
|
|
1580
|
+
page.withResponse = guarded.withResponse.bind(guarded);
|
|
1581
|
+
page._thenUnwrap = guarded._thenUnwrap.bind(guarded);
|
|
1582
|
+
return page;
|
|
916
1583
|
}
|
|
917
1584
|
|
|
918
1585
|
protected async fetchWithAuth(
|
|
@@ -925,16 +1592,17 @@ export class OpenAI {
|
|
|
925
1592
|
adminAPIKeyAuth: true,
|
|
926
1593
|
},
|
|
927
1594
|
): Promise<Response> {
|
|
928
|
-
if (this._workloadIdentityAuth && schemes.bearerAuth) {
|
|
1595
|
+
if (this._workloadIdentityAuth && !this.#x509Fetch && schemes.bearerAuth) {
|
|
929
1596
|
const headers = init.headers as Headers;
|
|
930
1597
|
const authHeader = headers.get('Authorization');
|
|
931
|
-
if (
|
|
1598
|
+
if (authHeader === `Bearer ${WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER}`) {
|
|
932
1599
|
const token = await this._workloadIdentityAuth.getToken();
|
|
933
1600
|
headers.set('Authorization', `Bearer ${token}`);
|
|
934
1601
|
}
|
|
935
1602
|
}
|
|
936
1603
|
|
|
937
|
-
const
|
|
1604
|
+
const fetchWithTimeout = this.#x509Fetch ? OpenAI.prototype.fetchWithTimeout : this.fetchWithTimeout;
|
|
1605
|
+
const response = await fetchWithTimeout.call(this, url, init, timeout, controller);
|
|
938
1606
|
|
|
939
1607
|
return response;
|
|
940
1608
|
}
|
|
@@ -947,7 +1615,9 @@ export class OpenAI {
|
|
|
947
1615
|
): Promise<Response> {
|
|
948
1616
|
const { signal, method, ...options } = init || {};
|
|
949
1617
|
const abort = this._makeAbort(controller);
|
|
950
|
-
|
|
1618
|
+
const composed = !!signal && composedCallerSignals.get(controller) === signal;
|
|
1619
|
+
const cleanup =
|
|
1620
|
+
signal && !composed ? addRequestAbortListener(signal, abort, controller.signal) : undefined;
|
|
951
1621
|
|
|
952
1622
|
const timeout = setTimeout(abort, ms);
|
|
953
1623
|
|
|
@@ -969,7 +1639,14 @@ export class OpenAI {
|
|
|
969
1639
|
|
|
970
1640
|
try {
|
|
971
1641
|
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
|
|
972
|
-
|
|
1642
|
+
const response = await (this.#x509Fetch ?? this.fetch).call(undefined, url, fetchOptions);
|
|
1643
|
+
if (cleanup) {
|
|
1644
|
+
retainRequestAbortCallback(response.body ?? response, abort, controller.signal);
|
|
1645
|
+
}
|
|
1646
|
+
return response;
|
|
1647
|
+
} catch (err) {
|
|
1648
|
+
cleanup?.();
|
|
1649
|
+
throw err;
|
|
973
1650
|
} finally {
|
|
974
1651
|
clearTimeout(timeout);
|
|
975
1652
|
}
|
|
@@ -1003,6 +1680,7 @@ export class OpenAI {
|
|
|
1003
1680
|
retriesRemaining: number,
|
|
1004
1681
|
requestLogID: string,
|
|
1005
1682
|
responseHeaders?: Headers | undefined,
|
|
1683
|
+
requestSignal: AbortSignal | null | undefined = options.signal,
|
|
1006
1684
|
): Promise<APIResponseProps> {
|
|
1007
1685
|
let timeoutMillis: number | undefined;
|
|
1008
1686
|
|
|
@@ -1017,7 +1695,7 @@ export class OpenAI {
|
|
|
1017
1695
|
|
|
1018
1696
|
// About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
1019
1697
|
const retryAfterHeader = responseHeaders?.get('retry-after');
|
|
1020
|
-
if (retryAfterHeader &&
|
|
1698
|
+
if (retryAfterHeader && timeoutMillis === undefined) {
|
|
1021
1699
|
const timeoutSeconds = parseFloat(retryAfterHeader);
|
|
1022
1700
|
if (!Number.isNaN(timeoutSeconds)) {
|
|
1023
1701
|
timeoutMillis = timeoutSeconds * 1000;
|
|
@@ -1028,11 +1706,40 @@ export class OpenAI {
|
|
|
1028
1706
|
|
|
1029
1707
|
// If the API asks us to wait a certain amount of time, just do what it
|
|
1030
1708
|
// says, but otherwise calculate a default
|
|
1031
|
-
if (
|
|
1709
|
+
if (
|
|
1710
|
+
timeoutMillis === undefined ||
|
|
1711
|
+
!Number.isFinite(timeoutMillis) ||
|
|
1712
|
+
timeoutMillis < 0 ||
|
|
1713
|
+
timeoutMillis > 60 * 1000
|
|
1714
|
+
) {
|
|
1032
1715
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
1033
1716
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
1034
1717
|
}
|
|
1035
|
-
|
|
1718
|
+
const x509Authentication = this.#x509Authentication;
|
|
1719
|
+
if (x509Authentication) {
|
|
1720
|
+
const remaining = x509Authentication.remainingTimeout(
|
|
1721
|
+
options,
|
|
1722
|
+
x509Authentication.requestSnapshot().timeout,
|
|
1723
|
+
);
|
|
1724
|
+
if (timeoutMillis >= remaining) {
|
|
1725
|
+
throw new Errors.APIConnectionTimeoutError();
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
if (x509Authentication) {
|
|
1729
|
+
await x509Authentication.waitForRetry(timeoutMillis, x509Authentication.effectiveSignal());
|
|
1730
|
+
} else {
|
|
1731
|
+
const retrySignals =
|
|
1732
|
+
requestSignal === options.signal ? [requestSignal] : [requestSignal, options.signal];
|
|
1733
|
+
try {
|
|
1734
|
+
await sleep(timeoutMillis, ...retrySignals);
|
|
1735
|
+
} catch (error) {
|
|
1736
|
+
const abortedSignal = retrySignals.find((signal) => signal?.aborted);
|
|
1737
|
+
if (abortedSignal) {
|
|
1738
|
+
throw this._makeUserAbortError(abortedSignal);
|
|
1739
|
+
}
|
|
1740
|
+
throw error;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1036
1743
|
|
|
1037
1744
|
return this.makeRequest(options, retriesRemaining - 1, requestLogID);
|
|
1038
1745
|
}
|
|
@@ -1052,16 +1759,60 @@ export class OpenAI {
|
|
|
1052
1759
|
return sleepSeconds * jitter * 1000;
|
|
1053
1760
|
}
|
|
1054
1761
|
|
|
1762
|
+
/**
|
|
1763
|
+
* Builds a request, resolving callback credentials when constructing authentication
|
|
1764
|
+
* headers, after any subclass request-option rewrites. Calling this method directly
|
|
1765
|
+
* also resolves credentials. Complete replacement builders own authentication and
|
|
1766
|
+
* can call `this.authHeaders()` to resolve headers with request-local credentials.
|
|
1767
|
+
*/
|
|
1055
1768
|
async buildRequest(
|
|
1056
1769
|
inputOptions: FinalRequestOptions,
|
|
1057
1770
|
{ retryCount = 0 }: { retryCount?: number } = {},
|
|
1058
1771
|
): Promise<{ req: FinalizedRequestInit; url: string; timeout: number }> {
|
|
1772
|
+
if (this.#x509Authentication && !this.#x509Authentication.inRequest(this)) {
|
|
1773
|
+
const authentication = this.#x509Authentication;
|
|
1774
|
+
return await authentication.runRequest(async () => {
|
|
1775
|
+
const built = await OpenAI.prototype.buildRequest.call(this, inputOptions, { retryCount });
|
|
1776
|
+
authentication.releaseRequestBody(built.req.body);
|
|
1777
|
+
return built;
|
|
1778
|
+
}, this);
|
|
1779
|
+
}
|
|
1059
1780
|
const options = { ...inputOptions };
|
|
1781
|
+
const x509Authentication = this.#x509Authentication;
|
|
1782
|
+
const x509Tenant = x509Authentication?.snapshotTenant(this.organization, this.project);
|
|
1783
|
+
const x509Headers = x509Authentication?.snapshotHeaders(this._options.defaultHeaders, options.headers);
|
|
1784
|
+
if (x509Headers) {
|
|
1785
|
+
options.headers = x509Headers.requestHeaders;
|
|
1786
|
+
}
|
|
1787
|
+
const x509ClientFetchOptions = x509Authentication
|
|
1788
|
+
? snapshotX509RequestOptions(this.fetchOptions)
|
|
1789
|
+
: undefined;
|
|
1790
|
+
const x509RequestFetchOptions = x509Authentication
|
|
1791
|
+
? snapshotX509RequestOptions(options.fetchOptions)
|
|
1792
|
+
: undefined;
|
|
1060
1793
|
const { method, path, query, defaultBaseURL } = options;
|
|
1061
1794
|
|
|
1062
1795
|
const url = this.buildURL(path!, query as Record<string, unknown>, defaultBaseURL);
|
|
1063
|
-
|
|
1796
|
+
x509Authentication?.snapshotAPIURL(url);
|
|
1797
|
+
const explicitTimeout = 'timeout' in options;
|
|
1798
|
+
if (explicitTimeout) validatePositiveInteger('timeout', options.timeout);
|
|
1064
1799
|
options.timeout = options.timeout ?? this.timeout;
|
|
1800
|
+
if (x509Authentication && x509RequestFetchOptions) {
|
|
1801
|
+
x509Authentication.snapshotRequest(options.signal, options.timeout, x509RequestFetchOptions);
|
|
1802
|
+
}
|
|
1803
|
+
if (x509Authentication) {
|
|
1804
|
+
const snapshot = x509Authentication.requestSnapshot();
|
|
1805
|
+
options.timeout = snapshot.timeout;
|
|
1806
|
+
if (snapshot.signal === undefined) {
|
|
1807
|
+
delete options.signal;
|
|
1808
|
+
} else {
|
|
1809
|
+
options.signal = snapshot.signal;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
const authenticationHeaders =
|
|
1813
|
+
this._provider || x509Authentication
|
|
1814
|
+
? undefined
|
|
1815
|
+
: await this.authHeaders(inputOptions, inputOptions.__security ?? { bearerAuth: true });
|
|
1065
1816
|
const { bodyHeaders, body, isStreamingBody } = this.buildBody({ options });
|
|
1066
1817
|
|
|
1067
1818
|
if (isStreamingBody) {
|
|
@@ -1069,9 +1820,19 @@ export class OpenAI {
|
|
|
1069
1820
|
...inputOptions.__metadata,
|
|
1070
1821
|
hasStreamingBody: true,
|
|
1071
1822
|
};
|
|
1823
|
+
x509Authentication?.ownRequestBody(body, options.body);
|
|
1072
1824
|
}
|
|
1073
1825
|
|
|
1074
|
-
const reqHeaders = await this.buildHeaders({
|
|
1826
|
+
const reqHeaders = await this.buildHeaders({
|
|
1827
|
+
options: inputOptions,
|
|
1828
|
+
method,
|
|
1829
|
+
bodyHeaders,
|
|
1830
|
+
authenticationHeaders,
|
|
1831
|
+
retryCount,
|
|
1832
|
+
x509Headers,
|
|
1833
|
+
x509Timeout: explicitTimeout ? options.timeout : undefined,
|
|
1834
|
+
x509Tenant,
|
|
1835
|
+
});
|
|
1075
1836
|
|
|
1076
1837
|
const req: FinalizedRequestInit = {
|
|
1077
1838
|
method,
|
|
@@ -1080,8 +1841,8 @@ export class OpenAI {
|
|
|
1080
1841
|
...((globalThis as any).ReadableStream &&
|
|
1081
1842
|
body instanceof (globalThis as any).ReadableStream && { duplex: 'half' }),
|
|
1082
1843
|
...(body && { body }),
|
|
1083
|
-
...((this.fetchOptions as any) ?? {}),
|
|
1084
|
-
...((options.fetchOptions as any) ?? {}),
|
|
1844
|
+
...(((x509Authentication ? x509ClientFetchOptions : this.fetchOptions) as any) ?? {}),
|
|
1845
|
+
...(((x509Authentication ? x509RequestFetchOptions : options.fetchOptions) as any) ?? {}),
|
|
1085
1846
|
};
|
|
1086
1847
|
|
|
1087
1848
|
return { req, url, timeout: options.timeout };
|
|
@@ -1091,12 +1852,20 @@ export class OpenAI {
|
|
|
1091
1852
|
options,
|
|
1092
1853
|
method,
|
|
1093
1854
|
bodyHeaders,
|
|
1855
|
+
authenticationHeaders,
|
|
1094
1856
|
retryCount,
|
|
1857
|
+
x509Headers,
|
|
1858
|
+
x509Timeout,
|
|
1859
|
+
x509Tenant,
|
|
1095
1860
|
}: {
|
|
1096
1861
|
options: FinalRequestOptions;
|
|
1097
1862
|
method: HTTPMethod;
|
|
1098
1863
|
bodyHeaders: HeadersLike;
|
|
1864
|
+
authenticationHeaders: NullableHeaders | undefined;
|
|
1099
1865
|
retryCount: number;
|
|
1866
|
+
x509Headers?: { defaultHeaders: NullableHeaders; requestHeaders: NullableHeaders } | undefined;
|
|
1867
|
+
x509Timeout: number | undefined;
|
|
1868
|
+
x509Tenant?: { organization: string | null; project: string | null } | undefined;
|
|
1100
1869
|
}): Promise<Headers> {
|
|
1101
1870
|
let idempotencyHeaders: HeadersLike = {};
|
|
1102
1871
|
if (this.idempotencyHeader && method !== 'get') {
|
|
@@ -1104,24 +1873,32 @@ export class OpenAI {
|
|
|
1104
1873
|
idempotencyHeaders[this.idempotencyHeader] = options.idempotencyKey;
|
|
1105
1874
|
}
|
|
1106
1875
|
|
|
1876
|
+
const helperMethod = options.__metadata?.['helperMethod'];
|
|
1877
|
+
const timeout = x509Headers ? x509Timeout : options.timeout;
|
|
1107
1878
|
const headers = buildHeaders([
|
|
1108
1879
|
idempotencyHeaders,
|
|
1109
1880
|
{
|
|
1110
1881
|
Accept: 'application/json',
|
|
1111
|
-
'User-Agent': this.getUserAgent(),
|
|
1882
|
+
...(!isRunningInBrowserOrBrowserWorker() ? { 'User-Agent': this.getUserAgent() } : undefined),
|
|
1112
1883
|
'X-Stainless-Retry-Count': String(retryCount),
|
|
1113
|
-
...(
|
|
1884
|
+
...(timeout ? { 'X-Stainless-Timeout': String(Math.trunc(timeout / 1000)) } : {}),
|
|
1114
1885
|
...getPlatformHeaders(),
|
|
1115
|
-
'
|
|
1116
|
-
'OpenAI-
|
|
1886
|
+
...(typeof helperMethod === 'string' ? { 'X-Stainless-Helper-Method': helperMethod } : {}),
|
|
1887
|
+
'OpenAI-Organization': x509Tenant ? x509Tenant.organization : this.organization,
|
|
1888
|
+
'OpenAI-Project': x509Tenant ? x509Tenant.project : this.project,
|
|
1117
1889
|
},
|
|
1118
|
-
|
|
1119
|
-
this.
|
|
1890
|
+
// X.509 owns streaming uploads before authentication so it can retire them on failure.
|
|
1891
|
+
this.#x509Authentication && !this.#x509Authentication.isPlanningRequest()
|
|
1892
|
+
? await this.authHeaders(options, options.__security ?? { bearerAuth: true })
|
|
1893
|
+
: authenticationHeaders,
|
|
1894
|
+
x509Headers?.defaultHeaders ?? this._options.defaultHeaders,
|
|
1120
1895
|
bodyHeaders,
|
|
1121
|
-
options.headers,
|
|
1896
|
+
x509Headers?.requestHeaders ?? options.headers,
|
|
1122
1897
|
]);
|
|
1123
1898
|
|
|
1124
|
-
this.
|
|
1899
|
+
if (!this._provider && !this.#x509Authentication?.isPlanningRequest()) {
|
|
1900
|
+
this.validateHeaders(headers, options.__security ?? { bearerAuth: true });
|
|
1901
|
+
}
|
|
1125
1902
|
|
|
1126
1903
|
return headers.values;
|
|
1127
1904
|
}
|
|
@@ -1132,12 +1909,26 @@ export class OpenAI {
|
|
|
1132
1909
|
return () => controller.abort();
|
|
1133
1910
|
}
|
|
1134
1911
|
|
|
1135
|
-
private
|
|
1912
|
+
private _makeUserAbortError(signal: NonNullable<RequestInit['signal']>): Errors.APIUserAbortError {
|
|
1913
|
+
const error = new Errors.APIUserAbortError();
|
|
1914
|
+
Object.defineProperty(error, 'cause', { value: signal.reason, writable: true, configurable: true });
|
|
1915
|
+
return error;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
private buildBody({ options }: { options: FinalRequestOptions }): {
|
|
1136
1919
|
bodyHeaders: HeadersLike;
|
|
1137
1920
|
body: BodyInit | undefined;
|
|
1138
1921
|
isStreamingBody: boolean;
|
|
1139
1922
|
} {
|
|
1923
|
+
const { body, headers: rawHeaders } = options;
|
|
1140
1924
|
if (!body) {
|
|
1925
|
+
// A resource method always passes a `body` key when its operation defines a
|
|
1926
|
+
// request body, even if the caller omitted an optional body param. Keep the
|
|
1927
|
+
// content-type for those, and only elide it for operations with no body at
|
|
1928
|
+
// all (e.g. GET/DELETE).
|
|
1929
|
+
if (body === undefined && 'body' in options) {
|
|
1930
|
+
return { ...this.#encoder({ body, headers: buildHeaders([rawHeaders]) }), isStreamingBody: false };
|
|
1931
|
+
}
|
|
1141
1932
|
return { bodyHeaders: undefined, body: undefined, isStreamingBody: false };
|
|
1142
1933
|
}
|
|
1143
1934
|
const headers = buildHeaders([rawHeaders]);
|
|
@@ -1216,6 +2007,7 @@ export class OpenAI {
|
|
|
1216
2007
|
static InvalidWebhookSignatureError = Errors.InvalidWebhookSignatureError;
|
|
1217
2008
|
|
|
1218
2009
|
static toFile = Uploads.toFile;
|
|
2010
|
+
static toStreamingFile = Uploads.toStreamingFile;
|
|
1219
2011
|
|
|
1220
2012
|
/**
|
|
1221
2013
|
* Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
|
|
@@ -1234,6 +2026,7 @@ export class OpenAI {
|
|
|
1234
2026
|
* Given a prompt and/or an input image, the model will generate a new image.
|
|
1235
2027
|
*/
|
|
1236
2028
|
images: API.Images = new API.Images(this);
|
|
2029
|
+
contentProvenanceChecks: API.ContentProvenanceChecks = new API.ContentProvenanceChecks(this);
|
|
1237
2030
|
audio: API.Audio = new API.Audio(this);
|
|
1238
2031
|
/**
|
|
1239
2032
|
* Given text and/or image inputs, classifies if those inputs are potentially harmful.
|
|
@@ -1246,6 +2039,7 @@ export class OpenAI {
|
|
|
1246
2039
|
fineTuning: API.FineTuning = new API.FineTuning(this);
|
|
1247
2040
|
graders: API.Graders = new API.Graders(this);
|
|
1248
2041
|
vectorStores: API.VectorStores = new API.VectorStores(this);
|
|
2042
|
+
safety: API.Safety = new API.Safety(this);
|
|
1249
2043
|
webhooks: API.Webhooks = new API.Webhooks(this);
|
|
1250
2044
|
beta: API.Beta = new API.Beta(this);
|
|
1251
2045
|
/**
|
|
@@ -1258,6 +2052,7 @@ export class OpenAI {
|
|
|
1258
2052
|
uploads: API.Uploads = new API.Uploads(this);
|
|
1259
2053
|
admin: API.Admin = new API.Admin(this);
|
|
1260
2054
|
responses: API.Responses = new API.Responses(this);
|
|
2055
|
+
live: API.Live = new API.Live(this);
|
|
1261
2056
|
realtime: API.Realtime = new API.Realtime(this);
|
|
1262
2057
|
/**
|
|
1263
2058
|
* Manage conversations and conversation items.
|
|
@@ -1269,6 +2064,9 @@ export class OpenAI {
|
|
|
1269
2064
|
evals: API.Evals = new API.Evals(this);
|
|
1270
2065
|
containers: API.Containers = new API.Containers(this);
|
|
1271
2066
|
skills: API.Skills = new API.Skills(this);
|
|
2067
|
+
/**
|
|
2068
|
+
* @deprecated The Sora API is scheduled to permanently shut down on September 24, 2026.
|
|
2069
|
+
*/
|
|
1272
2070
|
videos: API.Videos = new API.Videos(this);
|
|
1273
2071
|
}
|
|
1274
2072
|
|
|
@@ -1277,24 +2075,63 @@ OpenAI.Chat = Chat;
|
|
|
1277
2075
|
OpenAI.Embeddings = Embeddings;
|
|
1278
2076
|
OpenAI.Files = Files;
|
|
1279
2077
|
OpenAI.Images = Images;
|
|
2078
|
+
OpenAI.ContentProvenanceChecks = ContentProvenanceChecks;
|
|
1280
2079
|
OpenAI.Audio = Audio;
|
|
1281
2080
|
OpenAI.Moderations = Moderations;
|
|
1282
2081
|
OpenAI.Models = Models;
|
|
1283
2082
|
OpenAI.FineTuning = FineTuning;
|
|
1284
2083
|
OpenAI.Graders = Graders;
|
|
1285
2084
|
OpenAI.VectorStores = VectorStores;
|
|
2085
|
+
OpenAI.Safety = Safety;
|
|
1286
2086
|
OpenAI.Webhooks = Webhooks;
|
|
1287
2087
|
OpenAI.Beta = Beta;
|
|
1288
2088
|
OpenAI.Batches = Batches;
|
|
1289
2089
|
OpenAI.Uploads = UploadsAPIUploads;
|
|
1290
2090
|
OpenAI.Admin = Admin;
|
|
1291
2091
|
OpenAI.Responses = Responses;
|
|
2092
|
+
OpenAI.Live = Live;
|
|
1292
2093
|
OpenAI.Realtime = Realtime;
|
|
1293
2094
|
OpenAI.Conversations = Conversations;
|
|
1294
2095
|
OpenAI.Evals = Evals;
|
|
1295
2096
|
OpenAI.Containers = Containers;
|
|
1296
2097
|
OpenAI.Skills = Skills;
|
|
1297
2098
|
OpenAI.Videos = Videos;
|
|
2099
|
+
OpenAI.ConversationCursorPage = Pagination.ConversationCursorPage;
|
|
2100
|
+
OpenAI.CursorPage = Pagination.CursorPage;
|
|
2101
|
+
OpenAI.NextCursorPage = Pagination.NextCursorPage;
|
|
2102
|
+
OpenAI.Page = Pagination.Page;
|
|
2103
|
+
OpenAI.TokenPage = Pagination.TokenPage;
|
|
2104
|
+
|
|
2105
|
+
const composedCallerSignals = new WeakMap<AbortController, AbortSignal>();
|
|
2106
|
+
|
|
2107
|
+
function createRequestController(
|
|
2108
|
+
callerSignal: AbortSignal | null | undefined,
|
|
2109
|
+
originalSignal?: AbortSignal | null,
|
|
2110
|
+
): AbortController {
|
|
2111
|
+
const controller = new AbortController();
|
|
2112
|
+
if (!callerSignal) return controller;
|
|
2113
|
+
|
|
2114
|
+
const nativeAbortSignal = (globalThis as any).AbortSignal;
|
|
2115
|
+
if (typeof nativeAbortSignal?.any !== 'function' || !(callerSignal instanceof nativeAbortSignal)) {
|
|
2116
|
+
return controller;
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
try {
|
|
2120
|
+
// Native composition keeps cancellation active after response headers without
|
|
2121
|
+
// retaining an abort listener on the caller's signal or changing its reason.
|
|
2122
|
+
const signals = [controller.signal, callerSignal];
|
|
2123
|
+
if (originalSignal && originalSignal !== callerSignal) {
|
|
2124
|
+
signals.push(originalSignal);
|
|
2125
|
+
}
|
|
2126
|
+
const composed = nativeAbortSignal.any(signals) as AbortSignal;
|
|
2127
|
+
Object.defineProperty(controller, 'signal', { value: composed, configurable: true });
|
|
2128
|
+
composedCallerSignals.set(controller, callerSignal);
|
|
2129
|
+
} catch {
|
|
2130
|
+
// Older or incompatible runtimes retain the existing listener-based fallback.
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
return controller;
|
|
2134
|
+
}
|
|
1298
2135
|
|
|
1299
2136
|
function getConnectionErrorMessage(error: Error): string | undefined {
|
|
1300
2137
|
if (isUndiciDispatcherVersionMismatchError(error)) {
|
|
@@ -1330,6 +2167,7 @@ function isUndiciDispatcherVersionMismatchError(error: unknown): boolean {
|
|
|
1330
2167
|
}
|
|
1331
2168
|
|
|
1332
2169
|
export declare namespace OpenAI {
|
|
2170
|
+
export { type DataResidency as DataResidency };
|
|
1333
2171
|
export type RequestOptions = Opts.RequestOptions;
|
|
1334
2172
|
|
|
1335
2173
|
export import Page = Pagination.Page;
|
|
@@ -1350,6 +2188,9 @@ export declare namespace OpenAI {
|
|
|
1350
2188
|
type NextCursorPageResponse as NextCursorPageResponse,
|
|
1351
2189
|
};
|
|
1352
2190
|
|
|
2191
|
+
export import TokenPage = Pagination.TokenPage;
|
|
2192
|
+
export { type TokenPageParams as TokenPageParams, type TokenPageResponse as TokenPageResponse };
|
|
2193
|
+
|
|
1353
2194
|
export {
|
|
1354
2195
|
Completions as Completions,
|
|
1355
2196
|
type Completion as Completion,
|
|
@@ -1446,6 +2287,12 @@ export declare namespace OpenAI {
|
|
|
1446
2287
|
type ImageGenerateParamsStreaming as ImageGenerateParamsStreaming,
|
|
1447
2288
|
};
|
|
1448
2289
|
|
|
2290
|
+
export {
|
|
2291
|
+
ContentProvenanceChecks as ContentProvenanceChecks,
|
|
2292
|
+
type ContentProvenanceCheck as ContentProvenanceCheck,
|
|
2293
|
+
type ContentProvenanceCheckCreateParams as ContentProvenanceCheckCreateParams,
|
|
2294
|
+
};
|
|
2295
|
+
|
|
1449
2296
|
export { Audio as Audio, type AudioModel as AudioModel, type AudioResponseFormat as AudioResponseFormat };
|
|
1450
2297
|
|
|
1451
2298
|
export {
|
|
@@ -1490,6 +2337,8 @@ export declare namespace OpenAI {
|
|
|
1490
2337
|
type VectorStoreSearchParams as VectorStoreSearchParams,
|
|
1491
2338
|
};
|
|
1492
2339
|
|
|
2340
|
+
export { Safety as Safety };
|
|
2341
|
+
|
|
1493
2342
|
export { Webhooks as Webhooks };
|
|
1494
2343
|
|
|
1495
2344
|
export { Beta as Beta };
|
|
@@ -1516,6 +2365,8 @@ export declare namespace OpenAI {
|
|
|
1516
2365
|
|
|
1517
2366
|
export { Responses as Responses };
|
|
1518
2367
|
|
|
2368
|
+
export { Live as Live };
|
|
2369
|
+
|
|
1519
2370
|
export { Realtime as Realtime };
|
|
1520
2371
|
|
|
1521
2372
|
export { Conversations as Conversations };
|