@earendil-works/pi-ai 0.80.1 → 0.80.3

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.
Files changed (148) hide show
  1. package/README.md +14 -1
  2. package/dist/api/anthropic-messages.d.ts.map +1 -1
  3. package/dist/api/anthropic-messages.js +17 -10
  4. package/dist/api/anthropic-messages.js.map +1 -1
  5. package/dist/api/azure-openai-responses.d.ts.map +1 -1
  6. package/dist/api/azure-openai-responses.js +11 -17
  7. package/dist/api/azure-openai-responses.js.map +1 -1
  8. package/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  9. package/dist/api/bedrock-converse-stream.js +17 -8
  10. package/dist/api/bedrock-converse-stream.js.map +1 -1
  11. package/dist/api/google-generative-ai.d.ts.map +1 -1
  12. package/dist/api/google-generative-ai.js +4 -2
  13. package/dist/api/google-generative-ai.js.map +1 -1
  14. package/dist/api/google-vertex.d.ts.map +1 -1
  15. package/dist/api/google-vertex.js +4 -2
  16. package/dist/api/google-vertex.js.map +1 -1
  17. package/dist/api/mistral-conversations.d.ts.map +1 -1
  18. package/dist/api/mistral-conversations.js +1 -1
  19. package/dist/api/mistral-conversations.js.map +1 -1
  20. package/dist/api/openai-codex-responses.d.ts.map +1 -1
  21. package/dist/api/openai-codex-responses.js +11 -25
  22. package/dist/api/openai-codex-responses.js.map +1 -1
  23. package/dist/api/openai-completions.d.ts.map +1 -1
  24. package/dist/api/openai-completions.js +105 -44
  25. package/dist/api/openai-completions.js.map +1 -1
  26. package/dist/api/openai-responses-shared.d.ts.map +1 -1
  27. package/dist/api/openai-responses-shared.js +152 -175
  28. package/dist/api/openai-responses-shared.js.map +1 -1
  29. package/dist/api/openai-responses.d.ts.map +1 -1
  30. package/dist/api/openai-responses.js +3 -15
  31. package/dist/api/openai-responses.js.map +1 -1
  32. package/dist/api/openrouter-images.d.ts.map +1 -1
  33. package/dist/api/openrouter-images.js +2 -1
  34. package/dist/api/openrouter-images.js.map +1 -1
  35. package/dist/api/simple-options.d.ts +3 -2
  36. package/dist/api/simple-options.d.ts.map +1 -1
  37. package/dist/api/simple-options.js +11 -2
  38. package/dist/api/simple-options.js.map +1 -1
  39. package/dist/auth/helpers.d.ts +1 -1
  40. package/dist/auth/helpers.d.ts.map +1 -1
  41. package/dist/auth/helpers.js +2 -2
  42. package/dist/auth/helpers.js.map +1 -1
  43. package/dist/auth/resolve.d.ts +6 -2
  44. package/dist/auth/resolve.d.ts.map +1 -1
  45. package/dist/auth/resolve.js +19 -4
  46. package/dist/auth/resolve.js.map +1 -1
  47. package/dist/auth/types.d.ts +7 -7
  48. package/dist/auth/types.d.ts.map +1 -1
  49. package/dist/auth/types.js.map +1 -1
  50. package/dist/compat.d.ts +1 -0
  51. package/dist/compat.d.ts.map +1 -1
  52. package/dist/compat.js +1 -0
  53. package/dist/compat.js.map +1 -1
  54. package/dist/image-models.generated.d.ts +34 -19
  55. package/dist/image-models.generated.d.ts.map +1 -1
  56. package/dist/image-models.generated.js +60 -45
  57. package/dist/image-models.generated.js.map +1 -1
  58. package/dist/images-models.d.ts.map +1 -1
  59. package/dist/images-models.js +4 -1
  60. package/dist/images-models.js.map +1 -1
  61. package/dist/index.d.ts +1 -0
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +1 -0
  64. package/dist/index.js.map +1 -1
  65. package/dist/legacy-api-aliases.d.ts +42 -0
  66. package/dist/legacy-api-aliases.d.ts.map +1 -0
  67. package/dist/legacy-api-aliases.js +49 -0
  68. package/dist/legacy-api-aliases.js.map +1 -0
  69. package/dist/models.d.ts.map +1 -1
  70. package/dist/models.generated.d.ts +754 -198
  71. package/dist/models.generated.d.ts.map +1 -1
  72. package/dist/models.js +4 -1
  73. package/dist/models.js.map +1 -1
  74. package/dist/providers/amazon-bedrock.models.d.ts +119 -0
  75. package/dist/providers/amazon-bedrock.models.d.ts.map +1 -1
  76. package/dist/providers/amazon-bedrock.models.js +127 -8
  77. package/dist/providers/amazon-bedrock.models.js.map +1 -1
  78. package/dist/providers/anthropic.models.d.ts +20 -34
  79. package/dist/providers/anthropic.models.d.ts.map +1 -1
  80. package/dist/providers/anthropic.models.js +18 -34
  81. package/dist/providers/anthropic.models.js.map +1 -1
  82. package/dist/providers/cloudflare-auth.d.ts.map +1 -1
  83. package/dist/providers/cloudflare-auth.js +18 -20
  84. package/dist/providers/cloudflare-auth.js.map +1 -1
  85. package/dist/providers/fireworks.models.d.ts +23 -0
  86. package/dist/providers/fireworks.models.d.ts.map +1 -1
  87. package/dist/providers/fireworks.models.js +19 -1
  88. package/dist/providers/fireworks.models.js.map +1 -1
  89. package/dist/providers/groq.models.d.ts.map +1 -1
  90. package/dist/providers/groq.models.js +1 -1
  91. package/dist/providers/groq.models.js.map +1 -1
  92. package/dist/providers/huggingface.models.d.ts +80 -0
  93. package/dist/providers/huggingface.models.d.ts.map +1 -1
  94. package/dist/providers/huggingface.models.js +72 -0
  95. package/dist/providers/huggingface.models.js.map +1 -1
  96. package/dist/providers/minimax-cn.models.d.ts.map +1 -1
  97. package/dist/providers/minimax-cn.models.js +4 -4
  98. package/dist/providers/minimax-cn.models.js.map +1 -1
  99. package/dist/providers/minimax.models.d.ts.map +1 -1
  100. package/dist/providers/minimax.models.js +4 -4
  101. package/dist/providers/minimax.models.js.map +1 -1
  102. package/dist/providers/nvidia.models.d.ts +28 -0
  103. package/dist/providers/nvidia.models.d.ts.map +1 -1
  104. package/dist/providers/nvidia.models.js +19 -0
  105. package/dist/providers/nvidia.models.js.map +1 -1
  106. package/dist/providers/opencode-go.models.d.ts.map +1 -1
  107. package/dist/providers/opencode-go.models.js +4 -4
  108. package/dist/providers/opencode-go.models.js.map +1 -1
  109. package/dist/providers/openrouter.models.d.ts +29 -32
  110. package/dist/providers/openrouter.models.d.ts.map +1 -1
  111. package/dist/providers/openrouter.models.js +100 -101
  112. package/dist/providers/openrouter.models.js.map +1 -1
  113. package/dist/providers/together.models.d.ts +31 -0
  114. package/dist/providers/together.models.d.ts.map +1 -1
  115. package/dist/providers/together.models.js +19 -0
  116. package/dist/providers/together.models.js.map +1 -1
  117. package/dist/providers/vercel-ai-gateway.models.d.ts +343 -51
  118. package/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
  119. package/dist/providers/vercel-ai-gateway.models.js +367 -77
  120. package/dist/providers/vercel-ai-gateway.models.js.map +1 -1
  121. package/dist/providers/xiaomi-token-plan-ams.models.d.ts.map +1 -1
  122. package/dist/providers/xiaomi-token-plan-ams.models.js +12 -12
  123. package/dist/providers/xiaomi-token-plan-ams.models.js.map +1 -1
  124. package/dist/providers/xiaomi-token-plan-cn.models.d.ts.map +1 -1
  125. package/dist/providers/xiaomi-token-plan-cn.models.js +12 -12
  126. package/dist/providers/xiaomi-token-plan-cn.models.js.map +1 -1
  127. package/dist/providers/xiaomi-token-plan-sgp.models.d.ts.map +1 -1
  128. package/dist/providers/xiaomi-token-plan-sgp.models.js +12 -12
  129. package/dist/providers/xiaomi-token-plan-sgp.models.js.map +1 -1
  130. package/dist/providers/xiaomi.models.d.ts.map +1 -1
  131. package/dist/providers/xiaomi.models.js +15 -15
  132. package/dist/providers/xiaomi.models.js.map +1 -1
  133. package/dist/types.d.ts +6 -0
  134. package/dist/types.d.ts.map +1 -1
  135. package/dist/types.js.map +1 -1
  136. package/dist/utils/error-body.d.ts +25 -0
  137. package/dist/utils/error-body.d.ts.map +1 -0
  138. package/dist/utils/error-body.js +109 -0
  139. package/dist/utils/error-body.js.map +1 -0
  140. package/dist/utils/estimate.d.ts +17 -0
  141. package/dist/utils/estimate.d.ts.map +1 -0
  142. package/dist/utils/estimate.js +95 -0
  143. package/dist/utils/estimate.js.map +1 -0
  144. package/dist/utils/retry.d.ts +12 -0
  145. package/dist/utils/retry.d.ts.map +1 -0
  146. package/dist/utils/retry.js +86 -0
  147. package/dist/utils/retry.js.map +1 -0
  148. package/package.json +1 -1
@@ -10,13 +10,13 @@ export interface ModelAuth {
10
10
  baseUrl?: string;
11
11
  }
12
12
  /**
13
- * Stored api-key credential. `metadata` holds non-key values such as
14
- * Cloudflare account/gateway ids.
13
+ * Stored api-key credential. `env` holds provider-scoped environment/config
14
+ * values such as Cloudflare account/gateway ids.
15
15
  */
16
16
  export interface ApiKeyCredential {
17
- type: "api-key";
17
+ type: "api_key";
18
18
  key?: string;
19
- metadata?: Record<string, string>;
19
+ env?: ProviderEnv;
20
20
  }
21
21
  /** Stored OAuth credential (`access`, `refresh`, `expires` from OAuthCredentials). */
22
22
  export interface OAuthCredential extends OAuthCredentials {
@@ -127,17 +127,17 @@ export interface AuthLoginCallbacks {
127
127
  notify(event: AuthEvent): void;
128
128
  }
129
129
  /**
130
- * Api-key auth: stored key/metadata plus ambient sources (env vars, AWS
130
+ * Api-key auth: stored key/provider env plus ambient sources (env vars, AWS
131
131
  * profiles, ADC files). Ambient-only providers omit `login`.
132
132
  */
133
133
  export interface ApiKeyAuth {
134
134
  /** Display name, e.g. "Anthropic API key". */
135
135
  name: string;
136
- /** Interactive setup (prompt for key/metadata). Absent = ambient-only. */
136
+ /** Interactive setup (prompt for key/provider env). Absent = ambient-only. */
137
137
  login?(callbacks: AuthLoginCallbacks): Promise<ApiKeyCredential>;
138
138
  /**
139
139
  * Resolve auth from the stored credential and/or ambient sources, merging
140
- * per field (`credential.key ?? env("...")`, `metadata.accountId ?? env("...")`).
140
+ * per field (`credential.key ?? env("...")`, `credential.env?.NAME ?? env("...")`).
141
141
  * undefined = not configured. Receives the chat or image-generation model
142
142
  * the request is for (both carry `provider` and `baseUrl`).
143
143
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB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CAAC;IAC5C,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IAC1B,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IAEb,0EAA0E;IAC1E,KAAK,CAAC,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEjE;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE;QACd,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QAC3C,GAAG,EAAE,WAAW,CAAC;QACjB,UAAU,CAAC,EAAE,gBAAgB,CAAC;KAC9B,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE/D;;;OAGG;IACH,OAAO,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE/D;;;;OAIG;IACH,MAAM,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CACxD;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CAClB","sourcesContent":["import type { Api, ImagesApi, ImagesModel, Model, ProviderEnv, ProviderHeaders } from \"../types.ts\";\nimport type { OAuthCredentials } from \"../utils/oauth/types.ts\";\n\n/**\n * Request auth for a single model request. If a value cannot be expressed as\n * `apiKey`, `headers`, or `baseUrl`, it is provider config, not auth.\n */\nexport interface ModelAuth {\n\tapiKey?: string;\n\theaders?: ProviderHeaders;\n\tbaseUrl?: string;\n}\n\n/**\n * Stored api-key credential. `metadata` holds non-key values such as\n * Cloudflare account/gateway ids.\n */\nexport interface ApiKeyCredential {\n\ttype: \"api-key\";\n\tkey?: string;\n\tmetadata?: Record<string, string>;\n}\n\n/** Stored OAuth credential (`access`, `refresh`, `expires` from OAuthCredentials). */\nexport interface OAuthCredential extends OAuthCredentials {\n\ttype: \"oauth\";\n}\n\n/** One type-tagged credential per provider — the shape of today's auth.json. */\nexport type Credential = ApiKeyCredential | OAuthCredential;\n\n/**\n * App-owned credential storage, keyed by `Provider.id`, one credential per\n * provider. `modify` is the only write path, so every mutation is a\n * serialized read-modify-write; `Models.getAuth()` runs OAuth refresh inside\n * `modify` so concurrent requests cannot double-refresh a rotated token. The\n * app persists a credential after login via\n * `modify(provider.id, async () => credential)`. Login/logout orchestration\n * is app-owned.\n *\n * Error semantics: `read` resolves `undefined` for missing entries. Methods\n * reject only on storage failure; `Models` wraps such rejections in\n * `ModelsError` with code \"auth\". Best-effort stores that serve an in-memory\n * view and record persistence errors internally (like coding-agent's\n * AuthStorage) are valid implementations.\n */\nexport interface CredentialStore {\n\t/**\n\t * Read the stored credential, possibly expired. Display/status use;\n\t * resolved request auth comes from `Models.getAuth()`.\n\t */\n\tread(providerId: string): Promise<Credential | undefined>;\n\n\t/**\n\t * Serialized write — the only write path. `fn` sees the current credential\n\t * because correct writes (refresh, login-during-refresh) depend on it;\n\t * return the new credential, or undefined to leave the entry unchanged.\n\t * Mutual exclusion per provider id, cross-process too where the backing\n\t * store supports it (e.g. a file lock). Resolves with the post-write\n\t * credential. Rejections from `fn` propagate.\n\t */\n\tmodify(\n\t\tproviderId: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t): Promise<Credential | undefined>;\n\n\t/** Remove a credential (logout). Implementations serialize this against `modify`. */\n\tdelete(providerId: string): Promise<void>;\n}\n\n/** Environment access for auth resolution. Injectable for tests and browsers. */\nexport interface AuthContext {\n\tenv(name: string): Promise<string | undefined>;\n\t/** Check whether a file exists. Supports a leading `~`. Always false in browsers. */\n\tfileExists(path: string): Promise<boolean>;\n}\n\n/** Result of resolving auth for a model. */\nexport interface AuthResult {\n\tauth: ModelAuth;\n\t/** Provider-scoped environment/config values resolved from credentials and ambient context. */\n\tenv?: ProviderEnv;\n\t/** Human-readable label for status UI: \"ANTHROPIC_API_KEY\", \"OAuth\", \"~/.aws/credentials\". */\n\tsource?: string;\n}\n\n/**\n * Prompt shown to the user during login. `signal` lets the flow cancel a\n * pending prompt when an out-of-band event resolves the step, e.g. a\n * `manual_code` prompt raced against a callback server, aborted when the\n * callback wins.\n */\nexport type AuthPrompt = { signal?: AbortSignal } & (\n\t| { type: \"text\"; message: string; placeholder?: string }\n\t| { type: \"secret\"; message: string; placeholder?: string }\n\t| { type: \"select\"; message: string; options: readonly { id: string; label: string; description?: string }[] }\n\t| { type: \"manual_code\"; message: string; placeholder?: string }\n);\n\nexport type AuthEvent =\n\t| { type: \"auth_url\"; url: string; instructions?: string }\n\t| {\n\t\t\ttype: \"device_code\";\n\t\t\tuserCode: string;\n\t\t\tverificationUri: string;\n\t\t\tintervalSeconds?: number;\n\t\t\texpiresInSeconds?: number;\n\t }\n\t| { type: \"progress\"; message: string };\n\n/**\n * Login interaction callbacks serving both api-key and OAuth flows.\n *\n * `prompt()` returns the entered/selected string (`select` returns the option\n * id). Rejects on cancel/abort. `signal` aborts the whole login flow;\n * per-prompt cancellation uses `AuthPrompt.signal`.\n */\nexport interface AuthLoginCallbacks {\n\tsignal?: AbortSignal;\n\n\tprompt(prompt: AuthPrompt): Promise<string>;\n\tnotify(event: AuthEvent): void;\n}\n\n/**\n * Api-key auth: stored key/metadata plus ambient sources (env vars, AWS\n * profiles, ADC files). Ambient-only providers omit `login`.\n */\nexport interface ApiKeyAuth {\n\t/** Display name, e.g. \"Anthropic API key\". */\n\tname: string;\n\n\t/** Interactive setup (prompt for key/metadata). Absent = ambient-only. */\n\tlogin?(callbacks: AuthLoginCallbacks): Promise<ApiKeyCredential>;\n\n\t/**\n\t * Resolve auth from the stored credential and/or ambient sources, merging\n\t * per field (`credential.key ?? env(\"...\")`, `metadata.accountId ?? env(\"...\")`).\n\t * undefined = not configured. Receives the chat or image-generation model\n\t * the request is for (both carry `provider` and `baseUrl`).\n\t */\n\tresolve(input: {\n\t\tmodel: Model<Api> | ImagesModel<ImagesApi>;\n\t\tctx: AuthContext;\n\t\tcredential?: ApiKeyCredential;\n\t}): Promise<AuthResult | undefined>;\n}\n\n/**\n * OAuth auth. The `refresh`/`toAuth` split lets `Models` own the locked\n * refresh pattern: `refresh` produces a credential, `toAuth` derives request\n * auth from whatever credential ends up stored.\n */\nexport interface OAuthAuth {\n\t/** Display name, e.g. \"Anthropic (Claude Pro/Max)\". */\n\tname: string;\n\n\tlogin(callbacks: AuthLoginCallbacks): Promise<OAuthCredential>;\n\n\t/**\n\t * Exchange the refresh token. Network call; throws on failure\n\t * (invalid_grant etc.). `Models` runs this under the store lock.\n\t */\n\trefresh(credential: OAuthCredential): Promise<OAuthCredential>;\n\n\t/**\n\t * Side-effect-free derivation of request auth from a valid credential.\n\t * Covers per-credential baseUrl (GitHub Copilot). Async so lazy wrappers\n\t * can load the implementation on first use.\n\t */\n\ttoAuth(credential: OAuthCredential): Promise<ModelAuth>;\n}\n\n/**\n * Provider auth. At least one of `apiKey`/`oauth` must be present: even\n * ambient-credential providers and keyless local servers provide `apiKey`\n * auth whose `resolve()` reports whether the provider is configured.\n */\nexport interface ProviderAuth {\n\tapiKey?: ApiKeyAuth;\n\toauth?: OAuthAuth;\n}\n"]}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB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EAAE,SAAS,GAAG,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IAC1B,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IAEb,8EAA8E;IAC9E,KAAK,CAAC,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEjE;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE;QACd,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QAC3C,GAAG,EAAE,WAAW,CAAC;QACjB,UAAU,CAAC,EAAE,gBAAgB,CAAC;KAC9B,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE/D;;;OAGG;IACH,OAAO,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE/D;;;;OAIG;IACH,MAAM,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CACxD;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CAClB","sourcesContent":["import type { Api, ImagesApi, ImagesModel, Model, ProviderEnv, ProviderHeaders } from \"../types.ts\";\nimport type { OAuthCredentials } from \"../utils/oauth/types.ts\";\n\n/**\n * Request auth for a single model request. If a value cannot be expressed as\n * `apiKey`, `headers`, or `baseUrl`, it is provider config, not auth.\n */\nexport interface ModelAuth {\n\tapiKey?: string;\n\theaders?: ProviderHeaders;\n\tbaseUrl?: string;\n}\n\n/**\n * Stored api-key credential. `env` holds provider-scoped environment/config\n * values such as Cloudflare account/gateway ids.\n */\nexport interface ApiKeyCredential {\n\ttype: \"api_key\";\n\tkey?: string;\n\tenv?: ProviderEnv;\n}\n\n/** Stored OAuth credential (`access`, `refresh`, `expires` from OAuthCredentials). */\nexport interface OAuthCredential extends OAuthCredentials {\n\ttype: \"oauth\";\n}\n\n/** One type-tagged credential per provider — the shape of today's auth.json. */\nexport type Credential = ApiKeyCredential | OAuthCredential;\n\n/**\n * App-owned credential storage, keyed by `Provider.id`, one credential per\n * provider. `modify` is the only write path, so every mutation is a\n * serialized read-modify-write; `Models.getAuth()` runs OAuth refresh inside\n * `modify` so concurrent requests cannot double-refresh a rotated token. The\n * app persists a credential after login via\n * `modify(provider.id, async () => credential)`. Login/logout orchestration\n * is app-owned.\n *\n * Error semantics: `read` resolves `undefined` for missing entries. Methods\n * reject only on storage failure; `Models` wraps such rejections in\n * `ModelsError` with code \"auth\". Best-effort stores that serve an in-memory\n * view and record persistence errors internally (like coding-agent's\n * AuthStorage) are valid implementations.\n */\nexport interface CredentialStore {\n\t/**\n\t * Read the stored credential, possibly expired. Display/status use;\n\t * resolved request auth comes from `Models.getAuth()`.\n\t */\n\tread(providerId: string): Promise<Credential | undefined>;\n\n\t/**\n\t * Serialized write — the only write path. `fn` sees the current credential\n\t * because correct writes (refresh, login-during-refresh) depend on it;\n\t * return the new credential, or undefined to leave the entry unchanged.\n\t * Mutual exclusion per provider id, cross-process too where the backing\n\t * store supports it (e.g. a file lock). Resolves with the post-write\n\t * credential. Rejections from `fn` propagate.\n\t */\n\tmodify(\n\t\tproviderId: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t): Promise<Credential | undefined>;\n\n\t/** Remove a credential (logout). Implementations serialize this against `modify`. */\n\tdelete(providerId: string): Promise<void>;\n}\n\n/** Environment access for auth resolution. Injectable for tests and browsers. */\nexport interface AuthContext {\n\tenv(name: string): Promise<string | undefined>;\n\t/** Check whether a file exists. Supports a leading `~`. Always false in browsers. */\n\tfileExists(path: string): Promise<boolean>;\n}\n\n/** Result of resolving auth for a model. */\nexport interface AuthResult {\n\tauth: ModelAuth;\n\t/** Provider-scoped environment/config values resolved from credentials and ambient context. */\n\tenv?: ProviderEnv;\n\t/** Human-readable label for status UI: \"ANTHROPIC_API_KEY\", \"OAuth\", \"~/.aws/credentials\". */\n\tsource?: string;\n}\n\n/**\n * Prompt shown to the user during login. `signal` lets the flow cancel a\n * pending prompt when an out-of-band event resolves the step, e.g. a\n * `manual_code` prompt raced against a callback server, aborted when the\n * callback wins.\n */\nexport type AuthPrompt = { signal?: AbortSignal } & (\n\t| { type: \"text\"; message: string; placeholder?: string }\n\t| { type: \"secret\"; message: string; placeholder?: string }\n\t| { type: \"select\"; message: string; options: readonly { id: string; label: string; description?: string }[] }\n\t| { type: \"manual_code\"; message: string; placeholder?: string }\n);\n\nexport type AuthEvent =\n\t| { type: \"auth_url\"; url: string; instructions?: string }\n\t| {\n\t\t\ttype: \"device_code\";\n\t\t\tuserCode: string;\n\t\t\tverificationUri: string;\n\t\t\tintervalSeconds?: number;\n\t\t\texpiresInSeconds?: number;\n\t }\n\t| { type: \"progress\"; message: string };\n\n/**\n * Login interaction callbacks serving both api-key and OAuth flows.\n *\n * `prompt()` returns the entered/selected string (`select` returns the option\n * id). Rejects on cancel/abort. `signal` aborts the whole login flow;\n * per-prompt cancellation uses `AuthPrompt.signal`.\n */\nexport interface AuthLoginCallbacks {\n\tsignal?: AbortSignal;\n\n\tprompt(prompt: AuthPrompt): Promise<string>;\n\tnotify(event: AuthEvent): void;\n}\n\n/**\n * Api-key auth: stored key/provider env plus ambient sources (env vars, AWS\n * profiles, ADC files). Ambient-only providers omit `login`.\n */\nexport interface ApiKeyAuth {\n\t/** Display name, e.g. \"Anthropic API key\". */\n\tname: string;\n\n\t/** Interactive setup (prompt for key/provider env). Absent = ambient-only. */\n\tlogin?(callbacks: AuthLoginCallbacks): Promise<ApiKeyCredential>;\n\n\t/**\n\t * Resolve auth from the stored credential and/or ambient sources, merging\n\t * per field (`credential.key ?? env(\"...\")`, `credential.env?.NAME ?? env(\"...\")`).\n\t * undefined = not configured. Receives the chat or image-generation model\n\t * the request is for (both carry `provider` and `baseUrl`).\n\t */\n\tresolve(input: {\n\t\tmodel: Model<Api> | ImagesModel<ImagesApi>;\n\t\tctx: AuthContext;\n\t\tcredential?: ApiKeyCredential;\n\t}): Promise<AuthResult | undefined>;\n}\n\n/**\n * OAuth auth. The `refresh`/`toAuth` split lets `Models` own the locked\n * refresh pattern: `refresh` produces a credential, `toAuth` derives request\n * auth from whatever credential ends up stored.\n */\nexport interface OAuthAuth {\n\t/** Display name, e.g. \"Anthropic (Claude Pro/Max)\". */\n\tname: string;\n\n\tlogin(callbacks: AuthLoginCallbacks): Promise<OAuthCredential>;\n\n\t/**\n\t * Exchange the refresh token. Network call; throws on failure\n\t * (invalid_grant etc.). `Models` runs this under the store lock.\n\t */\n\trefresh(credential: OAuthCredential): Promise<OAuthCredential>;\n\n\t/**\n\t * Side-effect-free derivation of request auth from a valid credential.\n\t * Covers per-credential baseUrl (GitHub Copilot). Async so lazy wrappers\n\t * can load the implementation on first use.\n\t */\n\ttoAuth(credential: OAuthCredential): Promise<ModelAuth>;\n}\n\n/**\n * Provider auth. At least one of `apiKey`/`oauth` must be present: even\n * ambient-credential providers and keyless local servers provide `apiKey`\n * auth whose `resolve()` reports whether the provider is configured.\n */\nexport interface ProviderAuth {\n\tapiKey?: ApiKeyAuth;\n\toauth?: OAuthAuth;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Api, ImagesApi, ImagesModel, Model, ProviderEnv, ProviderHeaders } from \"../types.ts\";\nimport type { OAuthCredentials } from \"../utils/oauth/types.ts\";\n\n/**\n * Request auth for a single model request. If a value cannot be expressed as\n * `apiKey`, `headers`, or `baseUrl`, it is provider config, not auth.\n */\nexport interface ModelAuth {\n\tapiKey?: string;\n\theaders?: ProviderHeaders;\n\tbaseUrl?: string;\n}\n\n/**\n * Stored api-key credential. `metadata` holds non-key values such as\n * Cloudflare account/gateway ids.\n */\nexport interface ApiKeyCredential {\n\ttype: \"api-key\";\n\tkey?: string;\n\tmetadata?: Record<string, string>;\n}\n\n/** Stored OAuth credential (`access`, `refresh`, `expires` from OAuthCredentials). */\nexport interface OAuthCredential extends OAuthCredentials {\n\ttype: \"oauth\";\n}\n\n/** One type-tagged credential per provider — the shape of today's auth.json. */\nexport type Credential = ApiKeyCredential | OAuthCredential;\n\n/**\n * App-owned credential storage, keyed by `Provider.id`, one credential per\n * provider. `modify` is the only write path, so every mutation is a\n * serialized read-modify-write; `Models.getAuth()` runs OAuth refresh inside\n * `modify` so concurrent requests cannot double-refresh a rotated token. The\n * app persists a credential after login via\n * `modify(provider.id, async () => credential)`. Login/logout orchestration\n * is app-owned.\n *\n * Error semantics: `read` resolves `undefined` for missing entries. Methods\n * reject only on storage failure; `Models` wraps such rejections in\n * `ModelsError` with code \"auth\". Best-effort stores that serve an in-memory\n * view and record persistence errors internally (like coding-agent's\n * AuthStorage) are valid implementations.\n */\nexport interface CredentialStore {\n\t/**\n\t * Read the stored credential, possibly expired. Display/status use;\n\t * resolved request auth comes from `Models.getAuth()`.\n\t */\n\tread(providerId: string): Promise<Credential | undefined>;\n\n\t/**\n\t * Serialized write — the only write path. `fn` sees the current credential\n\t * because correct writes (refresh, login-during-refresh) depend on it;\n\t * return the new credential, or undefined to leave the entry unchanged.\n\t * Mutual exclusion per provider id, cross-process too where the backing\n\t * store supports it (e.g. a file lock). Resolves with the post-write\n\t * credential. Rejections from `fn` propagate.\n\t */\n\tmodify(\n\t\tproviderId: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t): Promise<Credential | undefined>;\n\n\t/** Remove a credential (logout). Implementations serialize this against `modify`. */\n\tdelete(providerId: string): Promise<void>;\n}\n\n/** Environment access for auth resolution. Injectable for tests and browsers. */\nexport interface AuthContext {\n\tenv(name: string): Promise<string | undefined>;\n\t/** Check whether a file exists. Supports a leading `~`. Always false in browsers. */\n\tfileExists(path: string): Promise<boolean>;\n}\n\n/** Result of resolving auth for a model. */\nexport interface AuthResult {\n\tauth: ModelAuth;\n\t/** Provider-scoped environment/config values resolved from credentials and ambient context. */\n\tenv?: ProviderEnv;\n\t/** Human-readable label for status UI: \"ANTHROPIC_API_KEY\", \"OAuth\", \"~/.aws/credentials\". */\n\tsource?: string;\n}\n\n/**\n * Prompt shown to the user during login. `signal` lets the flow cancel a\n * pending prompt when an out-of-band event resolves the step, e.g. a\n * `manual_code` prompt raced against a callback server, aborted when the\n * callback wins.\n */\nexport type AuthPrompt = { signal?: AbortSignal } & (\n\t| { type: \"text\"; message: string; placeholder?: string }\n\t| { type: \"secret\"; message: string; placeholder?: string }\n\t| { type: \"select\"; message: string; options: readonly { id: string; label: string; description?: string }[] }\n\t| { type: \"manual_code\"; message: string; placeholder?: string }\n);\n\nexport type AuthEvent =\n\t| { type: \"auth_url\"; url: string; instructions?: string }\n\t| {\n\t\t\ttype: \"device_code\";\n\t\t\tuserCode: string;\n\t\t\tverificationUri: string;\n\t\t\tintervalSeconds?: number;\n\t\t\texpiresInSeconds?: number;\n\t }\n\t| { type: \"progress\"; message: string };\n\n/**\n * Login interaction callbacks serving both api-key and OAuth flows.\n *\n * `prompt()` returns the entered/selected string (`select` returns the option\n * id). Rejects on cancel/abort. `signal` aborts the whole login flow;\n * per-prompt cancellation uses `AuthPrompt.signal`.\n */\nexport interface AuthLoginCallbacks {\n\tsignal?: AbortSignal;\n\n\tprompt(prompt: AuthPrompt): Promise<string>;\n\tnotify(event: AuthEvent): void;\n}\n\n/**\n * Api-key auth: stored key/metadata plus ambient sources (env vars, AWS\n * profiles, ADC files). Ambient-only providers omit `login`.\n */\nexport interface ApiKeyAuth {\n\t/** Display name, e.g. \"Anthropic API key\". */\n\tname: string;\n\n\t/** Interactive setup (prompt for key/metadata). Absent = ambient-only. */\n\tlogin?(callbacks: AuthLoginCallbacks): Promise<ApiKeyCredential>;\n\n\t/**\n\t * Resolve auth from the stored credential and/or ambient sources, merging\n\t * per field (`credential.key ?? env(\"...\")`, `metadata.accountId ?? env(\"...\")`).\n\t * undefined = not configured. Receives the chat or image-generation model\n\t * the request is for (both carry `provider` and `baseUrl`).\n\t */\n\tresolve(input: {\n\t\tmodel: Model<Api> | ImagesModel<ImagesApi>;\n\t\tctx: AuthContext;\n\t\tcredential?: ApiKeyCredential;\n\t}): Promise<AuthResult | undefined>;\n}\n\n/**\n * OAuth auth. The `refresh`/`toAuth` split lets `Models` own the locked\n * refresh pattern: `refresh` produces a credential, `toAuth` derives request\n * auth from whatever credential ends up stored.\n */\nexport interface OAuthAuth {\n\t/** Display name, e.g. \"Anthropic (Claude Pro/Max)\". */\n\tname: string;\n\n\tlogin(callbacks: AuthLoginCallbacks): Promise<OAuthCredential>;\n\n\t/**\n\t * Exchange the refresh token. Network call; throws on failure\n\t * (invalid_grant etc.). `Models` runs this under the store lock.\n\t */\n\trefresh(credential: OAuthCredential): Promise<OAuthCredential>;\n\n\t/**\n\t * Side-effect-free derivation of request auth from a valid credential.\n\t * Covers per-credential baseUrl (GitHub Copilot). Async so lazy wrappers\n\t * can load the implementation on first use.\n\t */\n\ttoAuth(credential: OAuthCredential): Promise<ModelAuth>;\n}\n\n/**\n * Provider auth. At least one of `apiKey`/`oauth` must be present: even\n * ambient-credential providers and keyless local servers provide `apiKey`\n * auth whose `resolve()` reports whether the provider is configured.\n */\nexport interface ProviderAuth {\n\tapiKey?: ApiKeyAuth;\n\toauth?: OAuthAuth;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Api, ImagesApi, ImagesModel, Model, ProviderEnv, ProviderHeaders } from \"../types.ts\";\nimport type { OAuthCredentials } from \"../utils/oauth/types.ts\";\n\n/**\n * Request auth for a single model request. If a value cannot be expressed as\n * `apiKey`, `headers`, or `baseUrl`, it is provider config, not auth.\n */\nexport interface ModelAuth {\n\tapiKey?: string;\n\theaders?: ProviderHeaders;\n\tbaseUrl?: string;\n}\n\n/**\n * Stored api-key credential. `env` holds provider-scoped environment/config\n * values such as Cloudflare account/gateway ids.\n */\nexport interface ApiKeyCredential {\n\ttype: \"api_key\";\n\tkey?: string;\n\tenv?: ProviderEnv;\n}\n\n/** Stored OAuth credential (`access`, `refresh`, `expires` from OAuthCredentials). */\nexport interface OAuthCredential extends OAuthCredentials {\n\ttype: \"oauth\";\n}\n\n/** One type-tagged credential per provider — the shape of today's auth.json. */\nexport type Credential = ApiKeyCredential | OAuthCredential;\n\n/**\n * App-owned credential storage, keyed by `Provider.id`, one credential per\n * provider. `modify` is the only write path, so every mutation is a\n * serialized read-modify-write; `Models.getAuth()` runs OAuth refresh inside\n * `modify` so concurrent requests cannot double-refresh a rotated token. The\n * app persists a credential after login via\n * `modify(provider.id, async () => credential)`. Login/logout orchestration\n * is app-owned.\n *\n * Error semantics: `read` resolves `undefined` for missing entries. Methods\n * reject only on storage failure; `Models` wraps such rejections in\n * `ModelsError` with code \"auth\". Best-effort stores that serve an in-memory\n * view and record persistence errors internally (like coding-agent's\n * AuthStorage) are valid implementations.\n */\nexport interface CredentialStore {\n\t/**\n\t * Read the stored credential, possibly expired. Display/status use;\n\t * resolved request auth comes from `Models.getAuth()`.\n\t */\n\tread(providerId: string): Promise<Credential | undefined>;\n\n\t/**\n\t * Serialized write — the only write path. `fn` sees the current credential\n\t * because correct writes (refresh, login-during-refresh) depend on it;\n\t * return the new credential, or undefined to leave the entry unchanged.\n\t * Mutual exclusion per provider id, cross-process too where the backing\n\t * store supports it (e.g. a file lock). Resolves with the post-write\n\t * credential. Rejections from `fn` propagate.\n\t */\n\tmodify(\n\t\tproviderId: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t): Promise<Credential | undefined>;\n\n\t/** Remove a credential (logout). Implementations serialize this against `modify`. */\n\tdelete(providerId: string): Promise<void>;\n}\n\n/** Environment access for auth resolution. Injectable for tests and browsers. */\nexport interface AuthContext {\n\tenv(name: string): Promise<string | undefined>;\n\t/** Check whether a file exists. Supports a leading `~`. Always false in browsers. */\n\tfileExists(path: string): Promise<boolean>;\n}\n\n/** Result of resolving auth for a model. */\nexport interface AuthResult {\n\tauth: ModelAuth;\n\t/** Provider-scoped environment/config values resolved from credentials and ambient context. */\n\tenv?: ProviderEnv;\n\t/** Human-readable label for status UI: \"ANTHROPIC_API_KEY\", \"OAuth\", \"~/.aws/credentials\". */\n\tsource?: string;\n}\n\n/**\n * Prompt shown to the user during login. `signal` lets the flow cancel a\n * pending prompt when an out-of-band event resolves the step, e.g. a\n * `manual_code` prompt raced against a callback server, aborted when the\n * callback wins.\n */\nexport type AuthPrompt = { signal?: AbortSignal } & (\n\t| { type: \"text\"; message: string; placeholder?: string }\n\t| { type: \"secret\"; message: string; placeholder?: string }\n\t| { type: \"select\"; message: string; options: readonly { id: string; label: string; description?: string }[] }\n\t| { type: \"manual_code\"; message: string; placeholder?: string }\n);\n\nexport type AuthEvent =\n\t| { type: \"auth_url\"; url: string; instructions?: string }\n\t| {\n\t\t\ttype: \"device_code\";\n\t\t\tuserCode: string;\n\t\t\tverificationUri: string;\n\t\t\tintervalSeconds?: number;\n\t\t\texpiresInSeconds?: number;\n\t }\n\t| { type: \"progress\"; message: string };\n\n/**\n * Login interaction callbacks serving both api-key and OAuth flows.\n *\n * `prompt()` returns the entered/selected string (`select` returns the option\n * id). Rejects on cancel/abort. `signal` aborts the whole login flow;\n * per-prompt cancellation uses `AuthPrompt.signal`.\n */\nexport interface AuthLoginCallbacks {\n\tsignal?: AbortSignal;\n\n\tprompt(prompt: AuthPrompt): Promise<string>;\n\tnotify(event: AuthEvent): void;\n}\n\n/**\n * Api-key auth: stored key/provider env plus ambient sources (env vars, AWS\n * profiles, ADC files). Ambient-only providers omit `login`.\n */\nexport interface ApiKeyAuth {\n\t/** Display name, e.g. \"Anthropic API key\". */\n\tname: string;\n\n\t/** Interactive setup (prompt for key/provider env). Absent = ambient-only. */\n\tlogin?(callbacks: AuthLoginCallbacks): Promise<ApiKeyCredential>;\n\n\t/**\n\t * Resolve auth from the stored credential and/or ambient sources, merging\n\t * per field (`credential.key ?? env(\"...\")`, `credential.env?.NAME ?? env(\"...\")`).\n\t * undefined = not configured. Receives the chat or image-generation model\n\t * the request is for (both carry `provider` and `baseUrl`).\n\t */\n\tresolve(input: {\n\t\tmodel: Model<Api> | ImagesModel<ImagesApi>;\n\t\tctx: AuthContext;\n\t\tcredential?: ApiKeyCredential;\n\t}): Promise<AuthResult | undefined>;\n}\n\n/**\n * OAuth auth. The `refresh`/`toAuth` split lets `Models` own the locked\n * refresh pattern: `refresh` produces a credential, `toAuth` derives request\n * auth from whatever credential ends up stored.\n */\nexport interface OAuthAuth {\n\t/** Display name, e.g. \"Anthropic (Claude Pro/Max)\". */\n\tname: string;\n\n\tlogin(callbacks: AuthLoginCallbacks): Promise<OAuthCredential>;\n\n\t/**\n\t * Exchange the refresh token. Network call; throws on failure\n\t * (invalid_grant etc.). `Models` runs this under the store lock.\n\t */\n\trefresh(credential: OAuthCredential): Promise<OAuthCredential>;\n\n\t/**\n\t * Side-effect-free derivation of request auth from a valid credential.\n\t * Covers per-credential baseUrl (GitHub Copilot). Async so lazy wrappers\n\t * can load the implementation on first use.\n\t */\n\ttoAuth(credential: OAuthCredential): Promise<ModelAuth>;\n}\n\n/**\n * Provider auth. At least one of `apiKey`/`oauth` must be present: even\n * ambient-credential providers and keyless local servers provide `apiKey`\n * auth whose `resolve()` reports whether the provider is configured.\n */\nexport interface ProviderAuth {\n\tapiKey?: ApiKeyAuth;\n\toauth?: OAuthAuth;\n}\n"]}
package/dist/compat.d.ts CHANGED
@@ -23,6 +23,7 @@ export * from "./image-models.ts";
23
23
  export * from "./images.ts";
24
24
  export * from "./images-api-registry.ts";
25
25
  export * from "./index.ts";
26
+ export * from "./legacy-api-aliases.ts";
26
27
  export * from "./providers/images/register-builtins.ts";
27
28
  import { getBuiltinModel, getBuiltinModels, getBuiltinProviders } from "./providers/all.ts";
28
29
  import { type FauxProviderRegistration, type RegisterFauxProviderOptions } from "./providers/faux.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../src/compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,yCAAyC,CAAC;AAYxD,OAAO,EAAiB,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC3G,OAAO,EAAkB,KAAK,wBAAwB,EAAE,KAAK,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AACtH,OAAO,KAAK,EACX,GAAG,EAEH,gBAAgB,EAChB,2BAA2B,EAC3B,OAAO,EACP,KAAK,EACL,qBAAqB,EAErB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,MAAM,YAAY,CAAC;AAEpB,gIAAgI;AAChI,eAAO,MAAM,QAAQ,wBAAkB,CAAC;AAExC,kIAAkI;AAClI,eAAO,MAAM,SAAS,yBAAmB,CAAC;AAE1C,wIAAwI;AACxI,eAAO,MAAM,YAAY,4BAAsB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG,CAC/B,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,aAAa,KACnB,2BAA2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A2B,CAM7B;AAED,wBAAsB,QAAQ,CAAC,IAAI,SAAS,GAAG,EAC9C,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,qBAAqB,GAC7B,OAAO,CAAC,gBAAgB,CAAC,CAG3B;AAED,wBAAgB,YAAY,CAAC,IAAI,SAAS,GAAG,EAC5C,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,mBAAmB,GAC3B,2BAA2B,CAM7B;AAED,wBAAsB,cAAc,CAAC,IAAI,SAAS,GAAG,EACpD,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CAG3B","sourcesContent":["/**\n * Temporary compatibility entrypoint preserving the old global pi-ai API\n * surface: api-dispatch `stream()`/`complete()` with env API key injection,\n * the api-registry, generated catalog reads (`getModel`/`getModels`/\n * `getProviders`), per-API lazy stream wrappers, and image generation.\n *\n * Existing apps switch imports from \"@earendil-works/pi-ai\" to\n * \"@earendil-works/pi-ai/compat\" unchanged; new code uses `createModels()`\n * and the provider factories. This module is deleted with the coding-agent\n * ModelManager migration.\n */\n\nexport * from \"./api/anthropic-messages.lazy.ts\";\nexport * from \"./api/azure-openai-responses.lazy.ts\";\nexport * from \"./api/bedrock-converse-stream.lazy.ts\";\nexport * from \"./api/google-generative-ai.lazy.ts\";\nexport * from \"./api/google-vertex.lazy.ts\";\nexport * from \"./api/mistral-conversations.lazy.ts\";\nexport * from \"./api/openai-codex-responses.lazy.ts\";\nexport * from \"./api/openai-completions.lazy.ts\";\nexport * from \"./api/openai-responses.lazy.ts\";\nexport * from \"./env-api-keys.ts\";\nexport * from \"./image-models.ts\";\nexport * from \"./images.ts\";\nexport * from \"./images-api-registry.ts\";\nexport * from \"./index.ts\";\nexport * from \"./providers/images/register-builtins.ts\";\n\nimport { anthropicMessagesApi } from \"./api/anthropic-messages.lazy.ts\";\nimport { azureOpenAIResponsesApi } from \"./api/azure-openai-responses.lazy.ts\";\nimport { bedrockConverseStreamApi } from \"./api/bedrock-converse-stream.lazy.ts\";\nimport { googleGenerativeAIApi } from \"./api/google-generative-ai.lazy.ts\";\nimport { googleVertexApi } from \"./api/google-vertex.lazy.ts\";\nimport { mistralConversationsApi } from \"./api/mistral-conversations.lazy.ts\";\nimport { openAICodexResponsesApi } from \"./api/openai-codex-responses.lazy.ts\";\nimport { openAICompletionsApi } from \"./api/openai-completions.lazy.ts\";\nimport { openAIResponsesApi } from \"./api/openai-responses.lazy.ts\";\nimport { getEnvApiKey } from \"./env-api-keys.ts\";\nimport { builtinModels, getBuiltinModel, getBuiltinModels, getBuiltinProviders } from \"./providers/all.ts\";\nimport { createFauxCore, type FauxProviderRegistration, type RegisterFauxProviderOptions } from \"./providers/faux.ts\";\nimport type {\n\tApi,\n\tApiStreamOptions,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tContext,\n\tModel,\n\tProviderStreamOptions,\n\tProviderStreams,\n\tSimpleStreamOptions,\n\tStreamFunction,\n\tStreamOptions,\n} from \"./types.ts\";\n\n/** @deprecated Static catalog read. Use `getBuiltinModel` from \"@earendil-works/pi-ai/providers/all\" or `Models.getModel()`. */\nexport const getModel = getBuiltinModel;\n\n/** @deprecated Static catalog read. Use `getBuiltinModels` from \"@earendil-works/pi-ai/providers/all\" or `Models.getModels()`. */\nexport const getModels = getBuiltinModels;\n\n/** @deprecated Static catalog read. Use `getBuiltinProviders` from \"@earendil-works/pi-ai/providers/all\" or `Models.getProviders()`. */\nexport const getProviders = getBuiltinProviders;\n\nexport type ApiStreamFunction = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: StreamOptions,\n) => AssistantMessageEventStream;\n\nexport type ApiStreamSimpleFunction = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n) => AssistantMessageEventStream;\n\nexport interface ApiProvider<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> {\n\tapi: TApi;\n\tstream: StreamFunction<TApi, TOptions>;\n\tstreamSimple: StreamFunction<TApi, SimpleStreamOptions>;\n}\n\ninterface ApiProviderInternal {\n\tapi: Api;\n\tstream: ApiStreamFunction;\n\tstreamSimple: ApiStreamSimpleFunction;\n}\n\ntype RegisteredApiProvider = {\n\tprovider: ApiProviderInternal;\n\tsourceId?: string;\n};\n\nconst apiProviderRegistry = new Map<string, RegisteredApiProvider>();\n\nfunction wrapStream<TApi extends Api, TOptions extends StreamOptions>(\n\tapi: TApi,\n\tstream: StreamFunction<TApi, TOptions>,\n): ApiStreamFunction {\n\treturn (model, context, options) => {\n\t\tif (model.api !== api) {\n\t\t\tthrow new Error(`Mismatched api: ${model.api} expected ${api}`);\n\t\t}\n\t\treturn stream(model as Model<TApi>, context, options as TOptions);\n\t};\n}\n\nfunction wrapStreamSimple<TApi extends Api>(\n\tapi: TApi,\n\tstreamSimple: StreamFunction<TApi, SimpleStreamOptions>,\n): ApiStreamSimpleFunction {\n\treturn (model, context, options) => {\n\t\tif (model.api !== api) {\n\t\t\tthrow new Error(`Mismatched api: ${model.api} expected ${api}`);\n\t\t}\n\t\treturn streamSimple(model as Model<TApi>, context, options);\n\t};\n}\n\nexport function registerApiProvider<TApi extends Api, TOptions extends StreamOptions>(\n\tprovider: ApiProvider<TApi, TOptions>,\n\tsourceId?: string,\n): void {\n\tapiProviderRegistry.set(provider.api, {\n\t\tprovider: {\n\t\t\tapi: provider.api,\n\t\t\tstream: wrapStream(provider.api, provider.stream),\n\t\t\tstreamSimple: wrapStreamSimple(provider.api, provider.streamSimple),\n\t\t},\n\t\tsourceId,\n\t});\n}\n\nexport function getApiProvider(api: Api): ApiProviderInternal | undefined {\n\treturn apiProviderRegistry.get(api)?.provider;\n}\n\nexport function getApiProviders(): ApiProviderInternal[] {\n\treturn Array.from(apiProviderRegistry.values(), (entry) => entry.provider);\n}\n\nexport function unregisterApiProviders(sourceId: string): void {\n\tfor (const [api, entry] of apiProviderRegistry.entries()) {\n\t\tif (entry.sourceId === sourceId) {\n\t\t\tapiProviderRegistry.delete(api);\n\t\t}\n\t}\n}\n\nfunction clearApiProviders(): void {\n\tapiProviderRegistry.clear();\n}\n\nexport function registerFauxProvider(options: RegisterFauxProviderOptions = {}): FauxProviderRegistration {\n\tconst core = createFauxCore(options);\n\tconst sourceId = `faux-provider-${Math.random().toString(36).slice(2, 10)}`;\n\tregisterApiProvider({ api: core.api, stream: core.stream, streamSimple: core.streamSimple }, sourceId);\n\treturn {\n\t\tapi: core.api,\n\t\tmodels: core.models,\n\t\tgetModel: core.getModel,\n\t\tstate: core.state,\n\t\tsetResponses: core.setResponses,\n\t\tappendResponses: core.appendResponses,\n\t\tgetPendingResponseCount: core.getPendingResponseCount,\n\t\tunregister() {\n\t\t\tunregisterApiProviders(sourceId);\n\t\t},\n\t};\n}\n\nconst BUILTIN_APIS: [Api, ProviderStreams][] = [\n\t[\"anthropic-messages\", anthropicMessagesApi()],\n\t[\"openai-completions\", openAICompletionsApi()],\n\t[\"openai-responses\", openAIResponsesApi()],\n\t[\"openai-codex-responses\", openAICodexResponsesApi()],\n\t[\"azure-openai-responses\", azureOpenAIResponsesApi()],\n\t[\"google-generative-ai\", googleGenerativeAIApi()],\n\t[\"google-vertex\", googleVertexApi()],\n\t[\"mistral-conversations\", mistralConversationsApi()],\n\t[\"bedrock-converse-stream\", bedrockConverseStreamApi()],\n];\n\nconst builtinApiProviderInstances = new Map<Api, ReturnType<typeof getApiProvider>>();\n\n/**\n * Registers the builtin API implementations into the api-registry without\n * clobbering existing entries: compat may load after a test or extension has\n * already registered an override for a builtin api id.\n */\nexport function registerBuiltInApiProviders(): void {\n\tfor (const [api, streams] of BUILTIN_APIS) {\n\t\tif (!getApiProvider(api)) {\n\t\t\tregisterApiProvider({ api, stream: streams.stream, streamSimple: streams.streamSimple });\n\t\t}\n\t\tbuiltinApiProviderInstances.set(api, getApiProvider(api));\n\t}\n}\n\nexport function resetApiProviders(): void {\n\tclearApiProviders();\n\tbuiltinApiProviderInstances.clear();\n\tregisterBuiltInApiProviders();\n}\n\nregisterBuiltInApiProviders();\n\nconst compatModels = builtinModels();\n\nfunction hasExplicitApiKey(apiKey: string | undefined): apiKey is string {\n\treturn typeof apiKey === \"string\" && apiKey.trim().length > 0;\n}\n\nfunction withEnvApiKey<TOptions extends StreamOptions>(\n\tmodel: Model<Api>,\n\toptions: TOptions | undefined,\n): TOptions | undefined {\n\tif (hasExplicitApiKey(options?.apiKey)) return options;\n\tconst apiKey = getEnvApiKey(model.provider, options?.env);\n\tif (!apiKey) return options;\n\treturn { ...options, apiKey } as TOptions;\n}\n\nfunction shouldUseBuiltinModels(model: Model<Api>): boolean {\n\tconst builtin = compatModels.getModel(model.provider, model.id);\n\treturn builtin?.api === model.api && getApiProvider(model.api) === builtinApiProviderInstances.get(model.api);\n}\n\nfunction resolveApiProvider(api: Api) {\n\tconst provider = getApiProvider(api);\n\tif (!provider) {\n\t\tthrow new Error(`No API provider registered for api: ${api}`);\n\t}\n\treturn provider;\n}\n\nexport function stream<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: ProviderStreamOptions,\n): AssistantMessageEventStream {\n\tif (shouldUseBuiltinModels(model)) {\n\t\treturn compatModels.stream(model, context, options as ApiStreamOptions<TApi> | undefined);\n\t}\n\tconst provider = resolveApiProvider(model.api);\n\treturn provider.stream(model, context, withEnvApiKey(model, options) as StreamOptions);\n}\n\nexport async function complete<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: ProviderStreamOptions,\n): Promise<AssistantMessage> {\n\tconst s = stream(model, context, options);\n\treturn s.result();\n}\n\nexport function streamSimple<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n): AssistantMessageEventStream {\n\tif (shouldUseBuiltinModels(model)) {\n\t\treturn compatModels.streamSimple(model, context, options);\n\t}\n\tconst provider = resolveApiProvider(model.api);\n\treturn provider.streamSimple(model, context, withEnvApiKey(model, options));\n}\n\nexport async function completeSimple<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n): Promise<AssistantMessage> {\n\tconst s = streamSimple(model, context, options);\n\treturn s.result();\n}\n"]}
1
+ {"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../src/compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yCAAyC,CAAC;AAYxD,OAAO,EAAiB,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC3G,OAAO,EAAkB,KAAK,wBAAwB,EAAE,KAAK,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AACtH,OAAO,KAAK,EACX,GAAG,EAEH,gBAAgB,EAChB,2BAA2B,EAC3B,OAAO,EACP,KAAK,EACL,qBAAqB,EAErB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,MAAM,YAAY,CAAC;AAEpB,gIAAgI;AAChI,eAAO,MAAM,QAAQ,wBAAkB,CAAC;AAExC,kIAAkI;AAClI,eAAO,MAAM,SAAS,yBAAmB,CAAC;AAE1C,wIAAwI;AACxI,eAAO,MAAM,YA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AIxC;AAiCD,wBAAgB,MAAM,CAAC,IAAI,SAAS,GAAG,EACtC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,qBAAqB,GAC7B,2BAA2B,CAM7B;AAED,wBAAsB,QAAQ,CAAC,IAAI,SAAS,GAAG,EAC9C,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,qBAAqB,GAC7B,OAAO,CAAC,gBAAgB,CAAC,CAG3B;AAED,wBAAgB,YAAY,CAAC,IAAI,SAAS,GAAG,EAC5C,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,mBAAmB,GAC3B,2BAA2B,CAM7B;AAED,wBAAsB,cAAc,CAAC,IAAI,SAAS,GAAG,EACpD,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CAG3B","sourcesContent":["/**\n * Temporary compatibility entrypoint preserving the old global pi-ai API\n * surface: api-dispatch `stream()`/`complete()` with env API key injection,\n * the api-registry, generated catalog reads (`getModel`/`getModels`/\n * `getProviders`), per-API lazy stream wrappers, and image generation.\n *\n * Existing apps switch imports from \"@earendil-works/pi-ai\" to\n * \"@earendil-works/pi-ai/compat\" unchanged; new code uses `createModels()`\n * and the provider factories. This module is deleted with the coding-agent\n * ModelManager migration.\n */\n\nexport * from \"./api/anthropic-messages.lazy.ts\";\nexport * from \"./api/azure-openai-responses.lazy.ts\";\nexport * from \"./api/bedrock-converse-stream.lazy.ts\";\nexport * from \"./api/google-generative-ai.lazy.ts\";\nexport * from \"./api/google-vertex.lazy.ts\";\nexport * from \"./api/mistral-conversations.lazy.ts\";\nexport * from \"./api/openai-codex-responses.lazy.ts\";\nexport * from \"./api/openai-completions.lazy.ts\";\nexport * from \"./api/openai-responses.lazy.ts\";\nexport * from \"./env-api-keys.ts\";\nexport * from \"./image-models.ts\";\nexport * from \"./images.ts\";\nexport * from \"./images-api-registry.ts\";\nexport * from \"./index.ts\";\nexport * from \"./legacy-api-aliases.ts\";\nexport * from \"./providers/images/register-builtins.ts\";\n\nimport { anthropicMessagesApi } from \"./api/anthropic-messages.lazy.ts\";\nimport { azureOpenAIResponsesApi } from \"./api/azure-openai-responses.lazy.ts\";\nimport { bedrockConverseStreamApi } from \"./api/bedrock-converse-stream.lazy.ts\";\nimport { googleGenerativeAIApi } from \"./api/google-generative-ai.lazy.ts\";\nimport { googleVertexApi } from \"./api/google-vertex.lazy.ts\";\nimport { mistralConversationsApi } from \"./api/mistral-conversations.lazy.ts\";\nimport { openAICodexResponsesApi } from \"./api/openai-codex-responses.lazy.ts\";\nimport { openAICompletionsApi } from \"./api/openai-completions.lazy.ts\";\nimport { openAIResponsesApi } from \"./api/openai-responses.lazy.ts\";\nimport { getEnvApiKey } from \"./env-api-keys.ts\";\nimport { builtinModels, getBuiltinModel, getBuiltinModels, getBuiltinProviders } from \"./providers/all.ts\";\nimport { createFauxCore, type FauxProviderRegistration, type RegisterFauxProviderOptions } from \"./providers/faux.ts\";\nimport type {\n\tApi,\n\tApiStreamOptions,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tContext,\n\tModel,\n\tProviderStreamOptions,\n\tProviderStreams,\n\tSimpleStreamOptions,\n\tStreamFunction,\n\tStreamOptions,\n} from \"./types.ts\";\n\n/** @deprecated Static catalog read. Use `getBuiltinModel` from \"@earendil-works/pi-ai/providers/all\" or `Models.getModel()`. */\nexport const getModel = getBuiltinModel;\n\n/** @deprecated Static catalog read. Use `getBuiltinModels` from \"@earendil-works/pi-ai/providers/all\" or `Models.getModels()`. */\nexport const getModels = getBuiltinModels;\n\n/** @deprecated Static catalog read. Use `getBuiltinProviders` from \"@earendil-works/pi-ai/providers/all\" or `Models.getProviders()`. */\nexport const getProviders = getBuiltinProviders;\n\nexport type ApiStreamFunction = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: StreamOptions,\n) => AssistantMessageEventStream;\n\nexport type ApiStreamSimpleFunction = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n) => AssistantMessageEventStream;\n\nexport interface ApiProvider<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> {\n\tapi: TApi;\n\tstream: StreamFunction<TApi, TOptions>;\n\tstreamSimple: StreamFunction<TApi, SimpleStreamOptions>;\n}\n\ninterface ApiProviderInternal {\n\tapi: Api;\n\tstream: ApiStreamFunction;\n\tstreamSimple: ApiStreamSimpleFunction;\n}\n\ntype RegisteredApiProvider = {\n\tprovider: ApiProviderInternal;\n\tsourceId?: string;\n};\n\nconst apiProviderRegistry = new Map<string, RegisteredApiProvider>();\n\nfunction wrapStream<TApi extends Api, TOptions extends StreamOptions>(\n\tapi: TApi,\n\tstream: StreamFunction<TApi, TOptions>,\n): ApiStreamFunction {\n\treturn (model, context, options) => {\n\t\tif (model.api !== api) {\n\t\t\tthrow new Error(`Mismatched api: ${model.api} expected ${api}`);\n\t\t}\n\t\treturn stream(model as Model<TApi>, context, options as TOptions);\n\t};\n}\n\nfunction wrapStreamSimple<TApi extends Api>(\n\tapi: TApi,\n\tstreamSimple: StreamFunction<TApi, SimpleStreamOptions>,\n): ApiStreamSimpleFunction {\n\treturn (model, context, options) => {\n\t\tif (model.api !== api) {\n\t\t\tthrow new Error(`Mismatched api: ${model.api} expected ${api}`);\n\t\t}\n\t\treturn streamSimple(model as Model<TApi>, context, options);\n\t};\n}\n\nexport function registerApiProvider<TApi extends Api, TOptions extends StreamOptions>(\n\tprovider: ApiProvider<TApi, TOptions>,\n\tsourceId?: string,\n): void {\n\tapiProviderRegistry.set(provider.api, {\n\t\tprovider: {\n\t\t\tapi: provider.api,\n\t\t\tstream: wrapStream(provider.api, provider.stream),\n\t\t\tstreamSimple: wrapStreamSimple(provider.api, provider.streamSimple),\n\t\t},\n\t\tsourceId,\n\t});\n}\n\nexport function getApiProvider(api: Api): ApiProviderInternal | undefined {\n\treturn apiProviderRegistry.get(api)?.provider;\n}\n\nexport function getApiProviders(): ApiProviderInternal[] {\n\treturn Array.from(apiProviderRegistry.values(), (entry) => entry.provider);\n}\n\nexport function unregisterApiProviders(sourceId: string): void {\n\tfor (const [api, entry] of apiProviderRegistry.entries()) {\n\t\tif (entry.sourceId === sourceId) {\n\t\t\tapiProviderRegistry.delete(api);\n\t\t}\n\t}\n}\n\nfunction clearApiProviders(): void {\n\tapiProviderRegistry.clear();\n}\n\nexport function registerFauxProvider(options: RegisterFauxProviderOptions = {}): FauxProviderRegistration {\n\tconst core = createFauxCore(options);\n\tconst sourceId = `faux-provider-${Math.random().toString(36).slice(2, 10)}`;\n\tregisterApiProvider({ api: core.api, stream: core.stream, streamSimple: core.streamSimple }, sourceId);\n\treturn {\n\t\tapi: core.api,\n\t\tmodels: core.models,\n\t\tgetModel: core.getModel,\n\t\tstate: core.state,\n\t\tsetResponses: core.setResponses,\n\t\tappendResponses: core.appendResponses,\n\t\tgetPendingResponseCount: core.getPendingResponseCount,\n\t\tunregister() {\n\t\t\tunregisterApiProviders(sourceId);\n\t\t},\n\t};\n}\n\nconst BUILTIN_APIS: [Api, ProviderStreams][] = [\n\t[\"anthropic-messages\", anthropicMessagesApi()],\n\t[\"openai-completions\", openAICompletionsApi()],\n\t[\"openai-responses\", openAIResponsesApi()],\n\t[\"openai-codex-responses\", openAICodexResponsesApi()],\n\t[\"azure-openai-responses\", azureOpenAIResponsesApi()],\n\t[\"google-generative-ai\", googleGenerativeAIApi()],\n\t[\"google-vertex\", googleVertexApi()],\n\t[\"mistral-conversations\", mistralConversationsApi()],\n\t[\"bedrock-converse-stream\", bedrockConverseStreamApi()],\n];\n\nconst builtinApiProviderInstances = new Map<Api, ReturnType<typeof getApiProvider>>();\n\n/**\n * Registers the builtin API implementations into the api-registry without\n * clobbering existing entries: compat may load after a test or extension has\n * already registered an override for a builtin api id.\n */\nexport function registerBuiltInApiProviders(): void {\n\tfor (const [api, streams] of BUILTIN_APIS) {\n\t\tif (!getApiProvider(api)) {\n\t\t\tregisterApiProvider({ api, stream: streams.stream, streamSimple: streams.streamSimple });\n\t\t}\n\t\tbuiltinApiProviderInstances.set(api, getApiProvider(api));\n\t}\n}\n\nexport function resetApiProviders(): void {\n\tclearApiProviders();\n\tbuiltinApiProviderInstances.clear();\n\tregisterBuiltInApiProviders();\n}\n\nregisterBuiltInApiProviders();\n\nconst compatModels = builtinModels();\n\nfunction hasExplicitApiKey(apiKey: string | undefined): apiKey is string {\n\treturn typeof apiKey === \"string\" && apiKey.trim().length > 0;\n}\n\nfunction withEnvApiKey<TOptions extends StreamOptions>(\n\tmodel: Model<Api>,\n\toptions: TOptions | undefined,\n): TOptions | undefined {\n\tif (hasExplicitApiKey(options?.apiKey)) return options;\n\tconst apiKey = getEnvApiKey(model.provider, options?.env);\n\tif (!apiKey) return options;\n\treturn { ...options, apiKey } as TOptions;\n}\n\nfunction shouldUseBuiltinModels(model: Model<Api>): boolean {\n\tconst builtin = compatModels.getModel(model.provider, model.id);\n\treturn builtin?.api === model.api && getApiProvider(model.api) === builtinApiProviderInstances.get(model.api);\n}\n\nfunction resolveApiProvider(api: Api) {\n\tconst provider = getApiProvider(api);\n\tif (!provider) {\n\t\tthrow new Error(`No API provider registered for api: ${api}`);\n\t}\n\treturn provider;\n}\n\nexport function stream<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: ProviderStreamOptions,\n): AssistantMessageEventStream {\n\tif (shouldUseBuiltinModels(model)) {\n\t\treturn compatModels.stream(model, context, options as ApiStreamOptions<TApi> | undefined);\n\t}\n\tconst provider = resolveApiProvider(model.api);\n\treturn provider.stream(model, context, withEnvApiKey(model, options) as StreamOptions);\n}\n\nexport async function complete<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: ProviderStreamOptions,\n): Promise<AssistantMessage> {\n\tconst s = stream(model, context, options);\n\treturn s.result();\n}\n\nexport function streamSimple<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n): AssistantMessageEventStream {\n\tif (shouldUseBuiltinModels(model)) {\n\t\treturn compatModels.streamSimple(model, context, options);\n\t}\n\tconst provider = resolveApiProvider(model.api);\n\treturn provider.streamSimple(model, context, withEnvApiKey(model, options));\n}\n\nexport async function completeSimple<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n): Promise<AssistantMessage> {\n\tconst s = streamSimple(model, context, options);\n\treturn s.result();\n}\n"]}
package/dist/compat.js CHANGED
@@ -23,6 +23,7 @@ export * from "./image-models.js";
23
23
  export * from "./images.js";
24
24
  export * from "./images-api-registry.js";
25
25
  export * from "./index.js";
26
+ export * from "./legacy-api-aliases.js";
26
27
  export * from "./providers/images/register-builtins.js";
27
28
  import { anthropicMessagesApi } from "./api/anthropic-messages.lazy.js";
28
29
  import { azureOpenAIResponsesApi } from "./api/azure-openai-responses.lazy.js";
@@ -1 +1 @@
1
- {"version":3,"file":"compat.js","sourceRoot":"","sources":["../src/compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,yCAAyC,CAAC;AAExD,OAAO,EAAE,oBAAoB,E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,OAAO,CAAC,CAAC;IAC1C,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;AAAA,CAClB;AAED,MAAM,UAAU,YAAY,CAC3B,KAAkB,EAClB,OAAgB,EAChB,OAA6B,EACC;IAC9B,IAAI,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,YAAY,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/C,OAAO,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAC5E;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,KAAkB,EAClB,OAAgB,EAChB,OAA6B,EACD;IAC5B,MAAM,CAAC,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAChD,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;AAAA,CAClB","sourcesContent":["/**\n * Temporary compatibility entrypoint preserving the old global pi-ai API\n * surface: api-dispatch `stream()`/`complete()` with env API key injection,\n * the api-registry, generated catalog reads (`getModel`/`getModels`/\n * `getProviders`), per-API lazy stream wrappers, and image generation.\n *\n * Existing apps switch imports from \"@earendil-works/pi-ai\" to\n * \"@earendil-works/pi-ai/compat\" unchanged; new code uses `createModels()`\n * and the provider factories. This module is deleted with the coding-agent\n * ModelManager migration.\n */\n\nexport * from \"./api/anthropic-messages.lazy.ts\";\nexport * from \"./api/azure-openai-responses.lazy.ts\";\nexport * from \"./api/bedrock-converse-stream.lazy.ts\";\nexport * from \"./api/google-generative-ai.lazy.ts\";\nexport * from \"./api/google-vertex.lazy.ts\";\nexport * from \"./api/mistral-conversations.lazy.ts\";\nexport * from \"./api/openai-codex-responses.lazy.ts\";\nexport * from \"./api/openai-completions.lazy.ts\";\nexport * from \"./api/openai-responses.lazy.ts\";\nexport * from \"./env-api-keys.ts\";\nexport * from \"./image-models.ts\";\nexport * from \"./images.ts\";\nexport * from \"./images-api-registry.ts\";\nexport * from \"./index.ts\";\nexport * from \"./providers/images/register-builtins.ts\";\n\nimport { anthropicMessagesApi } from \"./api/anthropic-messages.lazy.ts\";\nimport { azureOpenAIResponsesApi } from \"./api/azure-openai-responses.lazy.ts\";\nimport { bedrockConverseStreamApi } from \"./api/bedrock-converse-stream.lazy.ts\";\nimport { googleGenerativeAIApi } from \"./api/google-generative-ai.lazy.ts\";\nimport { googleVertexApi } from \"./api/google-vertex.lazy.ts\";\nimport { mistralConversationsApi } from \"./api/mistral-conversations.lazy.ts\";\nimport { openAICodexResponsesApi } from \"./api/openai-codex-responses.lazy.ts\";\nimport { openAICompletionsApi } from \"./api/openai-completions.lazy.ts\";\nimport { openAIResponsesApi } from \"./api/openai-responses.lazy.ts\";\nimport { getEnvApiKey } from \"./env-api-keys.ts\";\nimport { builtinModels, getBuiltinModel, getBuiltinModels, getBuiltinProviders } from \"./providers/all.ts\";\nimport { createFauxCore, type FauxProviderRegistration, type RegisterFauxProviderOptions } from \"./providers/faux.ts\";\nimport type {\n\tApi,\n\tApiStreamOptions,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tContext,\n\tModel,\n\tProviderStreamOptions,\n\tProviderStreams,\n\tSimpleStreamOptions,\n\tStreamFunction,\n\tStreamOptions,\n} from \"./types.ts\";\n\n/** @deprecated Static catalog read. Use `getBuiltinModel` from \"@earendil-works/pi-ai/providers/all\" or `Models.getModel()`. */\nexport const getModel = getBuiltinModel;\n\n/** @deprecated Static catalog read. Use `getBuiltinModels` from \"@earendil-works/pi-ai/providers/all\" or `Models.getModels()`. */\nexport const getModels = getBuiltinModels;\n\n/** @deprecated Static catalog read. Use `getBuiltinProviders` from \"@earendil-works/pi-ai/providers/all\" or `Models.getProviders()`. */\nexport const getProviders = getBuiltinProviders;\n\nexport type ApiStreamFunction = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: StreamOptions,\n) => AssistantMessageEventStream;\n\nexport type ApiStreamSimpleFunction = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n) => AssistantMessageEventStream;\n\nexport interface ApiProvider<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> {\n\tapi: TApi;\n\tstream: StreamFunction<TApi, TOptions>;\n\tstreamSimple: StreamFunction<TApi, SimpleStreamOptions>;\n}\n\ninterface ApiProviderInternal {\n\tapi: Api;\n\tstream: ApiStreamFunction;\n\tstreamSimple: ApiStreamSimpleFunction;\n}\n\ntype RegisteredApiProvider = {\n\tprovider: ApiProviderInternal;\n\tsourceId?: string;\n};\n\nconst apiProviderRegistry = new Map<string, RegisteredApiProvider>();\n\nfunction wrapStream<TApi extends Api, TOptions extends StreamOptions>(\n\tapi: TApi,\n\tstream: StreamFunction<TApi, TOptions>,\n): ApiStreamFunction {\n\treturn (model, context, options) => {\n\t\tif (model.api !== api) {\n\t\t\tthrow new Error(`Mismatched api: ${model.api} expected ${api}`);\n\t\t}\n\t\treturn stream(model as Model<TApi>, context, options as TOptions);\n\t};\n}\n\nfunction wrapStreamSimple<TApi extends Api>(\n\tapi: TApi,\n\tstreamSimple: StreamFunction<TApi, SimpleStreamOptions>,\n): ApiStreamSimpleFunction {\n\treturn (model, context, options) => {\n\t\tif (model.api !== api) {\n\t\t\tthrow new Error(`Mismatched api: ${model.api} expected ${api}`);\n\t\t}\n\t\treturn streamSimple(model as Model<TApi>, context, options);\n\t};\n}\n\nexport function registerApiProvider<TApi extends Api, TOptions extends StreamOptions>(\n\tprovider: ApiProvider<TApi, TOptions>,\n\tsourceId?: string,\n): void {\n\tapiProviderRegistry.set(provider.api, {\n\t\tprovider: {\n\t\t\tapi: provider.api,\n\t\t\tstream: wrapStream(provider.api, provider.stream),\n\t\t\tstreamSimple: wrapStreamSimple(provider.api, provider.streamSimple),\n\t\t},\n\t\tsourceId,\n\t});\n}\n\nexport function getApiProvider(api: Api): ApiProviderInternal | undefined {\n\treturn apiProviderRegistry.get(api)?.provider;\n}\n\nexport function getApiProviders(): ApiProviderInternal[] {\n\treturn Array.from(apiProviderRegistry.values(), (entry) => entry.provider);\n}\n\nexport function unregisterApiProviders(sourceId: string): void {\n\tfor (const [api, entry] of apiProviderRegistry.entries()) {\n\t\tif (entry.sourceId === sourceId) {\n\t\t\tapiProviderRegistry.delete(api);\n\t\t}\n\t}\n}\n\nfunction clearApiProviders(): void {\n\tapiProviderRegistry.clear();\n}\n\nexport function registerFauxProvider(options: RegisterFauxProviderOptions = {}): FauxProviderRegistration {\n\tconst core = createFauxCore(options);\n\tconst sourceId = `faux-provider-${Math.random().toString(36).slice(2, 10)}`;\n\tregisterApiProvider({ api: core.api, stream: core.stream, streamSimple: core.streamSimple }, sourceId);\n\treturn {\n\t\tapi: core.api,\n\t\tmodels: core.models,\n\t\tgetModel: core.getModel,\n\t\tstate: core.state,\n\t\tsetResponses: core.setResponses,\n\t\tappendResponses: core.appendResponses,\n\t\tgetPendingResponseCount: core.getPendingResponseCount,\n\t\tunregister() {\n\t\t\tunregisterApiProviders(sourceId);\n\t\t},\n\t};\n}\n\nconst BUILTIN_APIS: [Api, ProviderStreams][] = [\n\t[\"anthropic-messages\", anthropicMessagesApi()],\n\t[\"openai-completions\", openAICompletionsApi()],\n\t[\"openai-responses\", openAIResponsesApi()],\n\t[\"openai-codex-responses\", openAICodexResponsesApi()],\n\t[\"azure-openai-responses\", azureOpenAIResponsesApi()],\n\t[\"google-generative-ai\", googleGenerativeAIApi()],\n\t[\"google-vertex\", googleVertexApi()],\n\t[\"mistral-conversations\", mistralConversationsApi()],\n\t[\"bedrock-converse-stream\", bedrockConverseStreamApi()],\n];\n\nconst builtinApiProviderInstances = new Map<Api, ReturnType<typeof getApiProvider>>();\n\n/**\n * Registers the builtin API implementations into the api-registry without\n * clobbering existing entries: compat may load after a test or extension has\n * already registered an override for a builtin api id.\n */\nexport function registerBuiltInApiProviders(): void {\n\tfor (const [api, streams] of BUILTIN_APIS) {\n\t\tif (!getApiProvider(api)) {\n\t\t\tregisterApiProvider({ api, stream: streams.stream, streamSimple: streams.streamSimple });\n\t\t}\n\t\tbuiltinApiProviderInstances.set(api, getApiProvider(api));\n\t}\n}\n\nexport function resetApiProviders(): void {\n\tclearApiProviders();\n\tbuiltinApiProviderInstances.clear();\n\tregisterBuiltInApiProviders();\n}\n\nregisterBuiltInApiProviders();\n\nconst compatModels = builtinModels();\n\nfunction hasExplicitApiKey(apiKey: string | undefined): apiKey is string {\n\treturn typeof apiKey === \"string\" && apiKey.trim().length > 0;\n}\n\nfunction withEnvApiKey<TOptions extends StreamOptions>(\n\tmodel: Model<Api>,\n\toptions: TOptions | undefined,\n): TOptions | undefined {\n\tif (hasExplicitApiKey(options?.apiKey)) return options;\n\tconst apiKey = getEnvApiKey(model.provider, options?.env);\n\tif (!apiKey) return options;\n\treturn { ...options, apiKey } as TOptions;\n}\n\nfunction shouldUseBuiltinModels(model: Model<Api>): boolean {\n\tconst builtin = compatModels.getModel(model.provider, model.id);\n\treturn builtin?.api === model.api && getApiProvider(model.api) === builtinApiProviderInstances.get(model.api);\n}\n\nfunction resolveApiProvider(api: Api) {\n\tconst provider = getApiProvider(api);\n\tif (!provider) {\n\t\tthrow new Error(`No API provider registered for api: ${api}`);\n\t}\n\treturn provider;\n}\n\nexport function stream<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: ProviderStreamOptions,\n): AssistantMessageEventStream {\n\tif (shouldUseBuiltinModels(model)) {\n\t\treturn compatModels.stream(model, context, options as ApiStreamOptions<TApi> | undefined);\n\t}\n\tconst provider = resolveApiProvider(model.api);\n\treturn provider.stream(model, context, withEnvApiKey(model, options) as StreamOptions);\n}\n\nexport async function complete<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: ProviderStreamOptions,\n): Promise<AssistantMessage> {\n\tconst s = stream(model, context, options);\n\treturn s.result();\n}\n\nexport function streamSimple<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n): AssistantMessageEventStream {\n\tif (shouldUseBuiltinModels(model)) {\n\t\treturn compatModels.streamSimple(model, context, options);\n\t}\n\tconst provider = resolveApiProvider(model.api);\n\treturn provider.streamSimple(model, context, withEnvApiKey(model, options));\n}\n\nexport async function completeSimple<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n): Promise<AssistantMessage> {\n\tconst s = streamSimple(model, context, options);\n\treturn s.result();\n}\n"]}
1
+ {"version":3,"file":"compat.js","sourceRoot":"","sources":["../src/compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yCAAyC,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AA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AM,QAAQ,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/C,OAAO,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAC5E;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,KAAkB,EAClB,OAAgB,EAChB,OAA6B,EACD;IAC5B,MAAM,CAAC,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAChD,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;AAAA,CAClB","sourcesContent":["/**\n * Temporary compatibility entrypoint preserving the old global pi-ai API\n * surface: api-dispatch `stream()`/`complete()` with env API key injection,\n * the api-registry, generated catalog reads (`getModel`/`getModels`/\n * `getProviders`), per-API lazy stream wrappers, and image generation.\n *\n * Existing apps switch imports from \"@earendil-works/pi-ai\" to\n * \"@earendil-works/pi-ai/compat\" unchanged; new code uses `createModels()`\n * and the provider factories. This module is deleted with the coding-agent\n * ModelManager migration.\n */\n\nexport * from \"./api/anthropic-messages.lazy.ts\";\nexport * from \"./api/azure-openai-responses.lazy.ts\";\nexport * from \"./api/bedrock-converse-stream.lazy.ts\";\nexport * from \"./api/google-generative-ai.lazy.ts\";\nexport * from \"./api/google-vertex.lazy.ts\";\nexport * from \"./api/mistral-conversations.lazy.ts\";\nexport * from \"./api/openai-codex-responses.lazy.ts\";\nexport * from \"./api/openai-completions.lazy.ts\";\nexport * from \"./api/openai-responses.lazy.ts\";\nexport * from \"./env-api-keys.ts\";\nexport * from \"./image-models.ts\";\nexport * from \"./images.ts\";\nexport * from \"./images-api-registry.ts\";\nexport * from \"./index.ts\";\nexport * from \"./legacy-api-aliases.ts\";\nexport * from \"./providers/images/register-builtins.ts\";\n\nimport { anthropicMessagesApi } from \"./api/anthropic-messages.lazy.ts\";\nimport { azureOpenAIResponsesApi } from \"./api/azure-openai-responses.lazy.ts\";\nimport { bedrockConverseStreamApi } from \"./api/bedrock-converse-stream.lazy.ts\";\nimport { googleGenerativeAIApi } from \"./api/google-generative-ai.lazy.ts\";\nimport { googleVertexApi } from \"./api/google-vertex.lazy.ts\";\nimport { mistralConversationsApi } from \"./api/mistral-conversations.lazy.ts\";\nimport { openAICodexResponsesApi } from \"./api/openai-codex-responses.lazy.ts\";\nimport { openAICompletionsApi } from \"./api/openai-completions.lazy.ts\";\nimport { openAIResponsesApi } from \"./api/openai-responses.lazy.ts\";\nimport { getEnvApiKey } from \"./env-api-keys.ts\";\nimport { builtinModels, getBuiltinModel, getBuiltinModels, getBuiltinProviders } from \"./providers/all.ts\";\nimport { createFauxCore, type FauxProviderRegistration, type RegisterFauxProviderOptions } from \"./providers/faux.ts\";\nimport type {\n\tApi,\n\tApiStreamOptions,\n\tAssistantMessage,\n\tAssistantMessageEventStream,\n\tContext,\n\tModel,\n\tProviderStreamOptions,\n\tProviderStreams,\n\tSimpleStreamOptions,\n\tStreamFunction,\n\tStreamOptions,\n} from \"./types.ts\";\n\n/** @deprecated Static catalog read. Use `getBuiltinModel` from \"@earendil-works/pi-ai/providers/all\" or `Models.getModel()`. */\nexport const getModel = getBuiltinModel;\n\n/** @deprecated Static catalog read. Use `getBuiltinModels` from \"@earendil-works/pi-ai/providers/all\" or `Models.getModels()`. */\nexport const getModels = getBuiltinModels;\n\n/** @deprecated Static catalog read. Use `getBuiltinProviders` from \"@earendil-works/pi-ai/providers/all\" or `Models.getProviders()`. */\nexport const getProviders = getBuiltinProviders;\n\nexport type ApiStreamFunction = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: StreamOptions,\n) => AssistantMessageEventStream;\n\nexport type ApiStreamSimpleFunction = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n) => AssistantMessageEventStream;\n\nexport interface ApiProvider<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> {\n\tapi: TApi;\n\tstream: StreamFunction<TApi, TOptions>;\n\tstreamSimple: StreamFunction<TApi, SimpleStreamOptions>;\n}\n\ninterface ApiProviderInternal {\n\tapi: Api;\n\tstream: ApiStreamFunction;\n\tstreamSimple: ApiStreamSimpleFunction;\n}\n\ntype RegisteredApiProvider = {\n\tprovider: ApiProviderInternal;\n\tsourceId?: string;\n};\n\nconst apiProviderRegistry = new Map<string, RegisteredApiProvider>();\n\nfunction wrapStream<TApi extends Api, TOptions extends StreamOptions>(\n\tapi: TApi,\n\tstream: StreamFunction<TApi, TOptions>,\n): ApiStreamFunction {\n\treturn (model, context, options) => {\n\t\tif (model.api !== api) {\n\t\t\tthrow new Error(`Mismatched api: ${model.api} expected ${api}`);\n\t\t}\n\t\treturn stream(model as Model<TApi>, context, options as TOptions);\n\t};\n}\n\nfunction wrapStreamSimple<TApi extends Api>(\n\tapi: TApi,\n\tstreamSimple: StreamFunction<TApi, SimpleStreamOptions>,\n): ApiStreamSimpleFunction {\n\treturn (model, context, options) => {\n\t\tif (model.api !== api) {\n\t\t\tthrow new Error(`Mismatched api: ${model.api} expected ${api}`);\n\t\t}\n\t\treturn streamSimple(model as Model<TApi>, context, options);\n\t};\n}\n\nexport function registerApiProvider<TApi extends Api, TOptions extends StreamOptions>(\n\tprovider: ApiProvider<TApi, TOptions>,\n\tsourceId?: string,\n): void {\n\tapiProviderRegistry.set(provider.api, {\n\t\tprovider: {\n\t\t\tapi: provider.api,\n\t\t\tstream: wrapStream(provider.api, provider.stream),\n\t\t\tstreamSimple: wrapStreamSimple(provider.api, provider.streamSimple),\n\t\t},\n\t\tsourceId,\n\t});\n}\n\nexport function getApiProvider(api: Api): ApiProviderInternal | undefined {\n\treturn apiProviderRegistry.get(api)?.provider;\n}\n\nexport function getApiProviders(): ApiProviderInternal[] {\n\treturn Array.from(apiProviderRegistry.values(), (entry) => entry.provider);\n}\n\nexport function unregisterApiProviders(sourceId: string): void {\n\tfor (const [api, entry] of apiProviderRegistry.entries()) {\n\t\tif (entry.sourceId === sourceId) {\n\t\t\tapiProviderRegistry.delete(api);\n\t\t}\n\t}\n}\n\nfunction clearApiProviders(): void {\n\tapiProviderRegistry.clear();\n}\n\nexport function registerFauxProvider(options: RegisterFauxProviderOptions = {}): FauxProviderRegistration {\n\tconst core = createFauxCore(options);\n\tconst sourceId = `faux-provider-${Math.random().toString(36).slice(2, 10)}`;\n\tregisterApiProvider({ api: core.api, stream: core.stream, streamSimple: core.streamSimple }, sourceId);\n\treturn {\n\t\tapi: core.api,\n\t\tmodels: core.models,\n\t\tgetModel: core.getModel,\n\t\tstate: core.state,\n\t\tsetResponses: core.setResponses,\n\t\tappendResponses: core.appendResponses,\n\t\tgetPendingResponseCount: core.getPendingResponseCount,\n\t\tunregister() {\n\t\t\tunregisterApiProviders(sourceId);\n\t\t},\n\t};\n}\n\nconst BUILTIN_APIS: [Api, ProviderStreams][] = [\n\t[\"anthropic-messages\", anthropicMessagesApi()],\n\t[\"openai-completions\", openAICompletionsApi()],\n\t[\"openai-responses\", openAIResponsesApi()],\n\t[\"openai-codex-responses\", openAICodexResponsesApi()],\n\t[\"azure-openai-responses\", azureOpenAIResponsesApi()],\n\t[\"google-generative-ai\", googleGenerativeAIApi()],\n\t[\"google-vertex\", googleVertexApi()],\n\t[\"mistral-conversations\", mistralConversationsApi()],\n\t[\"bedrock-converse-stream\", bedrockConverseStreamApi()],\n];\n\nconst builtinApiProviderInstances = new Map<Api, ReturnType<typeof getApiProvider>>();\n\n/**\n * Registers the builtin API implementations into the api-registry without\n * clobbering existing entries: compat may load after a test or extension has\n * already registered an override for a builtin api id.\n */\nexport function registerBuiltInApiProviders(): void {\n\tfor (const [api, streams] of BUILTIN_APIS) {\n\t\tif (!getApiProvider(api)) {\n\t\t\tregisterApiProvider({ api, stream: streams.stream, streamSimple: streams.streamSimple });\n\t\t}\n\t\tbuiltinApiProviderInstances.set(api, getApiProvider(api));\n\t}\n}\n\nexport function resetApiProviders(): void {\n\tclearApiProviders();\n\tbuiltinApiProviderInstances.clear();\n\tregisterBuiltInApiProviders();\n}\n\nregisterBuiltInApiProviders();\n\nconst compatModels = builtinModels();\n\nfunction hasExplicitApiKey(apiKey: string | undefined): apiKey is string {\n\treturn typeof apiKey === \"string\" && apiKey.trim().length > 0;\n}\n\nfunction withEnvApiKey<TOptions extends StreamOptions>(\n\tmodel: Model<Api>,\n\toptions: TOptions | undefined,\n): TOptions | undefined {\n\tif (hasExplicitApiKey(options?.apiKey)) return options;\n\tconst apiKey = getEnvApiKey(model.provider, options?.env);\n\tif (!apiKey) return options;\n\treturn { ...options, apiKey } as TOptions;\n}\n\nfunction shouldUseBuiltinModels(model: Model<Api>): boolean {\n\tconst builtin = compatModels.getModel(model.provider, model.id);\n\treturn builtin?.api === model.api && getApiProvider(model.api) === builtinApiProviderInstances.get(model.api);\n}\n\nfunction resolveApiProvider(api: Api) {\n\tconst provider = getApiProvider(api);\n\tif (!provider) {\n\t\tthrow new Error(`No API provider registered for api: ${api}`);\n\t}\n\treturn provider;\n}\n\nexport function stream<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: ProviderStreamOptions,\n): AssistantMessageEventStream {\n\tif (shouldUseBuiltinModels(model)) {\n\t\treturn compatModels.stream(model, context, options as ApiStreamOptions<TApi> | undefined);\n\t}\n\tconst provider = resolveApiProvider(model.api);\n\treturn provider.stream(model, context, withEnvApiKey(model, options) as StreamOptions);\n}\n\nexport async function complete<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: ProviderStreamOptions,\n): Promise<AssistantMessage> {\n\tconst s = stream(model, context, options);\n\treturn s.result();\n}\n\nexport function streamSimple<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n): AssistantMessageEventStream {\n\tif (shouldUseBuiltinModels(model)) {\n\t\treturn compatModels.streamSimple(model, context, options);\n\t}\n\tconst provider = resolveApiProvider(model.api);\n\treturn provider.streamSimple(model, context, withEnvApiKey(model, options));\n}\n\nexport async function completeSimple<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n): Promise<AssistantMessage> {\n\tconst s = streamSimple(model, context, options);\n\treturn s.result();\n}\n"]}
@@ -150,6 +150,21 @@ export declare const IMAGE_MODELS: {
150
150
  cacheWrite: number;
151
151
  };
152
152
  };
153
+ readonly "google/gemini-3.1-flash-lite-image": {
154
+ id: string;
155
+ name: string;
156
+ api: "openrouter-images";
157
+ provider: string;
158
+ baseUrl: string;
159
+ input: ("image" | "text")[];
160
+ output: ("image" | "text")[];
161
+ cost: {
162
+ input: number;
163
+ output: number;
164
+ cacheRead: number;
165
+ cacheWrite: number;
166
+ };
167
+ };
153
168
  readonly "microsoft/mai-image-2.5": {
154
169
  id: string;
155
170
  name: string;
@@ -210,14 +225,14 @@ export declare const IMAGE_MODELS: {
210
225
  cacheWrite: number;
211
226
  };
212
227
  };
213
- readonly "openrouter/auto": {
228
+ readonly "openai/gpt-image-1": {
214
229
  id: string;
215
230
  name: string;
216
231
  api: "openrouter-images";
217
232
  provider: string;
218
233
  baseUrl: string;
219
234
  input: ("image" | "text")[];
220
- output: ("image" | "text")[];
235
+ output: "image"[];
221
236
  cost: {
222
237
  input: number;
223
238
  output: number;
@@ -225,7 +240,7 @@ export declare const IMAGE_MODELS: {
225
240
  cacheWrite: number;
226
241
  };
227
242
  };
228
- readonly "recraft/recraft-v3": {
243
+ readonly "openai/gpt-image-1-mini": {
229
244
  id: string;
230
245
  name: string;
231
246
  api: "openrouter-images";
@@ -240,7 +255,7 @@ export declare const IMAGE_MODELS: {
240
255
  cacheWrite: number;
241
256
  };
242
257
  };
243
- readonly "recraft/recraft-v4": {
258
+ readonly "openai/gpt-image-2": {
244
259
  id: string;
245
260
  name: string;
246
261
  api: "openrouter-images";
@@ -255,14 +270,14 @@ export declare const IMAGE_MODELS: {
255
270
  cacheWrite: number;
256
271
  };
257
272
  };
258
- readonly "recraft/recraft-v4-pro": {
273
+ readonly "openrouter/auto": {
259
274
  id: string;
260
275
  name: string;
261
276
  api: "openrouter-images";
262
277
  provider: string;
263
278
  baseUrl: string;
264
279
  input: ("image" | "text")[];
265
- output: "image"[];
280
+ output: ("image" | "text")[];
266
281
  cost: {
267
282
  input: number;
268
283
  output: number;
@@ -270,7 +285,7 @@ export declare const IMAGE_MODELS: {
270
285
  cacheWrite: number;
271
286
  };
272
287
  };
273
- readonly "recraft/recraft-v4-pro-vector": {
288
+ readonly "recraft/recraft-v3": {
274
289
  id: string;
275
290
  name: string;
276
291
  api: "openrouter-images";
@@ -285,7 +300,7 @@ export declare const IMAGE_MODELS: {
285
300
  cacheWrite: number;
286
301
  };
287
302
  };
288
- readonly "recraft/recraft-v4-vector": {
303
+ readonly "recraft/recraft-v4": {
289
304
  id: string;
290
305
  name: string;
291
306
  api: "openrouter-images";
@@ -300,7 +315,7 @@ export declare const IMAGE_MODELS: {
300
315
  cacheWrite: number;
301
316
  };
302
317
  };
303
- readonly "recraft/recraft-v4.1": {
318
+ readonly "recraft/recraft-v4-pro": {
304
319
  id: string;
305
320
  name: string;
306
321
  api: "openrouter-images";
@@ -315,7 +330,7 @@ export declare const IMAGE_MODELS: {
315
330
  cacheWrite: number;
316
331
  };
317
332
  };
318
- readonly "recraft/recraft-v4.1-pro": {
333
+ readonly "recraft/recraft-v4-pro-vector": {
319
334
  id: string;
320
335
  name: string;
321
336
  api: "openrouter-images";
@@ -330,7 +345,7 @@ export declare const IMAGE_MODELS: {
330
345
  cacheWrite: number;
331
346
  };
332
347
  };
333
- readonly "recraft/recraft-v4.1-pro-vector": {
348
+ readonly "recraft/recraft-v4-vector": {
334
349
  id: string;
335
350
  name: string;
336
351
  api: "openrouter-images";
@@ -345,7 +360,7 @@ export declare const IMAGE_MODELS: {
345
360
  cacheWrite: number;
346
361
  };
347
362
  };
348
- readonly "recraft/recraft-v4.1-utility": {
363
+ readonly "recraft/recraft-v4.1": {
349
364
  id: string;
350
365
  name: string;
351
366
  api: "openrouter-images";
@@ -360,7 +375,7 @@ export declare const IMAGE_MODELS: {
360
375
  cacheWrite: number;
361
376
  };
362
377
  };
363
- readonly "recraft/recraft-v4.1-utility-pro": {
378
+ readonly "recraft/recraft-v4.1-pro": {
364
379
  id: string;
365
380
  name: string;
366
381
  api: "openrouter-images";
@@ -375,7 +390,7 @@ export declare const IMAGE_MODELS: {
375
390
  cacheWrite: number;
376
391
  };
377
392
  };
378
- readonly "recraft/recraft-v4.1-vector": {
393
+ readonly "recraft/recraft-v4.1-pro-vector": {
379
394
  id: string;
380
395
  name: string;
381
396
  api: "openrouter-images";
@@ -390,7 +405,7 @@ export declare const IMAGE_MODELS: {
390
405
  cacheWrite: number;
391
406
  };
392
407
  };
393
- readonly "sourceful/riverflow-v2-fast": {
408
+ readonly "recraft/recraft-v4.1-utility": {
394
409
  id: string;
395
410
  name: string;
396
411
  api: "openrouter-images";
@@ -405,7 +420,7 @@ export declare const IMAGE_MODELS: {
405
420
  cacheWrite: number;
406
421
  };
407
422
  };
408
- readonly "sourceful/riverflow-v2-fast-preview": {
423
+ readonly "recraft/recraft-v4.1-utility-pro": {
409
424
  id: string;
410
425
  name: string;
411
426
  api: "openrouter-images";
@@ -420,7 +435,7 @@ export declare const IMAGE_MODELS: {
420
435
  cacheWrite: number;
421
436
  };
422
437
  };
423
- readonly "sourceful/riverflow-v2-max-preview": {
438
+ readonly "recraft/recraft-v4.1-vector": {
424
439
  id: string;
425
440
  name: string;
426
441
  api: "openrouter-images";
@@ -435,7 +450,7 @@ export declare const IMAGE_MODELS: {
435
450
  cacheWrite: number;
436
451
  };
437
452
  };
438
- readonly "sourceful/riverflow-v2-pro": {
453
+ readonly "sourceful/riverflow-v2-fast": {
439
454
  id: string;
440
455
  name: string;
441
456
  api: "openrouter-images";
@@ -450,7 +465,7 @@ export declare const IMAGE_MODELS: {
450
465
  cacheWrite: number;
451
466
  };
452
467
  };
453
- readonly "sourceful/riverflow-v2-standard-preview": {
468
+ readonly "sourceful/riverflow-v2-pro": {
454
469
  id: string;
455
470
  name: string;
456
471
  api: "openrouter-images";
@@ -1 +1 @@
1
- {"version":3,"file":"image-models.generated.d.ts","sourceRoot":"","sources":["../src/image-models.generated.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAigBkD,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-image-models.ts\n// Do not edit manually - run 'npm run generate-image-models' to update\n\nimport type { ImagesApi, ImagesModel } from \"./types.ts\";\n\nexport const IMAGE_MODELS = {\n\t\"openrouter\": {\n\t\t\"black-forest-labs/flux.2-flex\": {\n\t\t\tid: \"black-forest-labs/flux.2-flex\",\n\t\t\tname: \"Black Forest Labs: FLUX.2 Flex\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"black-forest-labs/flux.2-klein-4b\": {\n\t\t\tid: \"black-forest-labs/flux.2-klein-4b\",\n\t\t\tname: \"Black Forest Labs: FLUX.2 Klein 4B\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"black-forest-labs/flux.2-max\": {\n\t\t\tid: \"black-forest-labs/flux.2-max\",\n\t\t\tname: \"Black Forest Labs: FLUX.2 Max\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"black-forest-labs/flux.2-pro\": {\n\t\t\tid: \"black-forest-labs/flux.2-pro\",\n\t\t\tname: \"Black Forest Labs: FLUX.2 Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"bytedance-seed/seedream-4.5\": {\n\t\t\tid: \"bytedance-seed/seedream-4.5\",\n\t\t\tname: \"ByteDance Seed: Seedream 4.5\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"google/gemini-2.5-flash-image\": {\n\t\t\tid: \"google/gemini-2.5-flash-image\",\n\t\t\tname: \"Google: Nano Banana (Gemini 2.5 Flash Image)\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 0.3,\n\t \"output\": 2.5,\n\t \"cacheRead\": 0.03,\n\t \"cacheWrite\": 0.08333333333333334\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"google/gemini-3-pro-image\": {\n\t\t\tid: \"google/gemini-3-pro-image\",\n\t\t\tname: \"Google: Nano Banana Pro (Gemini 3 Pro Image)\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 2,\n\t \"output\": 12,\n\t \"cacheRead\": 0.19999999999999998,\n\t \"cacheWrite\": 0.375\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"google/gemini-3-pro-image-preview\": {\n\t\t\tid: \"google/gemini-3-pro-image-preview\",\n\t\t\tname: \"Google: Nano Banana Pro (Gemini 3 Pro Image Preview)\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 2,\n\t \"output\": 12,\n\t \"cacheRead\": 0.19999999999999998,\n\t \"cacheWrite\": 0.375\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"google/gemini-3.1-flash-image\": {\n\t\t\tid: \"google/gemini-3.1-flash-image\",\n\t\t\tname: \"Google: Nano Banana 2 (Gemini 3.1 Flash Image)\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 0.5,\n\t \"output\": 3,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"google/gemini-3.1-flash-image-preview\": {\n\t\t\tid: \"google/gemini-3.1-flash-image-preview\",\n\t\t\tname: \"Google: Nano Banana 2 (Gemini 3.1 Flash Image Preview)\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 0.5,\n\t \"output\": 3,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"microsoft/mai-image-2.5\": {\n\t\t\tid: \"microsoft/mai-image-2.5\",\n\t\t\tname: \"Microsoft: MAI-Image-2.5\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 5,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"openai/gpt-5-image\": {\n\t\t\tid: \"openai/gpt-5-image\",\n\t\t\tname: \"OpenAI: GPT-5 Image\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 10,\n\t \"output\": 10,\n\t \"cacheRead\": 1.25,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"openai/gpt-5-image-mini\": {\n\t\t\tid: \"openai/gpt-5-image-mini\",\n\t\t\tname: \"OpenAI: GPT-5 Image Mini\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 2.5,\n\t \"output\": 2,\n\t \"cacheRead\": 0.25,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"openai/gpt-5.4-image-2\": {\n\t\t\tid: \"openai/gpt-5.4-image-2\",\n\t\t\tname: \"OpenAI: GPT-5.4 Image 2\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 8,\n\t \"output\": 15,\n\t \"cacheRead\": 2,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"openrouter/auto\": {\n\t\t\tid: \"openrouter/auto\",\n\t\t\tname: \"Auto Router\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"text\",\"image\"],\n\t\t\tcost: \t{\n\t \"input\": -1000000,\n\t \"output\": -1000000,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v3\": {\n\t\t\tid: \"recraft/recraft-v3\",\n\t\t\tname: \"Recraft: Recraft V3\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4\": {\n\t\t\tid: \"recraft/recraft-v4\",\n\t\t\tname: \"Recraft: Recraft V4\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4-pro\": {\n\t\t\tid: \"recraft/recraft-v4-pro\",\n\t\t\tname: \"Recraft: Recraft V4 Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4-pro-vector\": {\n\t\t\tid: \"recraft/recraft-v4-pro-vector\",\n\t\t\tname: \"Recraft: Recraft V4 Pro Vector\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4-vector\": {\n\t\t\tid: \"recraft/recraft-v4-vector\",\n\t\t\tname: \"Recraft: Recraft V4 Vector\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1\": {\n\t\t\tid: \"recraft/recraft-v4.1\",\n\t\t\tname: \"Recraft: Recraft V4.1\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1-pro\": {\n\t\t\tid: \"recraft/recraft-v4.1-pro\",\n\t\t\tname: \"Recraft: Recraft V4.1 Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1-pro-vector\": {\n\t\t\tid: \"recraft/recraft-v4.1-pro-vector\",\n\t\t\tname: \"Recraft: Recraft V4.1 Pro Vector\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1-utility\": {\n\t\t\tid: \"recraft/recraft-v4.1-utility\",\n\t\t\tname: \"Recraft: Recraft V4.1 Utility\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1-utility-pro\": {\n\t\t\tid: \"recraft/recraft-v4.1-utility-pro\",\n\t\t\tname: \"Recraft: Recraft V4.1 Utility Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1-vector\": {\n\t\t\tid: \"recraft/recraft-v4.1-vector\",\n\t\t\tname: \"Recraft: Recraft V4.1 Vector\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"sourceful/riverflow-v2-fast\": {\n\t\t\tid: \"sourceful/riverflow-v2-fast\",\n\t\t\tname: \"Sourceful: Riverflow V2 Fast\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"sourceful/riverflow-v2-fast-preview\": {\n\t\t\tid: \"sourceful/riverflow-v2-fast-preview\",\n\t\t\tname: \"Sourceful: Riverflow V2 Fast Preview\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"sourceful/riverflow-v2-max-preview\": {\n\t\t\tid: \"sourceful/riverflow-v2-max-preview\",\n\t\t\tname: \"Sourceful: Riverflow V2 Max Preview\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"sourceful/riverflow-v2-pro\": {\n\t\t\tid: \"sourceful/riverflow-v2-pro\",\n\t\t\tname: \"Sourceful: Riverflow V2 Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"sourceful/riverflow-v2-standard-preview\": {\n\t\t\tid: \"sourceful/riverflow-v2-standard-preview\",\n\t\t\tname: \"Sourceful: Riverflow V2 Standard Preview\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"sourceful/riverflow-v2.5-fast\": {\n\t\t\tid: \"sourceful/riverflow-v2.5-fast\",\n\t\t\tname: \"Sourceful: Riverflow V2.5 Fast\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"sourceful/riverflow-v2.5-pro\": {\n\t\t\tid: \"sourceful/riverflow-v2.5-pro\",\n\t\t\tname: \"Sourceful: Riverflow V2.5 Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"x-ai/grok-imagine-image-quality\": {\n\t\t\tid: \"x-ai/grok-imagine-image-quality\",\n\t\t\tname: \"xAI: Grok Imagine Image Quality\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t},\n} as const satisfies Record<string, Record<string, ImagesModel<ImagesApi>>>;\n"]}
1
+ {"version":3,"file":"image-models.generated.d.ts","sourceRoot":"","sources":["../src/image-models.generated.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAghBkD,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-image-models.ts\n// Do not edit manually - run 'npm run generate-image-models' to update\n\nimport type { ImagesApi, ImagesModel } from \"./types.ts\";\n\nexport const IMAGE_MODELS = {\n\t\"openrouter\": {\n\t\t\"black-forest-labs/flux.2-flex\": {\n\t\t\tid: \"black-forest-labs/flux.2-flex\",\n\t\t\tname: \"Black Forest Labs: FLUX.2 Flex\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"black-forest-labs/flux.2-klein-4b\": {\n\t\t\tid: \"black-forest-labs/flux.2-klein-4b\",\n\t\t\tname: \"Black Forest Labs: FLUX.2 Klein 4B\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"black-forest-labs/flux.2-max\": {\n\t\t\tid: \"black-forest-labs/flux.2-max\",\n\t\t\tname: \"Black Forest Labs: FLUX.2 Max\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"black-forest-labs/flux.2-pro\": {\n\t\t\tid: \"black-forest-labs/flux.2-pro\",\n\t\t\tname: \"Black Forest Labs: FLUX.2 Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"bytedance-seed/seedream-4.5\": {\n\t\t\tid: \"bytedance-seed/seedream-4.5\",\n\t\t\tname: \"ByteDance Seed: Seedream 4.5\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"google/gemini-2.5-flash-image\": {\n\t\t\tid: \"google/gemini-2.5-flash-image\",\n\t\t\tname: \"Google: Nano Banana (Gemini 2.5 Flash Image)\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 0.3,\n\t \"output\": 2.5,\n\t \"cacheRead\": 0.03,\n\t \"cacheWrite\": 0.08333333333333334\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"google/gemini-3-pro-image\": {\n\t\t\tid: \"google/gemini-3-pro-image\",\n\t\t\tname: \"Google: Nano Banana Pro (Gemini 3 Pro Image)\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 2,\n\t \"output\": 12,\n\t \"cacheRead\": 0.19999999999999998,\n\t \"cacheWrite\": 0.375\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"google/gemini-3-pro-image-preview\": {\n\t\t\tid: \"google/gemini-3-pro-image-preview\",\n\t\t\tname: \"Google: Nano Banana Pro (Gemini 3 Pro Image Preview)\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 2,\n\t \"output\": 12,\n\t \"cacheRead\": 0.19999999999999998,\n\t \"cacheWrite\": 0.375\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"google/gemini-3.1-flash-image\": {\n\t\t\tid: \"google/gemini-3.1-flash-image\",\n\t\t\tname: \"Google: Nano Banana 2 (Gemini 3.1 Flash Image)\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 0.5,\n\t \"output\": 3,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"google/gemini-3.1-flash-image-preview\": {\n\t\t\tid: \"google/gemini-3.1-flash-image-preview\",\n\t\t\tname: \"Google: Nano Banana 2 (Gemini 3.1 Flash Image Preview)\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 0.5,\n\t \"output\": 3,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"google/gemini-3.1-flash-lite-image\": {\n\t\t\tid: \"google/gemini-3.1-flash-lite-image\",\n\t\t\tname: \"Google: Nano Banana 2 Lite (Gemini 3.1 Flash Lite Image)\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 0.25,\n\t \"output\": 1.5,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"microsoft/mai-image-2.5\": {\n\t\t\tid: \"microsoft/mai-image-2.5\",\n\t\t\tname: \"Microsoft: MAI-Image-2.5\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 5,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"openai/gpt-5-image\": {\n\t\t\tid: \"openai/gpt-5-image\",\n\t\t\tname: \"OpenAI: GPT-5 Image\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 10,\n\t \"output\": 10,\n\t \"cacheRead\": 1.25,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"openai/gpt-5-image-mini\": {\n\t\t\tid: \"openai/gpt-5-image-mini\",\n\t\t\tname: \"OpenAI: GPT-5 Image Mini\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 2.5,\n\t \"output\": 2,\n\t \"cacheRead\": 0.25,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"openai/gpt-5.4-image-2\": {\n\t\t\tid: \"openai/gpt-5.4-image-2\",\n\t\t\tname: \"OpenAI: GPT-5.4 Image 2\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"image\",\"text\"],\n\t\t\toutput: [\"image\",\"text\"],\n\t\t\tcost: \t{\n\t \"input\": 8,\n\t \"output\": 15,\n\t \"cacheRead\": 2,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"openai/gpt-image-1\": {\n\t\t\tid: \"openai/gpt-image-1\",\n\t\t\tname: \"OpenAI: GPT Image 1\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 10,\n\t \"output\": 10,\n\t \"cacheRead\": 1.25,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"openai/gpt-image-1-mini\": {\n\t\t\tid: \"openai/gpt-image-1-mini\",\n\t\t\tname: \"OpenAI: GPT Image 1 Mini\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 2.5,\n\t \"output\": 2.5,\n\t \"cacheRead\": 0.25,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"openai/gpt-image-2\": {\n\t\t\tid: \"openai/gpt-image-2\",\n\t\t\tname: \"OpenAI: GPT Image 2\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 8,\n\t \"output\": 8,\n\t \"cacheRead\": 2,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"openrouter/auto\": {\n\t\t\tid: \"openrouter/auto\",\n\t\t\tname: \"Auto Router\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"text\",\"image\"],\n\t\t\tcost: \t{\n\t \"input\": -1000000,\n\t \"output\": -1000000,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v3\": {\n\t\t\tid: \"recraft/recraft-v3\",\n\t\t\tname: \"Recraft: Recraft V3\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4\": {\n\t\t\tid: \"recraft/recraft-v4\",\n\t\t\tname: \"Recraft: Recraft V4\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4-pro\": {\n\t\t\tid: \"recraft/recraft-v4-pro\",\n\t\t\tname: \"Recraft: Recraft V4 Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4-pro-vector\": {\n\t\t\tid: \"recraft/recraft-v4-pro-vector\",\n\t\t\tname: \"Recraft: Recraft V4 Pro Vector\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4-vector\": {\n\t\t\tid: \"recraft/recraft-v4-vector\",\n\t\t\tname: \"Recraft: Recraft V4 Vector\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1\": {\n\t\t\tid: \"recraft/recraft-v4.1\",\n\t\t\tname: \"Recraft: Recraft V4.1\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1-pro\": {\n\t\t\tid: \"recraft/recraft-v4.1-pro\",\n\t\t\tname: \"Recraft: Recraft V4.1 Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1-pro-vector\": {\n\t\t\tid: \"recraft/recraft-v4.1-pro-vector\",\n\t\t\tname: \"Recraft: Recraft V4.1 Pro Vector\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1-utility\": {\n\t\t\tid: \"recraft/recraft-v4.1-utility\",\n\t\t\tname: \"Recraft: Recraft V4.1 Utility\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1-utility-pro\": {\n\t\t\tid: \"recraft/recraft-v4.1-utility-pro\",\n\t\t\tname: \"Recraft: Recraft V4.1 Utility Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"recraft/recraft-v4.1-vector\": {\n\t\t\tid: \"recraft/recraft-v4.1-vector\",\n\t\t\tname: \"Recraft: Recraft V4.1 Vector\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"sourceful/riverflow-v2-fast\": {\n\t\t\tid: \"sourceful/riverflow-v2-fast\",\n\t\t\tname: \"Sourceful: Riverflow V2 Fast\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"sourceful/riverflow-v2-pro\": {\n\t\t\tid: \"sourceful/riverflow-v2-pro\",\n\t\t\tname: \"Sourceful: Riverflow V2 Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"sourceful/riverflow-v2.5-fast\": {\n\t\t\tid: \"sourceful/riverflow-v2.5-fast\",\n\t\t\tname: \"Sourceful: Riverflow V2.5 Fast\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"sourceful/riverflow-v2.5-pro\": {\n\t\t\tid: \"sourceful/riverflow-v2.5-pro\",\n\t\t\tname: \"Sourceful: Riverflow V2.5 Pro\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t\t\"x-ai/grok-imagine-image-quality\": {\n\t\t\tid: \"x-ai/grok-imagine-image-quality\",\n\t\t\tname: \"xAI: Grok Imagine Image Quality\",\n\t\t\tapi: \"openrouter-images\",\n\t\t\tprovider: \"openrouter\",\n\t\t\tbaseUrl: \"https://openrouter.ai/api/v1\",\n\t\t\tinput: [\"text\",\"image\"],\n\t\t\toutput: [\"image\"],\n\t\t\tcost: \t{\n\t \"input\": 0,\n\t \"output\": 0,\n\t \"cacheRead\": 0,\n\t \"cacheWrite\": 0\n\t}\n\t\t} satisfies ImagesModel<\"openrouter-images\">,\n\t},\n} as const satisfies Record<string, Record<string, ImagesModel<ImagesApi>>>;\n"]}