@bastani/atomic-ai 0.0.0-stage → 0.9.88
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/CHANGELOG.md +1629 -0
- package/LICENSE +22 -0
- package/NOTICE.md +16 -0
- package/README.md +165 -2
- package/dist/api/anthropic-assistant-content.d.ts +24 -0
- package/dist/api/anthropic-assistant-content.d.ts.map +1 -0
- package/dist/api/anthropic-assistant-content.js +99 -0
- package/dist/api/anthropic-assistant-content.js.map +1 -0
- package/dist/api/anthropic-messages.d.ts +71 -0
- package/dist/api/anthropic-messages.d.ts.map +1 -0
- package/dist/api/anthropic-messages.js +1814 -0
- package/dist/api/anthropic-messages.js.map +1 -0
- package/dist/api/anthropic-messages.lazy.d.ts +3 -0
- package/dist/api/anthropic-messages.lazy.d.ts.map +1 -0
- package/dist/api/anthropic-messages.lazy.js +3 -0
- package/dist/api/anthropic-messages.lazy.js.map +1 -0
- package/dist/api/azure-openai-config.d.ts +14 -0
- package/dist/api/azure-openai-config.d.ts.map +1 -0
- package/dist/api/azure-openai-config.js +61 -0
- package/dist/api/azure-openai-config.js.map +1 -0
- package/dist/api/azure-openai-responses.d.ts +14 -0
- package/dist/api/azure-openai-responses.d.ts.map +1 -0
- package/dist/api/azure-openai-responses.js +213 -0
- package/dist/api/azure-openai-responses.js.map +1 -0
- package/dist/api/azure-openai-responses.lazy.d.ts +3 -0
- package/dist/api/azure-openai-responses.lazy.d.ts.map +1 -0
- package/dist/api/azure-openai-responses.lazy.js +3 -0
- package/dist/api/azure-openai-responses.lazy.js.map +1 -0
- package/dist/api/bedrock-converse-stream.d.ts +38 -0
- package/dist/api/bedrock-converse-stream.d.ts.map +1 -0
- package/dist/api/bedrock-converse-stream.js +1301 -0
- package/dist/api/bedrock-converse-stream.js.map +1 -0
- package/dist/api/bedrock-converse-stream.lazy.d.ts +16 -0
- package/dist/api/bedrock-converse-stream.lazy.d.ts.map +1 -0
- package/dist/api/bedrock-converse-stream.lazy.js +43 -0
- package/dist/api/bedrock-converse-stream.lazy.js.map +1 -0
- package/dist/api/classifier-shared.d.ts +11 -0
- package/dist/api/classifier-shared.d.ts.map +1 -0
- package/dist/api/classifier-shared.js +90 -0
- package/dist/api/classifier-shared.js.map +1 -0
- package/dist/api/cloudflare-gateway-binding.d.ts +58 -0
- package/dist/api/cloudflare-gateway-binding.d.ts.map +1 -0
- package/dist/api/cloudflare-gateway-binding.js +33 -0
- package/dist/api/cloudflare-gateway-binding.js.map +1 -0
- package/dist/api/cloudflare-workers-ai-system-one.d.ts +4 -0
- package/dist/api/cloudflare-workers-ai-system-one.d.ts.map +1 -0
- package/dist/api/cloudflare-workers-ai-system-one.js +57 -0
- package/dist/api/cloudflare-workers-ai-system-one.js.map +1 -0
- package/dist/api/cloudflare-workers-ai-system-one.lazy.d.ts +3 -0
- package/dist/api/cloudflare-workers-ai-system-one.lazy.d.ts.map +1 -0
- package/dist/api/cloudflare-workers-ai-system-one.lazy.js +4 -0
- package/dist/api/cloudflare-workers-ai-system-one.lazy.js.map +1 -0
- package/dist/api/cloudflare.d.ts +11 -0
- package/dist/api/cloudflare.d.ts.map +1 -0
- package/dist/api/cloudflare.js +11 -0
- package/dist/api/cloudflare.js.map +1 -0
- package/dist/api/constrained-sampling.d.ts +38 -0
- package/dist/api/constrained-sampling.d.ts.map +1 -0
- package/dist/api/constrained-sampling.js +271 -0
- package/dist/api/constrained-sampling.js.map +1 -0
- package/dist/api/github-copilot-headers.d.ts +40 -0
- package/dist/api/github-copilot-headers.d.ts.map +1 -0
- package/dist/api/github-copilot-headers.js +76 -0
- package/dist/api/github-copilot-headers.js.map +1 -0
- package/dist/api/google-generative-ai.d.ts +15 -0
- package/dist/api/google-generative-ai.d.ts.map +1 -0
- package/dist/api/google-generative-ai.js +376 -0
- package/dist/api/google-generative-ai.js.map +1 -0
- package/dist/api/google-generative-ai.lazy.d.ts +3 -0
- package/dist/api/google-generative-ai.lazy.d.ts.map +1 -0
- package/dist/api/google-generative-ai.lazy.js +3 -0
- package/dist/api/google-generative-ai.lazy.js.map +1 -0
- package/dist/api/google-shared.d.ts +103 -0
- package/dist/api/google-shared.d.ts.map +1 -0
- package/dist/api/google-shared.js +536 -0
- package/dist/api/google-shared.js.map +1 -0
- package/dist/api/google-vertex.d.ts +17 -0
- package/dist/api/google-vertex.d.ts.map +1 -0
- package/dist/api/google-vertex.js +440 -0
- package/dist/api/google-vertex.js.map +1 -0
- package/dist/api/google-vertex.lazy.d.ts +3 -0
- package/dist/api/google-vertex.lazy.d.ts.map +1 -0
- package/dist/api/google-vertex.lazy.js +3 -0
- package/dist/api/google-vertex.lazy.js.map +1 -0
- package/dist/api/lazy.d.ts +19 -0
- package/dist/api/lazy.d.ts.map +1 -0
- package/dist/api/lazy.js +72 -0
- package/dist/api/lazy.js.map +1 -0
- package/dist/api/llama-cpp-classify.d.ts +33 -0
- package/dist/api/llama-cpp-classify.d.ts.map +1 -0
- package/dist/api/llama-cpp-classify.js +368 -0
- package/dist/api/llama-cpp-classify.js.map +1 -0
- package/dist/api/llama-cpp-classify.lazy.d.ts +3 -0
- package/dist/api/llama-cpp-classify.lazy.d.ts.map +1 -0
- package/dist/api/llama-cpp-classify.lazy.js +4 -0
- package/dist/api/llama-cpp-classify.lazy.js.map +1 -0
- package/dist/api/mistral-conversations.d.ts +25 -0
- package/dist/api/mistral-conversations.d.ts.map +1 -0
- package/dist/api/mistral-conversations.js +779 -0
- package/dist/api/mistral-conversations.js.map +1 -0
- package/dist/api/mistral-conversations.lazy.d.ts +3 -0
- package/dist/api/mistral-conversations.lazy.d.ts.map +1 -0
- package/dist/api/mistral-conversations.lazy.js +3 -0
- package/dist/api/mistral-conversations.lazy.js.map +1 -0
- package/dist/api/openai-codex-responses.d.ts +32 -0
- package/dist/api/openai-codex-responses.d.ts.map +1 -0
- package/dist/api/openai-codex-responses.js +1357 -0
- package/dist/api/openai-codex-responses.js.map +1 -0
- package/dist/api/openai-codex-responses.lazy.d.ts +3 -0
- package/dist/api/openai-codex-responses.lazy.d.ts.map +1 -0
- package/dist/api/openai-codex-responses.lazy.js +3 -0
- package/dist/api/openai-codex-responses.lazy.js.map +1 -0
- package/dist/api/openai-completions.d.ts +30 -0
- package/dist/api/openai-completions.d.ts.map +1 -0
- package/dist/api/openai-completions.js +1529 -0
- package/dist/api/openai-completions.js.map +1 -0
- package/dist/api/openai-completions.lazy.d.ts +3 -0
- package/dist/api/openai-completions.lazy.d.ts.map +1 -0
- package/dist/api/openai-completions.lazy.js +3 -0
- package/dist/api/openai-completions.lazy.js.map +1 -0
- package/dist/api/openai-decisions.d.ts +3 -0
- package/dist/api/openai-decisions.d.ts.map +1 -0
- package/dist/api/openai-decisions.js +157 -0
- package/dist/api/openai-decisions.js.map +1 -0
- package/dist/api/openai-decisions.lazy.d.ts +3 -0
- package/dist/api/openai-decisions.lazy.d.ts.map +1 -0
- package/dist/api/openai-decisions.lazy.js +4 -0
- package/dist/api/openai-decisions.lazy.js.map +1 -0
- package/dist/api/openai-images-options.d.ts +120 -0
- package/dist/api/openai-images-options.d.ts.map +1 -0
- package/dist/api/openai-images-options.js +112 -0
- package/dist/api/openai-images-options.js.map +1 -0
- package/dist/api/openai-images.d.ts +9 -0
- package/dist/api/openai-images.d.ts.map +1 -0
- package/dist/api/openai-images.js +317 -0
- package/dist/api/openai-images.js.map +1 -0
- package/dist/api/openai-images.lazy.d.ts +3 -0
- package/dist/api/openai-images.lazy.d.ts.map +1 -0
- package/dist/api/openai-images.lazy.js +4 -0
- package/dist/api/openai-images.lazy.js.map +1 -0
- package/dist/api/openai-prompt-cache.d.ts +3 -0
- package/dist/api/openai-prompt-cache.d.ts.map +1 -0
- package/dist/api/openai-prompt-cache.js +10 -0
- package/dist/api/openai-prompt-cache.js.map +1 -0
- package/dist/api/openai-responses-shared.d.ts +133 -0
- package/dist/api/openai-responses-shared.d.ts.map +1 -0
- package/dist/api/openai-responses-shared.js +970 -0
- package/dist/api/openai-responses-shared.js.map +1 -0
- package/dist/api/openai-responses.d.ts +15 -0
- package/dist/api/openai-responses.d.ts.map +1 -0
- package/dist/api/openai-responses.js +444 -0
- package/dist/api/openai-responses.js.map +1 -0
- package/dist/api/openai-responses.lazy.d.ts +3 -0
- package/dist/api/openai-responses.lazy.d.ts.map +1 -0
- package/dist/api/openai-responses.lazy.js +3 -0
- package/dist/api/openai-responses.lazy.js.map +1 -0
- package/dist/api/openai-retry-hint-client.d.ts +10 -0
- package/dist/api/openai-retry-hint-client.d.ts.map +1 -0
- package/dist/api/openai-retry-hint-client.js +17 -0
- package/dist/api/openai-retry-hint-client.js.map +1 -0
- package/dist/api/openrouter-images.d.ts +4 -0
- package/dist/api/openrouter-images.d.ts.map +1 -0
- package/dist/api/openrouter-images.js +135 -0
- package/dist/api/openrouter-images.js.map +1 -0
- package/dist/api/openrouter-images.lazy.d.ts +3 -0
- package/dist/api/openrouter-images.lazy.d.ts.map +1 -0
- package/dist/api/openrouter-images.lazy.js +4 -0
- package/dist/api/openrouter-images.lazy.js.map +1 -0
- package/dist/api/pi-messages.d.ts +101 -0
- package/dist/api/pi-messages.d.ts.map +1 -0
- package/dist/api/pi-messages.js +338 -0
- package/dist/api/pi-messages.js.map +1 -0
- package/dist/api/pi-messages.lazy.d.ts +3 -0
- package/dist/api/pi-messages.lazy.d.ts.map +1 -0
- package/dist/api/pi-messages.lazy.js +3 -0
- package/dist/api/pi-messages.lazy.js.map +1 -0
- package/dist/api/simple-options.d.ts +17 -0
- package/dist/api/simple-options.d.ts.map +1 -0
- package/dist/api/simple-options.js +89 -0
- package/dist/api/simple-options.js.map +1 -0
- package/dist/api/strict-tool-limits.d.ts +13 -0
- package/dist/api/strict-tool-limits.d.ts.map +1 -0
- package/dist/api/strict-tool-limits.js +50 -0
- package/dist/api/strict-tool-limits.js.map +1 -0
- package/dist/api/system-one-shared.d.ts +48 -0
- package/dist/api/system-one-shared.d.ts.map +1 -0
- package/dist/api/system-one-shared.js +175 -0
- package/dist/api/system-one-shared.js.map +1 -0
- package/dist/api/transform-messages.d.ts +27 -0
- package/dist/api/transform-messages.d.ts.map +1 -0
- package/dist/api/transform-messages.js +353 -0
- package/dist/api/transform-messages.js.map +1 -0
- package/dist/api/typesafe-system-one.d.ts +4 -0
- package/dist/api/typesafe-system-one.d.ts.map +1 -0
- package/dist/api/typesafe-system-one.js +29 -0
- package/dist/api/typesafe-system-one.js.map +1 -0
- package/dist/api/typesafe-system-one.lazy.d.ts +3 -0
- package/dist/api/typesafe-system-one.lazy.d.ts.map +1 -0
- package/dist/api/typesafe-system-one.lazy.js +4 -0
- package/dist/api/typesafe-system-one.lazy.js.map +1 -0
- package/dist/auth/context.d.ts +7 -0
- package/dist/auth/context.d.ts.map +1 -0
- package/dist/auth/context.js +42 -0
- package/dist/auth/context.js.map +1 -0
- package/dist/auth/credential-store.d.ts +17 -0
- package/dist/auth/credential-store.d.ts.map +1 -0
- package/dist/auth/credential-store.js +52 -0
- package/dist/auth/credential-store.js.map +1 -0
- package/dist/auth/helpers.d.ts +30 -0
- package/dist/auth/helpers.d.ts.map +1 -0
- package/dist/auth/helpers.js +66 -0
- package/dist/auth/helpers.js.map +1 -0
- package/dist/auth/oauth/anthropic.d.ts +9 -0
- package/dist/auth/oauth/anthropic.d.ts.map +1 -0
- package/dist/auth/oauth/anthropic.js +266 -0
- package/dist/auth/oauth/anthropic.js.map +1 -0
- package/dist/auth/oauth/callback-server.d.ts +31 -0
- package/dist/auth/oauth/callback-server.d.ts.map +1 -0
- package/dist/auth/oauth/callback-server.js +138 -0
- package/dist/auth/oauth/callback-server.js.map +1 -0
- package/dist/auth/oauth/device-code.d.ts +24 -0
- package/dist/auth/oauth/device-code.d.ts.map +1 -0
- package/dist/auth/oauth/device-code.js +69 -0
- package/dist/auth/oauth/device-code.js.map +1 -0
- package/dist/auth/oauth/github-copilot.d.ts +6 -0
- package/dist/auth/oauth/github-copilot.d.ts.map +1 -0
- package/dist/auth/oauth/github-copilot.js +352 -0
- package/dist/auth/oauth/github-copilot.js.map +1 -0
- package/dist/auth/oauth/kimi-coding.d.ts +10 -0
- package/dist/auth/oauth/kimi-coding.d.ts.map +1 -0
- package/dist/auth/oauth/kimi-coding.js +238 -0
- package/dist/auth/oauth/kimi-coding.js.map +1 -0
- package/dist/auth/oauth/load.d.ts +23 -0
- package/dist/auth/oauth/load.d.ts.map +1 -0
- package/dist/auth/oauth/load.js +67 -0
- package/dist/auth/oauth/load.js.map +1 -0
- package/dist/auth/oauth/meta.d.ts +17 -0
- package/dist/auth/oauth/meta.d.ts.map +1 -0
- package/dist/auth/oauth/meta.js +182 -0
- package/dist/auth/oauth/meta.js.map +1 -0
- package/dist/auth/oauth/oauth-page.d.ts +3 -0
- package/dist/auth/oauth/oauth-page.d.ts.map +1 -0
- package/dist/auth/oauth/oauth-page.js +105 -0
- package/dist/auth/oauth/oauth-page.js.map +1 -0
- package/dist/auth/oauth/openai-chatgpt.d.ts +3 -0
- package/dist/auth/oauth/openai-chatgpt.d.ts.map +1 -0
- package/dist/auth/oauth/openai-chatgpt.js +271 -0
- package/dist/auth/oauth/openai-chatgpt.js.map +1 -0
- package/dist/auth/oauth/openai-codex.d.ts +9 -0
- package/dist/auth/oauth/openai-codex.d.ts.map +1 -0
- package/dist/auth/oauth/openai-codex.js +360 -0
- package/dist/auth/oauth/openai-codex.js.map +1 -0
- package/dist/auth/oauth/openrouter.d.ts +15 -0
- package/dist/auth/oauth/openrouter.d.ts.map +1 -0
- package/dist/auth/oauth/openrouter.js +159 -0
- package/dist/auth/oauth/openrouter.js.map +1 -0
- package/dist/auth/oauth/pkce.d.ts +13 -0
- package/dist/auth/oauth/pkce.d.ts.map +1 -0
- package/dist/auth/oauth/pkce.js +31 -0
- package/dist/auth/oauth/pkce.js.map +1 -0
- package/dist/auth/oauth/token-response.d.ts +25 -0
- package/dist/auth/oauth/token-response.d.ts.map +1 -0
- package/dist/auth/oauth/token-response.js +43 -0
- package/dist/auth/oauth/token-response.js.map +1 -0
- package/dist/auth/oauth/trusted-url.d.ts +7 -0
- package/dist/auth/oauth/trusted-url.d.ts.map +1 -0
- package/dist/auth/oauth/trusted-url.js +12 -0
- package/dist/auth/oauth/trusted-url.js.map +1 -0
- package/dist/auth/oauth/xai.d.ts +6 -0
- package/dist/auth/oauth/xai.d.ts.map +1 -0
- package/dist/auth/oauth/xai.js +193 -0
- package/dist/auth/oauth/xai.js.map +1 -0
- package/dist/auth/oauth-refresh-errors.d.ts +46 -0
- package/dist/auth/oauth-refresh-errors.d.ts.map +1 -0
- package/dist/auth/oauth-refresh-errors.js +150 -0
- package/dist/auth/oauth-refresh-errors.js.map +1 -0
- package/dist/auth/resolve.d.ts +62 -0
- package/dist/auth/resolve.d.ts.map +1 -0
- package/dist/auth/resolve.js +357 -0
- package/dist/auth/resolve.js.map +1 -0
- package/dist/auth/types.d.ts +267 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +2 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/bedrock-provider.d.ts +5 -0
- package/dist/bedrock-provider.d.ts.map +1 -0
- package/dist/bedrock-provider.js +6 -0
- package/dist/bedrock-provider.js.map +1 -0
- package/dist/bun-oauth.d.ts +3 -0
- package/dist/bun-oauth.d.ts.map +1 -0
- package/dist/bun-oauth.js +23 -0
- package/dist/bun-oauth.js.map +1 -0
- package/dist/cache-warming.d.ts +53 -0
- package/dist/cache-warming.d.ts.map +1 -0
- package/dist/cache-warming.js +82 -0
- package/dist/cache-warming.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +118 -0
- package/dist/cli.js.map +1 -0
- package/dist/compat/extension-oauth-types.d.ts +43 -0
- package/dist/compat/extension-oauth-types.d.ts.map +1 -0
- package/dist/compat/extension-oauth-types.js +2 -0
- package/dist/compat/extension-oauth-types.js.map +1 -0
- package/dist/compat.d.ts +67 -0
- package/dist/compat.d.ts.map +1 -0
- package/dist/compat.js +202 -0
- package/dist/compat.js.map +1 -0
- package/dist/decision-models.d.ts +21 -0
- package/dist/decision-models.d.ts.map +1 -0
- package/dist/decision-models.generated.d.ts +3 -0
- package/dist/decision-models.generated.d.ts.map +1 -0
- package/dist/decision-models.generated.js +47 -0
- package/dist/decision-models.generated.js.map +1 -0
- package/dist/decision-models.js +8 -0
- package/dist/decision-models.js.map +1 -0
- package/dist/env-api-keys.d.ts +28 -0
- package/dist/env-api-keys.d.ts.map +1 -0
- package/dist/env-api-keys.js +185 -0
- package/dist/env-api-keys.js.map +1 -0
- package/dist/image-generation-error.d.ts +210 -0
- package/dist/image-generation-error.d.ts.map +1 -0
- package/dist/image-generation-error.js +442 -0
- package/dist/image-generation-error.js.map +1 -0
- package/dist/image-models.d.ts +21 -0
- package/dist/image-models.d.ts.map +1 -0
- package/dist/image-models.js +24 -0
- package/dist/image-models.js.map +1 -0
- package/dist/images-api-registry.d.ts +14 -0
- package/dist/images-api-registry.d.ts.map +1 -0
- package/dist/images-api-registry.js +22 -0
- package/dist/images-api-registry.js.map +1 -0
- package/dist/images.d.ts +9 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +19 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/lazy-bedrock-provider.d.ts +10 -0
- package/dist/lazy-bedrock-provider.d.ts.map +1 -0
- package/dist/lazy-bedrock-provider.js +13 -0
- package/dist/lazy-bedrock-provider.js.map +1 -0
- package/dist/lazy-oauth.d.ts +10 -0
- package/dist/lazy-oauth.d.ts.map +1 -0
- package/dist/lazy-oauth.js +22 -0
- package/dist/lazy-oauth.js.map +1 -0
- package/dist/legacy-api-aliases.d.ts +42 -0
- package/dist/legacy-api-aliases.d.ts.map +1 -0
- package/dist/legacy-api-aliases.js +49 -0
- package/dist/legacy-api-aliases.js.map +1 -0
- package/dist/model-catalog.d.ts +33 -0
- package/dist/model-catalog.d.ts.map +1 -0
- package/dist/model-catalog.js +46 -0
- package/dist/model-catalog.js.map +1 -0
- package/dist/models-store.d.ts +30 -0
- package/dist/models-store.d.ts.map +1 -0
- package/dist/models-store.js +17 -0
- package/dist/models-store.js.map +1 -0
- package/dist/models.d.ts +297 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.generated.d.ts +183 -0
- package/dist/models.generated.d.ts.map +1 -0
- package/dist/models.generated.js +185 -0
- package/dist/models.generated.js.map +1 -0
- package/dist/models.js +817 -0
- package/dist/models.js.map +1 -0
- package/dist/oauth.d.ts +3 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +2 -0
- package/dist/oauth.js.map +1 -0
- package/dist/provider-id.d.ts +2 -0
- package/dist/provider-id.d.ts.map +1 -0
- package/dist/provider-id.js +4 -0
- package/dist/provider-id.js.map +1 -0
- package/dist/providers/all.d.ts +41 -0
- package/dist/providers/all.d.ts.map +1 -0
- package/dist/providers/all.js +145 -0
- package/dist/providers/all.js.map +1 -0
- package/dist/providers/amazon-bedrock.d.ts +3 -0
- package/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock.js +93 -0
- package/dist/providers/amazon-bedrock.js.map +1 -0
- package/dist/providers/amazon-bedrock.models.d.ts +5 -0
- package/dist/providers/amazon-bedrock.models.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock.models.js +8 -0
- package/dist/providers/amazon-bedrock.models.js.map +1 -0
- package/dist/providers/ant-ling.d.ts +3 -0
- package/dist/providers/ant-ling.d.ts.map +1 -0
- package/dist/providers/ant-ling.js +15 -0
- package/dist/providers/ant-ling.js.map +1 -0
- package/dist/providers/ant-ling.models.d.ts +5 -0
- package/dist/providers/ant-ling.models.d.ts.map +1 -0
- package/dist/providers/ant-ling.models.js +8 -0
- package/dist/providers/ant-ling.models.js.map +1 -0
- package/dist/providers/anthropic.d.ts +4 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +87 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/anthropic.models.d.ts +5 -0
- package/dist/providers/anthropic.models.d.ts.map +1 -0
- package/dist/providers/anthropic.models.js +8 -0
- package/dist/providers/anthropic.models.js.map +1 -0
- package/dist/providers/azure-openai-responses.d.ts +3 -0
- package/dist/providers/azure-openai-responses.d.ts.map +1 -0
- package/dist/providers/azure-openai-responses.js +3 -0
- package/dist/providers/azure-openai-responses.js.map +1 -0
- package/dist/providers/azure-openai-responses.models.d.ts +3 -0
- package/dist/providers/azure-openai-responses.models.d.ts.map +1 -0
- package/dist/providers/azure-openai-responses.models.js +5 -0
- package/dist/providers/azure-openai-responses.models.js.map +1 -0
- package/dist/providers/azure.d.ts +3 -0
- package/dist/providers/azure.d.ts.map +1 -0
- package/dist/providers/azure.js +41 -0
- package/dist/providers/azure.js.map +1 -0
- package/dist/providers/azure.models.d.ts +5 -0
- package/dist/providers/azure.models.d.ts.map +1 -0
- package/dist/providers/azure.models.js +8 -0
- package/dist/providers/azure.models.js.map +1 -0
- package/dist/providers/baseten.d.ts +3 -0
- package/dist/providers/baseten.d.ts.map +1 -0
- package/dist/providers/baseten.js +15 -0
- package/dist/providers/baseten.js.map +1 -0
- package/dist/providers/baseten.models.d.ts +5 -0
- package/dist/providers/baseten.models.d.ts.map +1 -0
- package/dist/providers/baseten.models.js +8 -0
- package/dist/providers/baseten.models.js.map +1 -0
- package/dist/providers/cerebras.d.ts +3 -0
- package/dist/providers/cerebras.d.ts.map +1 -0
- package/dist/providers/cerebras.js +15 -0
- package/dist/providers/cerebras.js.map +1 -0
- package/dist/providers/cerebras.models.d.ts +5 -0
- package/dist/providers/cerebras.models.d.ts.map +1 -0
- package/dist/providers/cerebras.models.js +8 -0
- package/dist/providers/cerebras.models.js.map +1 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +5 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts.map +1 -0
- package/dist/providers/cloudflare-ai-gateway.js +21 -0
- package/dist/providers/cloudflare-ai-gateway.js.map +1 -0
- package/dist/providers/cloudflare-ai-gateway.models.d.ts +5 -0
- package/dist/providers/cloudflare-ai-gateway.models.d.ts.map +1 -0
- package/dist/providers/cloudflare-ai-gateway.models.js +8 -0
- package/dist/providers/cloudflare-ai-gateway.models.js.map +1 -0
- package/dist/providers/cloudflare-auth.d.ts +4 -0
- package/dist/providers/cloudflare-auth.d.ts.map +1 -0
- package/dist/providers/cloudflare-auth.js +86 -0
- package/dist/providers/cloudflare-auth.js.map +1 -0
- package/dist/providers/cloudflare-stream.d.ts +12 -0
- package/dist/providers/cloudflare-stream.d.ts.map +1 -0
- package/dist/providers/cloudflare-stream.js +27 -0
- package/dist/providers/cloudflare-stream.js.map +1 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +3 -0
- package/dist/providers/cloudflare-workers-ai.d.ts.map +1 -0
- package/dist/providers/cloudflare-workers-ai.js +22 -0
- package/dist/providers/cloudflare-workers-ai.js.map +1 -0
- package/dist/providers/cloudflare-workers-ai.models.d.ts +5 -0
- package/dist/providers/cloudflare-workers-ai.models.d.ts.map +1 -0
- package/dist/providers/cloudflare-workers-ai.models.js +8 -0
- package/dist/providers/cloudflare-workers-ai.models.js.map +1 -0
- package/dist/providers/compat-schema.d.ts +549 -0
- package/dist/providers/compat-schema.d.ts.map +1 -0
- package/dist/providers/compat-schema.js +452 -0
- package/dist/providers/compat-schema.js.map +1 -0
- package/dist/providers/data/.manifest.json +1 -0
- package/dist/providers/data/amazon-bedrock.json +1 -0
- package/dist/providers/data/ant-ling.json +1 -0
- package/dist/providers/data/anthropic.json +1 -0
- package/dist/providers/data/azure.json +1 -0
- package/dist/providers/data/baseten.json +1 -0
- package/dist/providers/data/cerebras.json +1 -0
- package/dist/providers/data/cloudflare-ai-gateway.json +1 -0
- package/dist/providers/data/cloudflare-workers-ai.json +1 -0
- package/dist/providers/data/deepseek.json +1 -0
- package/dist/providers/data/fireworks.json +1 -0
- package/dist/providers/data/github-copilot.json +1 -0
- package/dist/providers/data/google-vertex.json +1 -0
- package/dist/providers/data/google.json +1 -0
- package/dist/providers/data/groq.json +1 -0
- package/dist/providers/data/huggingface.json +1 -0
- package/dist/providers/data/kimi-coding.json +1 -0
- package/dist/providers/data/meta.json +1 -0
- package/dist/providers/data/minimax-cn.json +1 -0
- package/dist/providers/data/minimax.json +1 -0
- package/dist/providers/data/mistral.json +1 -0
- package/dist/providers/data/moonshotai-cn.json +1 -0
- package/dist/providers/data/moonshotai.json +1 -0
- package/dist/providers/data/nvidia.json +1 -0
- package/dist/providers/data/openai-codex.json +1 -0
- package/dist/providers/data/openai-decisions.json +1 -0
- package/dist/providers/data/openai-images.json +1 -0
- package/dist/providers/data/openai.json +1 -0
- package/dist/providers/data/opencode-go.json +1 -0
- package/dist/providers/data/opencode.json +1 -0
- package/dist/providers/data/openrouter.json +1 -0
- package/dist/providers/data/qwen-token-plan-cn.json +1 -0
- package/dist/providers/data/qwen-token-plan-individual-cn.json +1 -0
- package/dist/providers/data/qwen-token-plan-individual.json +1 -0
- package/dist/providers/data/qwen-token-plan.json +1 -0
- package/dist/providers/data/together.json +1 -0
- package/dist/providers/data/typesafe.json +1 -0
- package/dist/providers/data/vercel-ai-gateway.json +1 -0
- package/dist/providers/data/xai.json +1 -0
- package/dist/providers/data/xiaomi-token-plan-ams.json +1 -0
- package/dist/providers/data/xiaomi-token-plan-cn.json +1 -0
- package/dist/providers/data/xiaomi-token-plan-sgp.json +1 -0
- package/dist/providers/data/xiaomi.json +1 -0
- package/dist/providers/data/zai-coding-cn.json +1 -0
- package/dist/providers/data/zai.json +1 -0
- package/dist/providers/deepseek.d.ts +3 -0
- package/dist/providers/deepseek.d.ts.map +1 -0
- package/dist/providers/deepseek.js +15 -0
- package/dist/providers/deepseek.js.map +1 -0
- package/dist/providers/deepseek.models.d.ts +5 -0
- package/dist/providers/deepseek.models.d.ts.map +1 -0
- package/dist/providers/deepseek.models.js +8 -0
- package/dist/providers/deepseek.models.js.map +1 -0
- package/dist/providers/faux.d.ts +103 -0
- package/dist/providers/faux.d.ts.map +1 -0
- package/dist/providers/faux.js +521 -0
- package/dist/providers/faux.js.map +1 -0
- package/dist/providers/fireworks.d.ts +3 -0
- package/dist/providers/fireworks.d.ts.map +1 -0
- package/dist/providers/fireworks.js +19 -0
- package/dist/providers/fireworks.js.map +1 -0
- package/dist/providers/fireworks.models.d.ts +5 -0
- package/dist/providers/fireworks.models.d.ts.map +1 -0
- package/dist/providers/fireworks.models.js +8 -0
- package/dist/providers/fireworks.models.js.map +1 -0
- package/dist/providers/github-copilot-account.d.ts +18 -0
- package/dist/providers/github-copilot-account.d.ts.map +1 -0
- package/dist/providers/github-copilot-account.js +57 -0
- package/dist/providers/github-copilot-account.js.map +1 -0
- package/dist/providers/github-copilot-capabilities.d.ts +67 -0
- package/dist/providers/github-copilot-capabilities.d.ts.map +1 -0
- package/dist/providers/github-copilot-capabilities.js +81 -0
- package/dist/providers/github-copilot-capabilities.js.map +1 -0
- package/dist/providers/github-copilot-env.d.ts +41 -0
- package/dist/providers/github-copilot-env.d.ts.map +1 -0
- package/dist/providers/github-copilot-env.js +108 -0
- package/dist/providers/github-copilot-env.js.map +1 -0
- package/dist/providers/github-copilot-errors.d.ts +255 -0
- package/dist/providers/github-copilot-errors.d.ts.map +1 -0
- package/dist/providers/github-copilot-errors.js +764 -0
- package/dist/providers/github-copilot-errors.js.map +1 -0
- package/dist/providers/github-copilot-stream-attempt.d.ts +27 -0
- package/dist/providers/github-copilot-stream-attempt.d.ts.map +1 -0
- package/dist/providers/github-copilot-stream-attempt.js +45 -0
- package/dist/providers/github-copilot-stream-attempt.js.map +1 -0
- package/dist/providers/github-copilot.d.ts +40 -0
- package/dist/providers/github-copilot.d.ts.map +1 -0
- package/dist/providers/github-copilot.js +363 -0
- package/dist/providers/github-copilot.js.map +1 -0
- package/dist/providers/github-copilot.models.d.ts +5 -0
- package/dist/providers/github-copilot.models.d.ts.map +1 -0
- package/dist/providers/github-copilot.models.js +8 -0
- package/dist/providers/github-copilot.models.js.map +1 -0
- package/dist/providers/google-vertex.d.ts +3 -0
- package/dist/providers/google-vertex.d.ts.map +1 -0
- package/dist/providers/google-vertex.js +94 -0
- package/dist/providers/google-vertex.js.map +1 -0
- package/dist/providers/google-vertex.models.d.ts +5 -0
- package/dist/providers/google-vertex.models.d.ts.map +1 -0
- package/dist/providers/google-vertex.models.js +8 -0
- package/dist/providers/google-vertex.models.js.map +1 -0
- package/dist/providers/google.d.ts +3 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +15 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/google.models.d.ts +5 -0
- package/dist/providers/google.models.d.ts.map +1 -0
- package/dist/providers/google.models.js +8 -0
- package/dist/providers/google.models.js.map +1 -0
- package/dist/providers/groq.d.ts +3 -0
- package/dist/providers/groq.d.ts.map +1 -0
- package/dist/providers/groq.js +15 -0
- package/dist/providers/groq.js.map +1 -0
- package/dist/providers/groq.models.d.ts +5 -0
- package/dist/providers/groq.models.d.ts.map +1 -0
- package/dist/providers/groq.models.js +8 -0
- package/dist/providers/groq.models.js.map +1 -0
- package/dist/providers/huggingface.d.ts +3 -0
- package/dist/providers/huggingface.d.ts.map +1 -0
- package/dist/providers/huggingface.js +15 -0
- package/dist/providers/huggingface.js.map +1 -0
- package/dist/providers/huggingface.models.d.ts +5 -0
- package/dist/providers/huggingface.models.d.ts.map +1 -0
- package/dist/providers/huggingface.models.js +8 -0
- package/dist/providers/huggingface.models.js.map +1 -0
- package/dist/providers/images/register-builtins.d.ts +5 -0
- package/dist/providers/images/register-builtins.d.ts.map +1 -0
- package/dist/providers/images/register-builtins.js +52 -0
- package/dist/providers/images/register-builtins.js.map +1 -0
- package/dist/providers/kimi-coding.d.ts +3 -0
- package/dist/providers/kimi-coding.d.ts.map +1 -0
- package/dist/providers/kimi-coding.js +24 -0
- package/dist/providers/kimi-coding.js.map +1 -0
- package/dist/providers/kimi-coding.models.d.ts +5 -0
- package/dist/providers/kimi-coding.models.d.ts.map +1 -0
- package/dist/providers/kimi-coding.models.js +8 -0
- package/dist/providers/kimi-coding.models.js.map +1 -0
- package/dist/providers/meta.d.ts +3 -0
- package/dist/providers/meta.d.ts.map +1 -0
- package/dist/providers/meta.js +24 -0
- package/dist/providers/meta.js.map +1 -0
- package/dist/providers/meta.models.d.ts +5 -0
- package/dist/providers/meta.models.d.ts.map +1 -0
- package/dist/providers/meta.models.js +8 -0
- package/dist/providers/meta.models.js.map +1 -0
- package/dist/providers/minimax-cn.d.ts +3 -0
- package/dist/providers/minimax-cn.d.ts.map +1 -0
- package/dist/providers/minimax-cn.js +15 -0
- package/dist/providers/minimax-cn.js.map +1 -0
- package/dist/providers/minimax-cn.models.d.ts +5 -0
- package/dist/providers/minimax-cn.models.d.ts.map +1 -0
- package/dist/providers/minimax-cn.models.js +8 -0
- package/dist/providers/minimax-cn.models.js.map +1 -0
- package/dist/providers/minimax.d.ts +3 -0
- package/dist/providers/minimax.d.ts.map +1 -0
- package/dist/providers/minimax.js +15 -0
- package/dist/providers/minimax.js.map +1 -0
- package/dist/providers/minimax.models.d.ts +5 -0
- package/dist/providers/minimax.models.d.ts.map +1 -0
- package/dist/providers/minimax.models.js +8 -0
- package/dist/providers/minimax.models.js.map +1 -0
- package/dist/providers/mistral.d.ts +3 -0
- package/dist/providers/mistral.d.ts.map +1 -0
- package/dist/providers/mistral.js +15 -0
- package/dist/providers/mistral.js.map +1 -0
- package/dist/providers/mistral.models.d.ts +5 -0
- package/dist/providers/mistral.models.d.ts.map +1 -0
- package/dist/providers/mistral.models.js +8 -0
- package/dist/providers/mistral.models.js.map +1 -0
- package/dist/providers/model-schema.d.ts +91 -0
- package/dist/providers/model-schema.d.ts.map +1 -0
- package/dist/providers/model-schema.js +57 -0
- package/dist/providers/model-schema.js.map +1 -0
- package/dist/providers/moonshotai-cn.d.ts +3 -0
- package/dist/providers/moonshotai-cn.d.ts.map +1 -0
- package/dist/providers/moonshotai-cn.js +15 -0
- package/dist/providers/moonshotai-cn.js.map +1 -0
- package/dist/providers/moonshotai-cn.models.d.ts +5 -0
- package/dist/providers/moonshotai-cn.models.d.ts.map +1 -0
- package/dist/providers/moonshotai-cn.models.js +8 -0
- package/dist/providers/moonshotai-cn.models.js.map +1 -0
- package/dist/providers/moonshotai.d.ts +3 -0
- package/dist/providers/moonshotai.d.ts.map +1 -0
- package/dist/providers/moonshotai.js +15 -0
- package/dist/providers/moonshotai.js.map +1 -0
- package/dist/providers/moonshotai.models.d.ts +5 -0
- package/dist/providers/moonshotai.models.d.ts.map +1 -0
- package/dist/providers/moonshotai.models.js +8 -0
- package/dist/providers/moonshotai.models.js.map +1 -0
- package/dist/providers/morph.d.ts +3 -0
- package/dist/providers/morph.d.ts.map +1 -0
- package/dist/providers/morph.js +22 -0
- package/dist/providers/morph.js.map +1 -0
- package/dist/providers/nvidia.d.ts +3 -0
- package/dist/providers/nvidia.d.ts.map +1 -0
- package/dist/providers/nvidia.js +15 -0
- package/dist/providers/nvidia.js.map +1 -0
- package/dist/providers/nvidia.models.d.ts +5 -0
- package/dist/providers/nvidia.models.d.ts.map +1 -0
- package/dist/providers/nvidia.models.js +8 -0
- package/dist/providers/nvidia.models.js.map +1 -0
- package/dist/providers/openai-codex.d.ts +3 -0
- package/dist/providers/openai-codex.d.ts.map +1 -0
- package/dist/providers/openai-codex.js +25 -0
- package/dist/providers/openai-codex.js.map +1 -0
- package/dist/providers/openai-codex.models.d.ts +5 -0
- package/dist/providers/openai-codex.models.d.ts.map +1 -0
- package/dist/providers/openai-codex.models.js +8 -0
- package/dist/providers/openai-codex.models.js.map +1 -0
- package/dist/providers/openai-decisions.d.ts +3 -0
- package/dist/providers/openai-decisions.d.ts.map +1 -0
- package/dist/providers/openai-decisions.js +19 -0
- package/dist/providers/openai-decisions.js.map +1 -0
- package/dist/providers/openai-decisions.models.d.ts +5 -0
- package/dist/providers/openai-decisions.models.d.ts.map +1 -0
- package/dist/providers/openai-decisions.models.js +8 -0
- package/dist/providers/openai-decisions.models.js.map +1 -0
- package/dist/providers/openai-images.d.ts +3 -0
- package/dist/providers/openai-images.d.ts.map +1 -0
- package/dist/providers/openai-images.js +19 -0
- package/dist/providers/openai-images.js.map +1 -0
- package/dist/providers/openai-images.models.d.ts +5 -0
- package/dist/providers/openai-images.models.d.ts.map +1 -0
- package/dist/providers/openai-images.models.js +8 -0
- package/dist/providers/openai-images.models.js.map +1 -0
- package/dist/providers/openai-mid-convo-effort.d.ts +2 -0
- package/dist/providers/openai-mid-convo-effort.d.ts.map +1 -0
- package/dist/providers/openai-mid-convo-effort.js +8 -0
- package/dist/providers/openai-mid-convo-effort.js.map +1 -0
- package/dist/providers/openai-subscription-models.d.ts +3 -0
- package/dist/providers/openai-subscription-models.d.ts.map +1 -0
- package/dist/providers/openai-subscription-models.js +19 -0
- package/dist/providers/openai-subscription-models.js.map +1 -0
- package/dist/providers/openai.d.ts +4 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +48 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/openai.models.d.ts +5 -0
- package/dist/providers/openai.models.d.ts.map +1 -0
- package/dist/providers/openai.models.js +8 -0
- package/dist/providers/openai.models.js.map +1 -0
- package/dist/providers/opencode-go.d.ts +5 -0
- package/dist/providers/opencode-go.d.ts.map +1 -0
- package/dist/providers/opencode-go.js +22 -0
- package/dist/providers/opencode-go.js.map +1 -0
- package/dist/providers/opencode-go.models.d.ts +5 -0
- package/dist/providers/opencode-go.models.d.ts.map +1 -0
- package/dist/providers/opencode-go.models.js +8 -0
- package/dist/providers/opencode-go.models.js.map +1 -0
- package/dist/providers/opencode.d.ts +5 -0
- package/dist/providers/opencode.d.ts.map +1 -0
- package/dist/providers/opencode.js +24 -0
- package/dist/providers/opencode.js.map +1 -0
- package/dist/providers/opencode.models.d.ts +5 -0
- package/dist/providers/opencode.models.d.ts.map +1 -0
- package/dist/providers/opencode.models.js +8 -0
- package/dist/providers/opencode.models.js.map +1 -0
- package/dist/providers/openrouter-api.d.ts +40 -0
- package/dist/providers/openrouter-api.d.ts.map +1 -0
- package/dist/providers/openrouter-api.js +41 -0
- package/dist/providers/openrouter-api.js.map +1 -0
- package/dist/providers/openrouter.d.ts +13 -0
- package/dist/providers/openrouter.d.ts.map +1 -0
- package/dist/providers/openrouter.js +88 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/providers/openrouter.models.d.ts +5 -0
- package/dist/providers/openrouter.models.d.ts.map +1 -0
- package/dist/providers/openrouter.models.js +8 -0
- package/dist/providers/openrouter.models.js.map +1 -0
- package/dist/providers/qwen-token-plan-cn.d.ts +3 -0
- package/dist/providers/qwen-token-plan-cn.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan-cn.js +20 -0
- package/dist/providers/qwen-token-plan-cn.js.map +1 -0
- package/dist/providers/qwen-token-plan-cn.models.d.ts +5 -0
- package/dist/providers/qwen-token-plan-cn.models.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan-cn.models.js +8 -0
- package/dist/providers/qwen-token-plan-cn.models.js.map +1 -0
- package/dist/providers/qwen-token-plan-individual-cn.d.ts +3 -0
- package/dist/providers/qwen-token-plan-individual-cn.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan-individual-cn.js +20 -0
- package/dist/providers/qwen-token-plan-individual-cn.js.map +1 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.d.ts +5 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.js +8 -0
- package/dist/providers/qwen-token-plan-individual-cn.models.js.map +1 -0
- package/dist/providers/qwen-token-plan-individual.d.ts +3 -0
- package/dist/providers/qwen-token-plan-individual.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan-individual.js +20 -0
- package/dist/providers/qwen-token-plan-individual.js.map +1 -0
- package/dist/providers/qwen-token-plan-individual.models.d.ts +5 -0
- package/dist/providers/qwen-token-plan-individual.models.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan-individual.models.js +8 -0
- package/dist/providers/qwen-token-plan-individual.models.js.map +1 -0
- package/dist/providers/qwen-token-plan.d.ts +3 -0
- package/dist/providers/qwen-token-plan.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan.js +20 -0
- package/dist/providers/qwen-token-plan.js.map +1 -0
- package/dist/providers/qwen-token-plan.models.d.ts +5 -0
- package/dist/providers/qwen-token-plan.models.d.ts.map +1 -0
- package/dist/providers/qwen-token-plan.models.js +8 -0
- package/dist/providers/qwen-token-plan.models.js.map +1 -0
- package/dist/providers/together.d.ts +3 -0
- package/dist/providers/together.d.ts.map +1 -0
- package/dist/providers/together.js +15 -0
- package/dist/providers/together.js.map +1 -0
- package/dist/providers/together.models.d.ts +5 -0
- package/dist/providers/together.models.d.ts.map +1 -0
- package/dist/providers/together.models.js +8 -0
- package/dist/providers/together.models.js.map +1 -0
- package/dist/providers/typesafe.d.ts +3 -0
- package/dist/providers/typesafe.d.ts.map +1 -0
- package/dist/providers/typesafe.js +18 -0
- package/dist/providers/typesafe.js.map +1 -0
- package/dist/providers/typesafe.models.d.ts +5 -0
- package/dist/providers/typesafe.models.d.ts.map +1 -0
- package/dist/providers/typesafe.models.js +8 -0
- package/dist/providers/typesafe.models.js.map +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +3 -0
- package/dist/providers/vercel-ai-gateway.d.ts.map +1 -0
- package/dist/providers/vercel-ai-gateway.js +17 -0
- package/dist/providers/vercel-ai-gateway.js.map +1 -0
- package/dist/providers/vercel-ai-gateway.models.d.ts +5 -0
- package/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -0
- package/dist/providers/vercel-ai-gateway.models.js +8 -0
- package/dist/providers/vercel-ai-gateway.models.js.map +1 -0
- package/dist/providers/xai.d.ts +3 -0
- package/dist/providers/xai.d.ts.map +1 -0
- package/dist/providers/xai.js +24 -0
- package/dist/providers/xai.js.map +1 -0
- package/dist/providers/xai.models.d.ts +5 -0
- package/dist/providers/xai.models.d.ts.map +1 -0
- package/dist/providers/xai.models.js +8 -0
- package/dist/providers/xai.models.js.map +1 -0
- package/dist/providers/xiaomi-token-plan-ams.d.ts +3 -0
- package/dist/providers/xiaomi-token-plan-ams.d.ts.map +1 -0
- package/dist/providers/xiaomi-token-plan-ams.js +15 -0
- package/dist/providers/xiaomi-token-plan-ams.js.map +1 -0
- package/dist/providers/xiaomi-token-plan-ams.models.d.ts +5 -0
- package/dist/providers/xiaomi-token-plan-ams.models.d.ts.map +1 -0
- package/dist/providers/xiaomi-token-plan-ams.models.js +8 -0
- package/dist/providers/xiaomi-token-plan-ams.models.js.map +1 -0
- package/dist/providers/xiaomi-token-plan-cn.d.ts +3 -0
- package/dist/providers/xiaomi-token-plan-cn.d.ts.map +1 -0
- package/dist/providers/xiaomi-token-plan-cn.js +15 -0
- package/dist/providers/xiaomi-token-plan-cn.js.map +1 -0
- package/dist/providers/xiaomi-token-plan-cn.models.d.ts +5 -0
- package/dist/providers/xiaomi-token-plan-cn.models.d.ts.map +1 -0
- package/dist/providers/xiaomi-token-plan-cn.models.js +8 -0
- package/dist/providers/xiaomi-token-plan-cn.models.js.map +1 -0
- package/dist/providers/xiaomi-token-plan-sgp.d.ts +3 -0
- package/dist/providers/xiaomi-token-plan-sgp.d.ts.map +1 -0
- package/dist/providers/xiaomi-token-plan-sgp.js +15 -0
- package/dist/providers/xiaomi-token-plan-sgp.js.map +1 -0
- package/dist/providers/xiaomi-token-plan-sgp.models.d.ts +5 -0
- package/dist/providers/xiaomi-token-plan-sgp.models.d.ts.map +1 -0
- package/dist/providers/xiaomi-token-plan-sgp.models.js +8 -0
- package/dist/providers/xiaomi-token-plan-sgp.models.js.map +1 -0
- package/dist/providers/xiaomi.d.ts +3 -0
- package/dist/providers/xiaomi.d.ts.map +1 -0
- package/dist/providers/xiaomi.js +15 -0
- package/dist/providers/xiaomi.js.map +1 -0
- package/dist/providers/xiaomi.models.d.ts +5 -0
- package/dist/providers/xiaomi.models.d.ts.map +1 -0
- package/dist/providers/xiaomi.models.js +8 -0
- package/dist/providers/xiaomi.models.js.map +1 -0
- package/dist/providers/zai-coding-cn.d.ts +3 -0
- package/dist/providers/zai-coding-cn.d.ts.map +1 -0
- package/dist/providers/zai-coding-cn.js +15 -0
- package/dist/providers/zai-coding-cn.js.map +1 -0
- package/dist/providers/zai-coding-cn.models.d.ts +5 -0
- package/dist/providers/zai-coding-cn.models.d.ts.map +1 -0
- package/dist/providers/zai-coding-cn.models.js +8 -0
- package/dist/providers/zai-coding-cn.models.js.map +1 -0
- package/dist/providers/zai.d.ts +3 -0
- package/dist/providers/zai.d.ts.map +1 -0
- package/dist/providers/zai.js +15 -0
- package/dist/providers/zai.js.map +1 -0
- package/dist/providers/zai.models.d.ts +5 -0
- package/dist/providers/zai.models.d.ts.map +1 -0
- package/dist/providers/zai.models.js +8 -0
- package/dist/providers/zai.models.js.map +1 -0
- package/dist/session-resources.d.ts +4 -0
- package/dist/session-resources.d.ts.map +1 -0
- package/dist/session-resources.js +22 -0
- package/dist/session-resources.js.map +1 -0
- package/dist/types.d.ts +845 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/abort-signals.d.ts +6 -0
- package/dist/utils/abort-signals.d.ts.map +1 -0
- package/dist/utils/abort-signals.js +34 -0
- package/dist/utils/abort-signals.js.map +1 -0
- package/dist/utils/abort.d.ts +8 -0
- package/dist/utils/abort.d.ts.map +1 -0
- package/dist/utils/abort.js +49 -0
- package/dist/utils/abort.js.map +1 -0
- package/dist/utils/azure-openai-thinking-level-map.d.ts +19 -0
- package/dist/utils/azure-openai-thinking-level-map.d.ts.map +1 -0
- package/dist/utils/azure-openai-thinking-level-map.js +45 -0
- package/dist/utils/azure-openai-thinking-level-map.js.map +1 -0
- package/dist/utils/diagnostics.d.ts +20 -0
- package/dist/utils/diagnostics.d.ts.map +1 -0
- package/dist/utils/diagnostics.js +25 -0
- package/dist/utils/diagnostics.js.map +1 -0
- package/dist/utils/document-input.d.ts +21 -0
- package/dist/utils/document-input.d.ts.map +1 -0
- package/dist/utils/document-input.js +28 -0
- package/dist/utils/document-input.js.map +1 -0
- package/dist/utils/error-body.d.ts +40 -0
- package/dist/utils/error-body.d.ts.map +1 -0
- package/dist/utils/error-body.js +177 -0
- package/dist/utils/error-body.js.map +1 -0
- package/dist/utils/estimate.d.ts +17 -0
- package/dist/utils/estimate.d.ts.map +1 -0
- package/dist/utils/estimate.js +107 -0
- package/dist/utils/estimate.js.map +1 -0
- package/dist/utils/event-stream.d.ts +24 -0
- package/dist/utils/event-stream.d.ts.map +1 -0
- package/dist/utils/event-stream.js +118 -0
- package/dist/utils/event-stream.js.map +1 -0
- package/dist/utils/hash.d.ts +3 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +14 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/headers.d.ts +4 -0
- package/dist/utils/headers.d.ts.map +1 -0
- package/dist/utils/headers.js +20 -0
- package/dist/utils/headers.js.map +1 -0
- package/dist/utils/identity.d.ts +67 -0
- package/dist/utils/identity.d.ts.map +1 -0
- package/dist/utils/identity.js +148 -0
- package/dist/utils/identity.js.map +1 -0
- package/dist/utils/inline-images.d.ts +24 -0
- package/dist/utils/inline-images.d.ts.map +1 -0
- package/dist/utils/inline-images.js +55 -0
- package/dist/utils/inline-images.js.map +1 -0
- package/dist/utils/json-parse.d.ts +18 -0
- package/dist/utils/json-parse.d.ts.map +1 -0
- package/dist/utils/json-parse.js +167 -0
- package/dist/utils/json-parse.js.map +1 -0
- package/dist/utils/model-operations.d.ts +12 -0
- package/dist/utils/model-operations.d.ts.map +1 -0
- package/dist/utils/model-operations.js +58 -0
- package/dist/utils/model-operations.js.map +1 -0
- package/dist/utils/models-dev-catalog.d.ts +324 -0
- package/dist/utils/models-dev-catalog.d.ts.map +1 -0
- package/dist/utils/models-dev-catalog.js +3166 -0
- package/dist/utils/models-dev-catalog.js.map +1 -0
- package/dist/utils/models-dev-reasoning-options.d.ts +18 -0
- package/dist/utils/models-dev-reasoning-options.d.ts.map +1 -0
- package/dist/utils/models-dev-reasoning-options.js +20 -0
- package/dist/utils/models-dev-reasoning-options.js.map +1 -0
- package/dist/utils/models-error.d.ts +8 -0
- package/dist/utils/models-error.d.ts.map +1 -0
- package/dist/utils/models-error.js +19 -0
- package/dist/utils/models-error.js.map +1 -0
- package/dist/utils/node-http-proxy.d.ts +4 -0
- package/dist/utils/node-http-proxy.d.ts.map +1 -0
- package/dist/utils/node-http-proxy.js +141 -0
- package/dist/utils/node-http-proxy.js.map +1 -0
- package/dist/utils/oauth-page.d.ts +2 -0
- package/dist/utils/oauth-page.d.ts.map +1 -0
- package/dist/utils/oauth-page.js +2 -0
- package/dist/utils/oauth-page.js.map +1 -0
- package/dist/utils/openrouter-cost.d.ts +24 -0
- package/dist/utils/openrouter-cost.d.ts.map +1 -0
- package/dist/utils/openrouter-cost.js +34 -0
- package/dist/utils/openrouter-cost.js.map +1 -0
- package/dist/utils/overflow.d.ts +73 -0
- package/dist/utils/overflow.d.ts.map +1 -0
- package/dist/utils/overflow.js +204 -0
- package/dist/utils/overflow.js.map +1 -0
- package/dist/utils/provider-env.d.ts +12 -0
- package/dist/utils/provider-env.d.ts.map +1 -0
- package/dist/utils/provider-env.js +51 -0
- package/dist/utils/provider-env.js.map +1 -0
- package/dist/utils/provider-retry.d.ts +21 -0
- package/dist/utils/provider-retry.d.ts.map +1 -0
- package/dist/utils/provider-retry.js +100 -0
- package/dist/utils/provider-retry.js.map +1 -0
- package/dist/utils/request-admission.d.ts +12 -0
- package/dist/utils/request-admission.d.ts.map +1 -0
- package/dist/utils/request-admission.js +37 -0
- package/dist/utils/request-admission.js.map +1 -0
- package/dist/utils/retry-hints.d.ts +15 -0
- package/dist/utils/retry-hints.d.ts.map +1 -0
- package/dist/utils/retry-hints.js +130 -0
- package/dist/utils/retry-hints.js.map +1 -0
- package/dist/utils/retry.d.ts +78 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +251 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/sanitize-unicode.d.ts +22 -0
- package/dist/utils/sanitize-unicode.d.ts.map +1 -0
- package/dist/utils/sanitize-unicode.js +26 -0
- package/dist/utils/sanitize-unicode.js.map +1 -0
- package/dist/utils/sleep.d.ts +2 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +15 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/sse.d.ts +29 -0
- package/dist/utils/sse.d.ts.map +1 -0
- package/dist/utils/sse.js +73 -0
- package/dist/utils/sse.js.map +1 -0
- package/dist/utils/stream-deadline.d.ts +78 -0
- package/dist/utils/stream-deadline.d.ts.map +1 -0
- package/dist/utils/stream-deadline.js +205 -0
- package/dist/utils/stream-deadline.js.map +1 -0
- package/dist/utils/streaming-json.d.ts +84 -0
- package/dist/utils/streaming-json.d.ts.map +1 -0
- package/dist/utils/streaming-json.js +513 -0
- package/dist/utils/streaming-json.js.map +1 -0
- package/dist/utils/text.d.ts +21 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +45 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/thinking-off.d.ts +23 -0
- package/dist/utils/thinking-off.d.ts.map +1 -0
- package/dist/utils/thinking-off.js +51 -0
- package/dist/utils/thinking-off.js.map +1 -0
- package/dist/utils/transcript.d.ts +101 -0
- package/dist/utils/transcript.d.ts.map +1 -0
- package/dist/utils/transcript.js +218 -0
- package/dist/utils/transcript.js.map +1 -0
- package/dist/utils/typebox-helpers.d.ts +17 -0
- package/dist/utils/typebox-helpers.d.ts.map +1 -0
- package/dist/utils/typebox-helpers.js +21 -0
- package/dist/utils/typebox-helpers.js.map +1 -0
- package/dist/utils/uuid.d.ts +3 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/uuid.js +46 -0
- package/dist/utils/uuid.js.map +1 -0
- package/dist/utils/validation.d.ts +24 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +363 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/utils/version.d.ts +2 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +3 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +138 -4
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { ImageEditParamsNonStreaming } from "openai/resources/images";
|
|
2
|
+
import type { ImageApi, ImageModel, ImagesInputContent, ImagesInputImage, ImagesOptions } from "../types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Bounds the OpenAI Images API accepts for GPT Image 2.6 request fields. Requests outside them fail
|
|
5
|
+
* before anything is sent. The image generation guide and the API reference both document 2-16 GIF
|
|
6
|
+
* frames, and a live request with 17 frames was rejected ("Use an integer from 2 to 16", #4332).
|
|
7
|
+
*/
|
|
8
|
+
export declare const OPENAI_IMAGES_LIMITS: {
|
|
9
|
+
readonly gifFrameCount: {
|
|
10
|
+
readonly min: 2;
|
|
11
|
+
readonly max: 16;
|
|
12
|
+
};
|
|
13
|
+
readonly gifFrameDurationMs: {
|
|
14
|
+
readonly min: 20;
|
|
15
|
+
readonly max: 2000;
|
|
16
|
+
};
|
|
17
|
+
readonly outputCompression: {
|
|
18
|
+
readonly min: 0;
|
|
19
|
+
readonly max: 100;
|
|
20
|
+
};
|
|
21
|
+
readonly safetyIdentifierMaxLength: 128;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The model SVG output retries with when the API answers that `svg.model` is required and the
|
|
25
|
+
* request carried no `svg`. OpenAI's documentation names no SVG authoring model and no default:
|
|
26
|
+
* the API reference says only that `svg.model` is required when SVG model selection is enabled
|
|
27
|
+
* for the account. `gpt-6.1-sol` is a value observed to work (#4615), not a documented default.
|
|
28
|
+
*/
|
|
29
|
+
export declare const DEFAULT_SVG_AUTHOR_MODEL = "gpt-6.1-sol";
|
|
30
|
+
export type OpenAIImagesOutputFormat = "png" | "jpeg" | "webp" | "svg" | "gif";
|
|
31
|
+
/** The model that writes the SVG for `outputFormat: "svg"`, and its reasoning effort. */
|
|
32
|
+
export interface OpenAIImagesSvgOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Required by the API when SVG model selection is enabled for the account, and rejected when it is
|
|
35
|
+
* not. Leave `svg` out to let SVG output recover: when the API answers that `svg.model` is
|
|
36
|
+
* required, the request is retried once with {@link DEFAULT_SVG_AUTHOR_MODEL}.
|
|
37
|
+
*/
|
|
38
|
+
model: string;
|
|
39
|
+
reasoning?: {
|
|
40
|
+
effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Request options for OpenAI's Images API. Each field is sent only when set.
|
|
45
|
+
*
|
|
46
|
+
* Image blocks in the context go to `/images/edits`: the first image without a `role` is the base
|
|
47
|
+
* image and every other image without a `role` is a reference. An image block with `role: "markup"`
|
|
48
|
+
* is sent as the `markup` field and one with `role: "mask"` as the `mask` field; both apply to the
|
|
49
|
+
* first image, and they cannot be combined.
|
|
50
|
+
*/
|
|
51
|
+
export interface OpenAIImagesOptions extends ImagesOptions {
|
|
52
|
+
/** `auto`, a listed size, or a custom `WIDTHxHEIGHT` where the model supports one. */
|
|
53
|
+
size?: "auto" | "1024x1024" | "1536x1024" | "1024x1536" | (string & {});
|
|
54
|
+
quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto";
|
|
55
|
+
/** Number of images to generate. SVG output requires 1. */
|
|
56
|
+
n?: number;
|
|
57
|
+
/** `transparent` needs a PNG or WebP output format. */
|
|
58
|
+
background?: "transparent" | "opaque" | "auto";
|
|
59
|
+
/**
|
|
60
|
+
* `svg` and `gif` are generation-only and need a model that supports them (GPT Image 2.6).
|
|
61
|
+
* `svg` returns UTF-8 XML as `image/svg+xml`; `gif` returns an animation as `image/gif`.
|
|
62
|
+
*/
|
|
63
|
+
outputFormat?: OpenAIImagesOutputFormat;
|
|
64
|
+
/**
|
|
65
|
+
* Selects the model that authors the SVG. Needs `outputFormat: "svg"`; the API requires `svg.model`
|
|
66
|
+
* when SVG model selection is enabled for the account and rejects the field otherwise. Without
|
|
67
|
+
* `svg`, a request the API refuses for a missing `svg.model` is retried once with
|
|
68
|
+
* {@link DEFAULT_SVG_AUTHOR_MODEL}, and that retry is sent again without `svg` if the API rejects
|
|
69
|
+
* the field as unsupported. A `svg` you set is always sent as given and never retried or replaced.
|
|
70
|
+
*/
|
|
71
|
+
svg?: OpenAIImagesSvgOptions;
|
|
72
|
+
/** 0-100, for `jpeg` and `webp` output only. */
|
|
73
|
+
outputCompression?: number;
|
|
74
|
+
/** GIF frames, an integer within {@link OPENAI_IMAGES_LIMITS}. The API defaults to 9. Needs `outputFormat: "gif"`. */
|
|
75
|
+
frameCount?: number;
|
|
76
|
+
/** Milliseconds per GIF frame, an integer within {@link OPENAI_IMAGES_LIMITS}; the API rounds to 10 ms and defaults to 200. Needs `outputFormat: "gif"`. */
|
|
77
|
+
frameDurationMs?: number;
|
|
78
|
+
/** How much the model plans before rendering. GPT Image 2.6 only; the API defaults to `high`. */
|
|
79
|
+
complexity?: "low" | "medium" | "high";
|
|
80
|
+
moderation?: "auto" | "low";
|
|
81
|
+
/** A stable, privacy-preserving end-user identifier of at most 128 characters; sent as `safety_identifier`. */
|
|
82
|
+
safetyIdentifier?: string;
|
|
83
|
+
}
|
|
84
|
+
/** The fields of an Images API request this provider validates. Upload fields are opaque here. */
|
|
85
|
+
export interface OpenAIImagesWireParams {
|
|
86
|
+
model: string;
|
|
87
|
+
prompt: string;
|
|
88
|
+
size?: string;
|
|
89
|
+
quality?: string;
|
|
90
|
+
n?: number;
|
|
91
|
+
background?: string;
|
|
92
|
+
output_format?: string;
|
|
93
|
+
output_compression?: number;
|
|
94
|
+
frame_count?: number;
|
|
95
|
+
frame_duration_ms?: number;
|
|
96
|
+
complexity?: string;
|
|
97
|
+
moderation?: string;
|
|
98
|
+
safety_identifier?: string;
|
|
99
|
+
svg?: OpenAIImagesSvgOptions;
|
|
100
|
+
stream?: boolean;
|
|
101
|
+
partial_images?: number;
|
|
102
|
+
image?: ImageEditParamsNonStreaming["image"];
|
|
103
|
+
markup?: object;
|
|
104
|
+
mask?: object;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Check a request against the Images API rules before it is sent, and throw an
|
|
108
|
+
* {@link ImageGenerationConfigError} naming the first offending option. Runs on the request as it
|
|
109
|
+
* will be sent, so it also covers a request an `onPayload` hook replaced.
|
|
110
|
+
*/
|
|
111
|
+
export declare function validateOpenAIImagesRequest(model: ImageModel<ImageApi>, params: OpenAIImagesWireParams): void;
|
|
112
|
+
export interface PartitionedInputImages {
|
|
113
|
+
/** Images without a role in order: the first is the base image and the rest are references. */
|
|
114
|
+
images: ImagesInputImage[];
|
|
115
|
+
markup?: ImagesInputImage;
|
|
116
|
+
mask?: ImagesInputImage;
|
|
117
|
+
}
|
|
118
|
+
/** Split the image blocks of a request by role, rejecting roles the API cannot express. */
|
|
119
|
+
export declare function partitionInputImages(model: ImageModel<ImageApi>, input: readonly ImagesInputContent[]): PartitionedInputImages;
|
|
120
|
+
//# sourceMappingURL=openai-images-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-images-options.d.ts","sourceRoot":"","sources":["../../src/api/openai-images-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE7G;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;aAChC,aAAa;iBAAI,GAAG,EAAE,CAAC;iBAAE,GAAG,EAAE,EAAE;;aAChC,kBAAkB;iBAAI,GAAG,EAAE,EAAE;iBAAE,GAAG,EAAE,IAAI;;aACxC,iBAAiB;iBAAI,GAAG,EAAE,CAAC;iBAAE,GAAG,EAAE,GAAG;;aACrC,yBAAyB,EAAE,GAAG;CACrB,CAAC;AAEX;;;;;GAKG;A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ationConfigError } from "../image-generation-error.js";
|
|
2
|
+
/**
|
|
3
|
+
* Bounds the OpenAI Images API accepts for GPT Image 2.6 request fields. Requests outside them fail
|
|
4
|
+
* before anything is sent. The image generation guide and the API reference both document 2-16 GIF
|
|
5
|
+
* frames, and a live request with 17 frames was rejected ("Use an integer from 2 to 16", #4332).
|
|
6
|
+
*/
|
|
7
|
+
export const OPENAI_IMAGES_LIMITS = {
|
|
8
|
+
gifFrameCount: { min: 2, max: 16 },
|
|
9
|
+
gifFrameDurationMs: { min: 20, max: 2000 },
|
|
10
|
+
outputCompression: { min: 0, max: 100 },
|
|
11
|
+
safetyIdentifierMaxLength: 128,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The model SVG output retries with when the API answers that `svg.model` is required and the
|
|
15
|
+
* request carried no `svg`. OpenAI's documentation names no SVG authoring model and no default:
|
|
16
|
+
* the API reference says only that `svg.model` is required when SVG model selection is enabled
|
|
17
|
+
* for the account. `gpt-6.1-sol` is a value observed to work (#4615), not a documented default.
|
|
18
|
+
*/
|
|
19
|
+
export const DEFAULT_SVG_AUTHOR_MODEL = "gpt-6.1-sol";
|
|
20
|
+
function fail(model, field, reason, detail, hint, related) {
|
|
21
|
+
throw new ImageGenerationConfigError({ model: model.id, field, reason, related, detail, hint });
|
|
22
|
+
}
|
|
23
|
+
function checkIntegerRange(model, field, value, range) {
|
|
24
|
+
if (value === undefined)
|
|
25
|
+
return;
|
|
26
|
+
if (Number.isInteger(value) && value >= range.min && value <= range.max)
|
|
27
|
+
return;
|
|
28
|
+
fail(model, field, "out-of-range", `${field} must be an integer from ${range.min} to ${range.max}`, `Set ${field} to an integer from ${range.min} to ${range.max}.`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check a request against the Images API rules before it is sent, and throw an
|
|
32
|
+
* {@link ImageGenerationConfigError} naming the first offending option. Runs on the request as it
|
|
33
|
+
* will be sent, so it also covers a request an `onPayload` hook replaced.
|
|
34
|
+
*/
|
|
35
|
+
export function validateOpenAIImagesRequest(model, params) {
|
|
36
|
+
const format = params.output_format;
|
|
37
|
+
const isEdit = params.image !== undefined;
|
|
38
|
+
const isGif = format === "gif";
|
|
39
|
+
const isSvg = format === "svg";
|
|
40
|
+
checkIntegerRange(model, "frameCount", params.frame_count, OPENAI_IMAGES_LIMITS.gifFrameCount);
|
|
41
|
+
checkIntegerRange(model, "frameDurationMs", params.frame_duration_ms, OPENAI_IMAGES_LIMITS.gifFrameDurationMs);
|
|
42
|
+
checkIntegerRange(model, "outputCompression", params.output_compression, OPENAI_IMAGES_LIMITS.outputCompression);
|
|
43
|
+
if (params.safety_identifier !== undefined &&
|
|
44
|
+
params.safety_identifier.length > OPENAI_IMAGES_LIMITS.safetyIdentifierMaxLength) {
|
|
45
|
+
fail(model, "safetyIdentifier", "out-of-range", `safetyIdentifier must be at most ${OPENAI_IMAGES_LIMITS.safetyIdentifierMaxLength} characters`, "Hash the user name or email address and send the digest.");
|
|
46
|
+
}
|
|
47
|
+
for (const [field, value] of [
|
|
48
|
+
["frameCount", params.frame_count],
|
|
49
|
+
["frameDurationMs", params.frame_duration_ms],
|
|
50
|
+
]) {
|
|
51
|
+
if (value !== undefined && !isGif) {
|
|
52
|
+
fail(model, field, "requires-option", `${field} applies to animated GIF output only`, 'Set outputFormat to "gif" or remove the option.', "outputFormat");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (params.svg !== undefined && !isSvg) {
|
|
56
|
+
fail(model, "svg", "requires-option", "svg applies to SVG output only", 'Set outputFormat to "svg" or remove the option.', "outputFormat");
|
|
57
|
+
}
|
|
58
|
+
if ((isGif || isSvg) && isEdit) {
|
|
59
|
+
fail(model, "outputFormat", "generation-only", `${format} output is available on generations only, not on edits`, "Remove the input images, or choose png, jpeg or webp.", "image");
|
|
60
|
+
}
|
|
61
|
+
if (isSvg && params.n !== undefined && params.n !== 1) {
|
|
62
|
+
fail(model, "n", "conflicts-with-option", "svg output requires n to be 1", "Set n to 1 or remove it.", "outputFormat");
|
|
63
|
+
}
|
|
64
|
+
if ((isGif || isSvg) && (params.stream === true || params.partial_images !== undefined)) {
|
|
65
|
+
const field = params.stream === true ? "stream" : "partialImages";
|
|
66
|
+
fail(model, field, "conflicts-with-option", `${format} output does not support streaming or partial images`, `Remove ${field} from the request.`, "outputFormat");
|
|
67
|
+
}
|
|
68
|
+
if (params.background === "transparent" && format !== undefined && format !== "png" && format !== "webp") {
|
|
69
|
+
fail(model, "background", "conflicts-with-option", "transparent backgrounds require png or webp output", 'Set outputFormat to "png" or "webp", or remove the transparent background.', "outputFormat");
|
|
70
|
+
}
|
|
71
|
+
if (params.output_compression !== undefined && format !== "jpeg" && format !== "webp") {
|
|
72
|
+
fail(model, "outputCompression", "conflicts-with-option", "outputCompression applies to jpeg and webp output only", 'Set outputFormat to "jpeg" or "webp", or remove outputCompression.', "outputFormat");
|
|
73
|
+
}
|
|
74
|
+
const hasBaseImage = Array.isArray(params.image) ? params.image.length > 0 : params.image != null;
|
|
75
|
+
for (const role of ["markup", "mask"]) {
|
|
76
|
+
if (params[role] !== undefined && !hasBaseImage) {
|
|
77
|
+
fail(model, "input", "requires-base-image", `an image with role "${role}" needs a base image to apply to`, "Add an image without a role before it; the first image is the base.", role);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (params.markup !== undefined && params.mask !== undefined) {
|
|
81
|
+
fail(model, "markup", "conflicts-with-option", "a markup image cannot be combined with a mask image", 'Remove the image with role "markup" or the one with role "mask".', "mask");
|
|
82
|
+
}
|
|
83
|
+
const requireFeature = (field, used, feature) => {
|
|
84
|
+
if (!used || model.capabilities?.[feature] === true)
|
|
85
|
+
return;
|
|
86
|
+
fail(model, field, "unsupported-by-model", `${model.id} does not support ${field}`, "Use a GPT Image 2.6 model (gpt-image-2.6-sunburst or gpt-image-2.6-flare).");
|
|
87
|
+
};
|
|
88
|
+
requireFeature("complexity", params.complexity !== undefined, "complexity");
|
|
89
|
+
requireFeature("outputFormat", isGif, "gif");
|
|
90
|
+
requireFeature("outputFormat", isSvg, "svg");
|
|
91
|
+
requireFeature("markup", params.markup !== undefined, "markup");
|
|
92
|
+
}
|
|
93
|
+
/** Split the image blocks of a request by role, rejecting roles the API cannot express. */
|
|
94
|
+
export function partitionInputImages(model, input) {
|
|
95
|
+
const blocks = input.filter((item) => item.type === "image");
|
|
96
|
+
const images = blocks.filter((block) => block.role === undefined);
|
|
97
|
+
const markups = blocks.filter((block) => block.role === "markup");
|
|
98
|
+
const masks = blocks.filter((block) => block.role === "mask");
|
|
99
|
+
for (const [role, found] of [
|
|
100
|
+
["markup", markups],
|
|
101
|
+
["mask", masks],
|
|
102
|
+
]) {
|
|
103
|
+
if (found.length > 1) {
|
|
104
|
+
fail(model, "input", "duplicate-role", `at most one image can have role "${role}"`, `Keep one image with role "${role}".`, role);
|
|
105
|
+
}
|
|
106
|
+
if (found.length === 1 && images.length === 0) {
|
|
107
|
+
fail(model, "input", "requires-base-image", `an image with role "${role}" needs a base image to apply to`, "Add an image without a role before it; the first image is the base.", role);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return { images, markup: markups[0], mask: masks[0] };
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=openai-images-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-images-options.js","sourceRoot":"","sources":["../../src/api/openai-images-options.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAoC,MAAM,8BAA8B,CAAC;AAG5G;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IACnC,aAAa,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IAClC,kBAAkB,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;IAC1C,iBAAiB,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE;IACvC,yBAAyB,EAAE,GAAG;CACr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MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IAClE,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IAC9D,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI;QAC3B,CAAC,QAAQ,EAAE,OAAO,CAAC;QACnB,CAAC,MAAM,EAAE,KAAK,CAAC;KACN,EAAE,CAAC;QACZ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,IAAI,CACH,KAAK,EACL,OAAO,EACP,gBAAgB,EAChB,oCAAoC,IAAI,GAAG,EAC3C,6BAA6B,IAAI,IAAI,EACrC,IAAI,CACJ,CAAC;QACH,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/C,IAAI,CACH,KAAK,EACL,OAAO,EACP,qBAAqB,EACrB,uBAAuB,IAAI,kCAAkC,EAC7D,qEAAqE,EACrE,IAAI,CACJ,CAAC;QACH,CAAC;IACF,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACvD,CAAC","sourcesContent":["import type { ImageEditParamsNonStreaming } from \"openai/resources/images\";\nimport { ImageGenerationConfigError, type ImageGenerationConfigReason } from \"../image-generation-error.ts\";\nimport type { ImageApi, ImageModel, ImagesInputContent, ImagesInputImage, ImagesOptions } from \"../types.ts\";\n\n/**\n * Bounds the OpenAI Images API accepts for GPT Image 2.6 request fields. Requests outside them fail\n * before anything is sent. The image generation guide and the API reference both document 2-16 GIF\n * frames, and a live request with 17 frames was rejected (\"Use an integer from 2 to 16\", #4332).\n */\nexport const OPENAI_IMAGES_LIMITS = {\n\tgifFrameCount: { min: 2, max: 16 },\n\tgifFrameDurationMs: { min: 20, max: 2000 },\n\toutputCompression: { min: 0, max: 100 },\n\tsafetyIdentifierMaxLength: 128,\n} as const;\n\n/**\n * The model SVG output retries with when the API answers that `svg.model` is required and the\n * request carried no `svg`. OpenAI's documentation names no SVG authoring model and no default:\n * the API reference says only that `svg.model` is required when SVG model selection is enabled\n * for the account. `gpt-6.1-sol` is a value observed to work (#4615), not a documented default.\n */\nexport const DEFAULT_SVG_AUTHOR_MODEL = \"gpt-6.1-sol\";\n\nexport type OpenAIImagesOutputFormat = \"png\" | \"jpeg\" | \"webp\" | \"svg\" | \"gif\";\n\n/** The model that writes the SVG for `outputFormat: \"svg\"`, and its reasoning effort. */\nexport interface OpenAIImagesSvgOptions {\n\t/**\n\t * Required by the API when SVG model selection is enabled for the account, and rejected when it is\n\t * not. Leave `svg` out to let SVG output recover: when the API answers that `svg.model` is\n\t * required, the request is retried once with {@link DEFAULT_SVG_AUTHOR_MODEL}.\n\t */\n\tmodel: string;\n\treasoning?: { effort?: \"none\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\" };\n}\n\n/**\n * Request options for OpenAI's Images API. Each field is sent only when set.\n *\n * Image blocks in the context go to `/images/edits`: the first image without a `role` is the base\n * image and every other image without a `role` is a reference. An image block with `role: \"markup\"`\n * is sent as the `markup` field and one with `role: \"mask\"` as the `mask` field; both apply to the\n * first image, and they cannot be combined.\n */\nexport interface OpenAIImagesOptions extends ImagesOptions {\n\t/** `auto`, a listed size, or a custom `WIDTHxHEIGHT` where the model supports one. */\n\tsize?: \"auto\" | \"1024x1024\" | \"1536x1024\" | \"1024x1536\" | (string & {});\n\tquality?: \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\" | \"auto\";\n\t/** Number of images to generate. SVG output requires 1. */\n\tn?: number;\n\t/** `transparent` needs a PNG or WebP output format. */\n\tbackground?: \"transparent\" | \"opaque\" | \"auto\";\n\t/**\n\t * `svg` and `gif` are generation-only and need a model that supports them (GPT Image 2.6).\n\t * `svg` returns UTF-8 XML as `image/svg+xml`; `gif` returns an animation as `image/gif`.\n\t */\n\toutputFormat?: OpenAIImagesOutputFormat;\n\t/**\n\t * Selects the model that authors the SVG. Needs `outputFormat: \"svg\"`; the API requires `svg.model`\n\t * when SVG model selection is enabled for the account and rejects the field otherwise. Without\n\t * `svg`, a request the API refuses for a missing `svg.model` is retried once with\n\t * {@link DEFAULT_SVG_AUTHOR_MODEL}, and that retry is sent again without `svg` if the API rejects\n\t * the field as unsupported. A `svg` you set is always sent as given and never retried or replaced.\n\t */\n\tsvg?: OpenAIImagesSvgOptions;\n\t/** 0-100, for `jpeg` and `webp` output only. */\n\toutputCompression?: number;\n\t/** GIF frames, an integer within {@link OPENAI_IMAGES_LIMITS}. The API defaults to 9. Needs `outputFormat: \"gif\"`. */\n\tframeCount?: number;\n\t/** Milliseconds per GIF frame, an integer within {@link OPENAI_IMAGES_LIMITS}; the API rounds to 10 ms and defaults to 200. Needs `outputFormat: \"gif\"`. */\n\tframeDurationMs?: number;\n\t/** How much the model plans before rendering. GPT Image 2.6 only; the API defaults to `high`. */\n\tcomplexity?: \"low\" | \"medium\" | \"high\";\n\tmoderation?: \"auto\" | \"low\";\n\t/** A stable, privacy-preserving end-user identifier of at most 128 characters; sent as `safety_identifier`. */\n\tsafetyIdentifier?: string;\n}\n\n/** The fields of an Images API request this provider validates. Upload fields are opaque here. */\nexport interface OpenAIImagesWireParams {\n\tmodel: string;\n\tprompt: string;\n\tsize?: string;\n\tquality?: string;\n\tn?: number;\n\tbackground?: string;\n\toutput_format?: string;\n\toutput_compression?: number;\n\tframe_count?: number;\n\tframe_duration_ms?: number;\n\tcomplexity?: string;\n\tmoderation?: string;\n\tsafety_identifier?: string;\n\tsvg?: OpenAIImagesSvgOptions;\n\tstream?: boolean;\n\tpartial_images?: number;\n\timage?: ImageEditParamsNonStreaming[\"image\"];\n\tmarkup?: object;\n\tmask?: object;\n}\n\nfunction fail(\n\tmodel: ImageModel<ImageApi>,\n\tfield: string,\n\treason: ImageGenerationConfigReason,\n\tdetail: string,\n\thint: string,\n\trelated?: string,\n): never {\n\tthrow new ImageGenerationConfigError({ model: model.id, field, reason, related, detail, hint });\n}\n\nfunction checkIntegerRange(\n\tmodel: ImageModel<ImageApi>,\n\tfield: string,\n\tvalue: number | undefined,\n\trange: { min: number; max: number },\n): void {\n\tif (value === undefined) return;\n\tif (Number.isInteger(value) && value >= range.min && value <= range.max) return;\n\tfail(\n\t\tmodel,\n\t\tfield,\n\t\t\"out-of-range\",\n\t\t`${field} must be an integer from ${range.min} to ${range.max}`,\n\t\t`Set ${field} to an integer from ${range.min} to ${range.max}.`,\n\t);\n}\n\n/**\n * Check a request against the Images API rules before it is sent, and throw an\n * {@link ImageGenerationConfigError} naming the first offending option. Runs on the request as it\n * will be sent, so it also covers a request an `onPayload` hook replaced.\n */\nexport function validateOpenAIImagesRequest(model: ImageModel<ImageApi>, params: OpenAIImagesWireParams): void {\n\tconst format = params.output_format;\n\tconst isEdit = params.image !== undefined;\n\tconst isGif = format === \"gif\";\n\tconst isSvg = format === \"svg\";\n\n\tcheckIntegerRange(model, \"frameCount\", params.frame_count, OPENAI_IMAGES_LIMITS.gifFrameCount);\n\tcheckIntegerRange(model, \"frameDurationMs\", params.frame_duration_ms, OPENAI_IMAGES_LIMITS.gifFrameDurationMs);\n\tcheckIntegerRange(model, \"outputCompression\", params.output_compression, OPENAI_IMAGES_LIMITS.outputCompression);\n\tif (\n\t\tparams.safety_identifier !== undefined &&\n\t\tparams.safety_identifier.length > OPENAI_IMAGES_LIMITS.safetyIdentifierMaxLength\n\t) {\n\t\tfail(\n\t\t\tmodel,\n\t\t\t\"safetyIdentifier\",\n\t\t\t\"out-of-range\",\n\t\t\t`safetyIdentifier must be at most ${OPENAI_IMAGES_LIMITS.safetyIdentifierMaxLength} characters`,\n\t\t\t\"Hash the user name or email address and send the digest.\",\n\t\t);\n\t}\n\n\tfor (const [field, value] of [\n\t\t[\"frameCount\", params.frame_count],\n\t\t[\"frameDurationMs\", params.frame_duration_ms],\n\t] as const) {\n\t\tif (value !== undefined && !isGif) {\n\t\t\tfail(\n\t\t\t\tmodel,\n\t\t\t\tfield,\n\t\t\t\t\"requires-option\",\n\t\t\t\t`${field} applies to animated GIF output only`,\n\t\t\t\t'Set outputFormat to \"gif\" or remove the option.',\n\t\t\t\t\"outputFormat\",\n\t\t\t);\n\t\t}\n\t}\n\n\tif (params.svg !== undefined && !isSvg) {\n\t\tfail(\n\t\t\tmodel,\n\t\t\t\"svg\",\n\t\t\t\"requires-option\",\n\t\t\t\"svg applies to SVG output only\",\n\t\t\t'Set outputFormat to \"svg\" or remove the option.',\n\t\t\t\"outputFormat\",\n\t\t);\n\t}\n\tif ((isGif || isSvg) && isEdit) {\n\t\tfail(\n\t\t\tmodel,\n\t\t\t\"outputFormat\",\n\t\t\t\"generation-only\",\n\t\t\t`${format} output is available on generations only, not on edits`,\n\t\t\t\"Remove the input images, or choose png, jpeg or webp.\",\n\t\t\t\"image\",\n\t\t);\n\t}\n\tif (isSvg && params.n !== undefined && params.n !== 1) {\n\t\tfail(\n\t\t\tmodel,\n\t\t\t\"n\",\n\t\t\t\"conflicts-with-option\",\n\t\t\t\"svg output requires n to be 1\",\n\t\t\t\"Set n to 1 or remove it.\",\n\t\t\t\"outputFormat\",\n\t\t);\n\t}\n\tif ((isGif || isSvg) && (params.stream === true || params.partial_images !== undefined)) {\n\t\tconst field = params.stream === true ? \"stream\" : \"partialImages\";\n\t\tfail(\n\t\t\tmodel,\n\t\t\tfield,\n\t\t\t\"conflicts-with-option\",\n\t\t\t`${format} output does not support streaming or partial images`,\n\t\t\t`Remove ${field} from the request.`,\n\t\t\t\"outputFormat\",\n\t\t);\n\t}\n\tif (params.background === \"transparent\" && format !== undefined && format !== \"png\" && format !== \"webp\") {\n\t\tfail(\n\t\t\tmodel,\n\t\t\t\"background\",\n\t\t\t\"conflicts-with-option\",\n\t\t\t\"transparent backgrounds require png or webp output\",\n\t\t\t'Set outputFormat to \"png\" or \"webp\", or remove the transparent background.',\n\t\t\t\"outputFormat\",\n\t\t);\n\t}\n\tif (params.output_compression !== undefined && format !== \"jpeg\" && format !== \"webp\") {\n\t\tfail(\n\t\t\tmodel,\n\t\t\t\"outputCompression\",\n\t\t\t\"conflicts-with-option\",\n\t\t\t\"outputCompression applies to jpeg and webp output only\",\n\t\t\t'Set outputFormat to \"jpeg\" or \"webp\", or remove outputCompression.',\n\t\t\t\"outputFormat\",\n\t\t);\n\t}\n\tconst hasBaseImage = Array.isArray(params.image) ? params.image.length > 0 : params.image != null;\n\tfor (const role of [\"markup\", \"mask\"] as const) {\n\t\tif (params[role] !== undefined && !hasBaseImage) {\n\t\t\tfail(\n\t\t\t\tmodel,\n\t\t\t\t\"input\",\n\t\t\t\t\"requires-base-image\",\n\t\t\t\t`an image with role \"${role}\" needs a base image to apply to`,\n\t\t\t\t\"Add an image without a role before it; the first image is the base.\",\n\t\t\t\trole,\n\t\t\t);\n\t\t}\n\t}\n\tif (params.markup !== undefined && params.mask !== undefined) {\n\t\tfail(\n\t\t\tmodel,\n\t\t\t\"markup\",\n\t\t\t\"conflicts-with-option\",\n\t\t\t\"a markup image cannot be combined with a mask image\",\n\t\t\t'Remove the image with role \"markup\" or the one with role \"mask\".',\n\t\t\t\"mask\",\n\t\t);\n\t}\n\n\tconst requireFeature = (\n\t\tfield: string,\n\t\tused: boolean,\n\t\tfeature: keyof NonNullable<ImageModel<ImageApi>[\"capabilities\"]>,\n\t): void => {\n\t\tif (!used || model.capabilities?.[feature] === true) return;\n\t\tfail(\n\t\t\tmodel,\n\t\t\tfield,\n\t\t\t\"unsupported-by-model\",\n\t\t\t`${model.id} does not support ${field}`,\n\t\t\t\"Use a GPT Image 2.6 model (gpt-image-2.6-sunburst or gpt-image-2.6-flare).\",\n\t\t);\n\t};\n\trequireFeature(\"complexity\", params.complexity !== undefined, \"complexity\");\n\trequireFeature(\"outputFormat\", isGif, \"gif\");\n\trequireFeature(\"outputFormat\", isSvg, \"svg\");\n\trequireFeature(\"markup\", params.markup !== undefined, \"markup\");\n}\n\nexport interface PartitionedInputImages {\n\t/** Images without a role in order: the first is the base image and the rest are references. */\n\timages: ImagesInputImage[];\n\tmarkup?: ImagesInputImage;\n\tmask?: ImagesInputImage;\n}\n\n/** Split the image blocks of a request by role, rejecting roles the API cannot express. */\nexport function partitionInputImages(\n\tmodel: ImageModel<ImageApi>,\n\tinput: readonly ImagesInputContent[],\n): PartitionedInputImages {\n\tconst blocks = input.filter((item): item is ImagesInputImage => item.type === \"image\");\n\tconst images = blocks.filter((block) => block.role === undefined);\n\tconst markups = blocks.filter((block) => block.role === \"markup\");\n\tconst masks = blocks.filter((block) => block.role === \"mask\");\n\tfor (const [role, found] of [\n\t\t[\"markup\", markups],\n\t\t[\"mask\", masks],\n\t] as const) {\n\t\tif (found.length > 1) {\n\t\t\tfail(\n\t\t\t\tmodel,\n\t\t\t\t\"input\",\n\t\t\t\t\"duplicate-role\",\n\t\t\t\t`at most one image can have role \"${role}\"`,\n\t\t\t\t`Keep one image with role \"${role}\".`,\n\t\t\t\trole,\n\t\t\t);\n\t\t}\n\t\tif (found.length === 1 && images.length === 0) {\n\t\t\tfail(\n\t\t\t\tmodel,\n\t\t\t\t\"input\",\n\t\t\t\t\"requires-base-image\",\n\t\t\t\t`an image with role \"${role}\" needs a base image to apply to`,\n\t\t\t\t\"Add an image without a role before it; the first image is the base.\",\n\t\t\t\trole,\n\t\t\t);\n\t\t}\n\t}\n\treturn { images, markup: markups[0], mask: masks[0] };\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ImagesFunction } from "../types.ts";
|
|
2
|
+
import { type OpenAIImagesOptions } from "./openai-images-options.ts";
|
|
3
|
+
export type { OpenAIImagesOptions, OpenAIImagesOutputFormat, OpenAIImagesSvgOptions } from "./openai-images-options.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Image generation over OpenAI's Images API: `/images/generations` for text-only
|
|
6
|
+
* input and `/images/edits` when the context includes image blocks.
|
|
7
|
+
*/
|
|
8
|
+
export declare const generateImages: ImagesFunction<OpenAIImagesOptions>;
|
|
9
|
+
//# sourceMappingURL=openai-images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-images.d.ts","sourceRoot":"","sources":["../../src/api/openai-images.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAMX,cAAc,EAGd,MAAM,aAAa,CAAC;AAKrB,OAAO,EAEN,KAAK,mBAAmB,EAIxB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AA4BxH;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,mBAAmB,CAgF9D,CAAC"}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import OpenAI, { APIConnectionError, APIConnectionTimeoutError, APIError, APIUserAbortError, toFile, } from "openai";
|
|
2
|
+
import { findImageGenerationError, ImageGenerationApiError, ImageGenerationConfigError, ImageGenerationQuotaError, ImageGenerationRateLimitError, ImageGenerationServerError, ImageGenerationTimeoutError, ImageGenerationUserError, ImageModerationBlockedError, isImageGenerationConfigError, } from "../image-generation-error.js";
|
|
3
|
+
import { calculateCost } from "../models.js";
|
|
4
|
+
import { formatProviderError, normalizeProviderError } from "../utils/error-body.js";
|
|
5
|
+
import { headersToRecord, providerHeadersToRecord } from "../utils/headers.js";
|
|
6
|
+
import { retryProviderRequest } from "../utils/provider-retry.js";
|
|
7
|
+
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
8
|
+
import { DEFAULT_SVG_AUTHOR_MODEL, partitionInputImages, validateOpenAIImagesRequest, } from "./openai-images-options.js";
|
|
9
|
+
const OUTPUT_FORMAT_MIME_TYPES = {
|
|
10
|
+
png: "image/png",
|
|
11
|
+
jpeg: "image/jpeg",
|
|
12
|
+
webp: "image/webp",
|
|
13
|
+
gif: "image/gif",
|
|
14
|
+
svg: "image/svg+xml",
|
|
15
|
+
};
|
|
16
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 600_000;
|
|
17
|
+
/** Request options and the API fields they are sent as. */
|
|
18
|
+
const OPTION_WIRE_FIELDS = [
|
|
19
|
+
["size", "size"],
|
|
20
|
+
["quality", "quality"],
|
|
21
|
+
["n", "n"],
|
|
22
|
+
["background", "background"],
|
|
23
|
+
["outputFormat", "output_format"],
|
|
24
|
+
["svg", "svg"],
|
|
25
|
+
["outputCompression", "output_compression"],
|
|
26
|
+
["frameCount", "frame_count"],
|
|
27
|
+
["frameDurationMs", "frame_duration_ms"],
|
|
28
|
+
["complexity", "complexity"],
|
|
29
|
+
["moderation", "moderation"],
|
|
30
|
+
["safetyIdentifier", "safety_identifier"],
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* Image generation over OpenAI's Images API: `/images/generations` for text-only
|
|
34
|
+
* input and `/images/edits` when the context includes image blocks.
|
|
35
|
+
*/
|
|
36
|
+
export const generateImages = async (model, context, options) => {
|
|
37
|
+
const output = {
|
|
38
|
+
api: model.api,
|
|
39
|
+
provider: model.provider,
|
|
40
|
+
model: model.id,
|
|
41
|
+
output: [],
|
|
42
|
+
stopReason: "stop",
|
|
43
|
+
timestamp: Date.now(),
|
|
44
|
+
};
|
|
45
|
+
const state = {
|
|
46
|
+
modelId: model.id,
|
|
47
|
+
timeoutMs: options?.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,
|
|
48
|
+
startedAt: Date.now(),
|
|
49
|
+
};
|
|
50
|
+
try {
|
|
51
|
+
if (!options?.apiKey) {
|
|
52
|
+
throw new Error(`No API key for provider: ${model.provider}`);
|
|
53
|
+
}
|
|
54
|
+
const client = createClient(model, options.apiKey, options.headers, options.fetch);
|
|
55
|
+
let params = await buildParams(model, context, options);
|
|
56
|
+
validateOpenAIImagesRequest(model, params);
|
|
57
|
+
const nextParams = await options?.onPayload?.(params, model);
|
|
58
|
+
if (nextParams !== undefined)
|
|
59
|
+
params = nextParams;
|
|
60
|
+
validateOpenAIImagesRequest(model, params);
|
|
61
|
+
const requestOptions = {
|
|
62
|
+
...(options?.signal ? { signal: options.signal } : {}),
|
|
63
|
+
timeout: state.timeoutMs,
|
|
64
|
+
maxRetries: 0,
|
|
65
|
+
};
|
|
66
|
+
const send = async (body, svgModelDefaulted) => {
|
|
67
|
+
state.svgModelDefaulted = svgModelDefaulted;
|
|
68
|
+
const { data, response } = await retryProviderRequest(() => body.image !== undefined
|
|
69
|
+
? client.images.edit(body, requestOptions).withResponse()
|
|
70
|
+
: client.images.generate(body, requestOptions).withResponse(), {
|
|
71
|
+
maxRetries: options.maxRetries,
|
|
72
|
+
maxRetryDelayMs: options.maxRetryDelayMs,
|
|
73
|
+
signal: options.signal,
|
|
74
|
+
noRetry: (error) => classifyImageApiError(error, state)?.retryable === false,
|
|
75
|
+
});
|
|
76
|
+
return { params: body, data, response };
|
|
77
|
+
};
|
|
78
|
+
const { params: sentParams, data: response, response: rawResponse, } = await sendWithSvgRecovery(send, params, state, options.signal);
|
|
79
|
+
await options?.onResponse?.({ status: rawResponse.status, headers: headersToRecord(rawResponse.headers) }, model);
|
|
80
|
+
if (response.usage) {
|
|
81
|
+
output.usage = parseUsage(response.usage, model);
|
|
82
|
+
}
|
|
83
|
+
const svgModel = svgAuthoringModel(response) ?? sentParams.svg?.model;
|
|
84
|
+
if (svgModel !== undefined)
|
|
85
|
+
output.svgModel = svgModel;
|
|
86
|
+
const mimeType = OUTPUT_FORMAT_MIME_TYPES[response.output_format ?? sentParams.output_format ?? "png"] ?? "image/png";
|
|
87
|
+
for (const image of response.data ?? []) {
|
|
88
|
+
if (!image.b64_json)
|
|
89
|
+
continue;
|
|
90
|
+
output.output.push({ type: "image", mimeType, data: image.b64_json });
|
|
91
|
+
}
|
|
92
|
+
return output;
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
const aborted = options?.signal?.aborted === true;
|
|
96
|
+
output.stopReason = aborted ? "aborted" : "error";
|
|
97
|
+
output.errorMessage = formatProviderError(normalizeProviderError(error));
|
|
98
|
+
if (!aborted) {
|
|
99
|
+
const typed = findImageGenerationError(error) ?? classifyImageApiError(error, state);
|
|
100
|
+
if (typed)
|
|
101
|
+
output.error = typed.toData();
|
|
102
|
+
}
|
|
103
|
+
return output;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Send a request, and for SVG output without a caller `svg` recover from two API answers: a
|
|
108
|
+
* missing `svg.model` retries once with {@link DEFAULT_SVG_AUTHOR_MODEL}, and an `svg` the API
|
|
109
|
+
* then rejects as unsupported retries once more without it. At most three requests are sent. An
|
|
110
|
+
* `svg` the caller or an `onPayload` hook set is never replaced or dropped.
|
|
111
|
+
*/
|
|
112
|
+
async function sendWithSvgRecovery(send, params, state, signal) {
|
|
113
|
+
const recoverable = params.output_format === "svg" && params.svg === undefined;
|
|
114
|
+
try {
|
|
115
|
+
return await send(params, false);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (!recoverable || svgRejection(error, state) !== "required-by-api")
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
signal?.throwIfAborted();
|
|
122
|
+
try {
|
|
123
|
+
return await send({ ...params, svg: { model: DEFAULT_SVG_AUTHOR_MODEL } }, true);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (svgRejection(error, state) !== "unsupported-by-api")
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
signal?.throwIfAborted();
|
|
130
|
+
return send(params, false);
|
|
131
|
+
}
|
|
132
|
+
/** Why the API rejected the `svg` option, for the only failures that become a config error. */
|
|
133
|
+
function svgRejection(error, state) {
|
|
134
|
+
const typed = classifyImageApiError(error, state);
|
|
135
|
+
return isImageGenerationConfigError(typed) ? typed.reason : undefined;
|
|
136
|
+
}
|
|
137
|
+
/** The authoring model the API names in `svg_usage`, which the SDK's response type does not declare. */
|
|
138
|
+
function svgAuthoringModel(response) {
|
|
139
|
+
const reported = response.svg_usage?.model;
|
|
140
|
+
return typeof reported === "string" && reported !== "" ? reported : undefined;
|
|
141
|
+
}
|
|
142
|
+
/** Provider types, codes, request IDs and moderation categories are short identifiers. */
|
|
143
|
+
const SAFE_TOKEN = /^[A-Za-z0-9][A-Za-z0-9_./:-]{0,127}$/;
|
|
144
|
+
function safeToken(value) {
|
|
145
|
+
return typeof value === "string" && SAFE_TOKEN.test(value) ? value : undefined;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The provider's error message can quote the prompt, so typed errors carry only the HTTP status and
|
|
149
|
+
* identifier-shaped fields, and a cause rebuilt from them instead of the SDK error.
|
|
150
|
+
*/
|
|
151
|
+
function safeSummary(status, apiType, apiCode, requestId) {
|
|
152
|
+
return [
|
|
153
|
+
status === undefined ? "no HTTP response" : `HTTP ${status}`,
|
|
154
|
+
...(apiType ? [`type ${apiType}`] : []),
|
|
155
|
+
...(apiCode ? [`code ${apiCode}`] : []),
|
|
156
|
+
...(requestId ? [`request ${requestId}`] : []),
|
|
157
|
+
].join(", ");
|
|
158
|
+
}
|
|
159
|
+
function safeCause(sdkError, summary) {
|
|
160
|
+
const cause = new Error(summary);
|
|
161
|
+
cause.name =
|
|
162
|
+
sdkError instanceof APIConnectionTimeoutError
|
|
163
|
+
? "APIConnectionTimeoutError"
|
|
164
|
+
: sdkError instanceof APIConnectionError
|
|
165
|
+
? "APIConnectionError"
|
|
166
|
+
: "APIError";
|
|
167
|
+
return cause;
|
|
168
|
+
}
|
|
169
|
+
/** Translate an OpenAI SDK failure, also when wrapped in a retry-delay error, into the typed family. */
|
|
170
|
+
function classifyImageApiError(error, state) {
|
|
171
|
+
const cause = error instanceof Error ? error.cause : undefined;
|
|
172
|
+
const sdkError = [error, cause].find((candidate) => candidate instanceof APIError);
|
|
173
|
+
if (!sdkError || sdkError instanceof APIUserAbortError)
|
|
174
|
+
return undefined;
|
|
175
|
+
if (sdkError instanceof APIConnectionTimeoutError) {
|
|
176
|
+
return new ImageGenerationTimeoutError({
|
|
177
|
+
timeoutMs: state.timeoutMs,
|
|
178
|
+
elapsedMs: Date.now() - state.startedAt,
|
|
179
|
+
cause: safeCause(sdkError, "no HTTP response, the request timed out"),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const status = sdkError.status;
|
|
183
|
+
const apiType = safeToken(sdkError.type);
|
|
184
|
+
const apiCode = safeToken(sdkError.code);
|
|
185
|
+
const requestId = safeToken(sdkError.requestID);
|
|
186
|
+
const detail = safeSummary(status, apiType, apiCode, requestId);
|
|
187
|
+
const init = { detail, status, apiCode, apiType, requestId, cause: safeCause(sdkError, detail) };
|
|
188
|
+
if (apiType === "image_generation_user_error") {
|
|
189
|
+
if (apiCode === "moderation_blocked") {
|
|
190
|
+
const details = sdkError.error.moderation_details;
|
|
191
|
+
const stage = details?.moderation_stage;
|
|
192
|
+
return new ImageModerationBlockedError({
|
|
193
|
+
...init,
|
|
194
|
+
moderationStage: stage === "input" || stage === "output" || stage === "unknown" ? stage : undefined,
|
|
195
|
+
categories: Array.isArray(details?.categories)
|
|
196
|
+
? details.categories.filter((category) => safeToken(category) !== undefined)
|
|
197
|
+
: [],
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return new ImageGenerationUserError(init);
|
|
201
|
+
}
|
|
202
|
+
const svgFailure = classifySvgFailure(sdkError.param, status, apiCode, state, init);
|
|
203
|
+
if (svgFailure)
|
|
204
|
+
return svgFailure;
|
|
205
|
+
if (apiCode === "insufficient_quota" || apiType === "insufficient_quota") {
|
|
206
|
+
return new ImageGenerationQuotaError(init);
|
|
207
|
+
}
|
|
208
|
+
if (status === 429)
|
|
209
|
+
return new ImageGenerationRateLimitError(init);
|
|
210
|
+
if ((status ?? 0) >= 500)
|
|
211
|
+
return new ImageGenerationServerError(init);
|
|
212
|
+
return new ImageGenerationApiError({ ...init, retryable: status === undefined || status === 408 || status === 409 });
|
|
213
|
+
}
|
|
214
|
+
const SVG_FIELDS = ["svg", "svg.model"];
|
|
215
|
+
const SVG_REJECTION_STATUSES = [400, 404, 422];
|
|
216
|
+
const SVG_UNSUPPORTED_CODES = ["unsupported_parameter", "unknown_parameter"];
|
|
217
|
+
function isSvgField(param) {
|
|
218
|
+
return SVG_FIELDS.some((field) => field === param);
|
|
219
|
+
}
|
|
220
|
+
function svgRejectionReason(param, apiCode) {
|
|
221
|
+
if (param === "svg.model" && apiCode === "missing_required_parameter")
|
|
222
|
+
return "required-by-api";
|
|
223
|
+
if (SVG_UNSUPPORTED_CODES.includes(apiCode))
|
|
224
|
+
return "unsupported-by-api";
|
|
225
|
+
return param === "svg.model" ? "rejected-by-api" : undefined;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Translate the API's rejection of the `svg` option into an `invalid-option` error naming the
|
|
229
|
+
* field, found by the response's `param` and `code`, never by its message.
|
|
230
|
+
*/
|
|
231
|
+
function classifySvgFailure(param, status, apiCode, state, init) {
|
|
232
|
+
if (!isSvgField(param) || !SVG_REJECTION_STATUSES.includes(status))
|
|
233
|
+
return undefined;
|
|
234
|
+
const reason = svgRejectionReason(param, apiCode);
|
|
235
|
+
if (reason === undefined)
|
|
236
|
+
return undefined;
|
|
237
|
+
const text = describeSvgRejection(param, reason, state);
|
|
238
|
+
return new ImageGenerationConfigError({
|
|
239
|
+
model: state.modelId,
|
|
240
|
+
field: param,
|
|
241
|
+
reason,
|
|
242
|
+
detail: `${text.detail} (${init.detail})`,
|
|
243
|
+
hint: text.hint,
|
|
244
|
+
cause: init.cause,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
function describeSvgRejection(field, reason, state) {
|
|
248
|
+
if (reason === "required-by-api") {
|
|
249
|
+
return {
|
|
250
|
+
detail: "the API requires svg.model for SVG output on this account",
|
|
251
|
+
hint: `Set svg.model to an SVG authoring model your account can use, for example svg: { model: "${DEFAULT_SVG_AUTHOR_MODEL}" }.`,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
if (reason === "unsupported-by-api") {
|
|
255
|
+
return {
|
|
256
|
+
detail: `the API does not accept ${field} on this account`,
|
|
257
|
+
hint: "Remove svg from the request: this account does not take an SVG authoring model.",
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
detail: state.svgModelDefaulted
|
|
262
|
+
? `the API rejected ${DEFAULT_SVG_AUTHOR_MODEL}, the default SVG authoring model the request was retried with`
|
|
263
|
+
: "the API rejected svg.model",
|
|
264
|
+
hint: "Set svg.model to an SVG authoring model your account can use.",
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function createClient(model, apiKey, optionsHeaders, fetch) {
|
|
268
|
+
return new OpenAI({
|
|
269
|
+
apiKey,
|
|
270
|
+
baseURL: model.baseUrl,
|
|
271
|
+
dangerouslyAllowBrowser: true,
|
|
272
|
+
fetch,
|
|
273
|
+
defaultHeaders: providerHeadersToRecord({ ...model.headers, ...optionsHeaders }),
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
async function buildParams(model, context, options) {
|
|
277
|
+
const prompt = context.input
|
|
278
|
+
.flatMap((item) => (item.type === "text" ? [sanitizeSurrogates(item.text)] : []))
|
|
279
|
+
.join("\n\n");
|
|
280
|
+
const params = {
|
|
281
|
+
model: model.id,
|
|
282
|
+
prompt,
|
|
283
|
+
...Object.fromEntries(OPTION_WIRE_FIELDS.flatMap(([option, field]) => options[option] === undefined ? [] : [[field, options[option]]])),
|
|
284
|
+
};
|
|
285
|
+
const { images, markup, mask } = partitionInputImages(model, context.input);
|
|
286
|
+
if (images.length === 0)
|
|
287
|
+
return params;
|
|
288
|
+
return {
|
|
289
|
+
...params,
|
|
290
|
+
image: await Promise.all(images.map((image, index) => toUpload(image, `image-${index + 1}`))),
|
|
291
|
+
...(markup ? { markup: await toUpload(markup, "markup") } : {}),
|
|
292
|
+
...(mask ? { mask: await toUpload(mask, "mask") } : {}),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function toUpload(image, name) {
|
|
296
|
+
return toFile(base64ToBytes(image.data), `${name}.${image.mimeType.split("/")[1] ?? "png"}`, {
|
|
297
|
+
type: image.mimeType,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function base64ToBytes(data) {
|
|
301
|
+
return Uint8Array.from(atob(data), (char) => char.charCodeAt(0));
|
|
302
|
+
}
|
|
303
|
+
function parseUsage(rawUsage, model) {
|
|
304
|
+
const input = rawUsage.input_tokens || 0;
|
|
305
|
+
const output = rawUsage.output_tokens || 0;
|
|
306
|
+
const usage = {
|
|
307
|
+
input,
|
|
308
|
+
output,
|
|
309
|
+
cacheRead: 0,
|
|
310
|
+
cacheWrite: 0,
|
|
311
|
+
totalTokens: rawUsage.total_tokens || input + output,
|
|
312
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
313
|
+
};
|
|
314
|
+
calculateCost(model, usage);
|
|
315
|
+
return usage;
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=openai-images.js.map
|