workers-ai-provider 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/openai.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ProviderPlugin } from "./gateway-delegate-CAX7trdL.mjs";
1
+ import { a as ProviderPlugin } from "./gateway-delegate-DYjgGAa-.mjs";
2
2
 
3
3
  //#region src/openai.d.ts
4
4
  /**
@@ -14,6 +14,10 @@ import { a as ProviderPlugin } from "./gateway-delegate-CAX7trdL.mjs";
14
14
  * Uses `.chat()` (Chat Completions) deliberately: the bare `openai()` call
15
15
  * (AI SDK v6+) defaults to the Responses API, which the AI Gateway run catalog
16
16
  * does not serve.
17
+ *
18
+ * @deprecated Pass the vendor's own model to `createAI` from
19
+ * `agents/models/ai-sdk` instead of a plugin plus a slug:
20
+ * `ai(createOpenAI({ apiKey: "cloudflare" }).chat("gpt-5.4"))`.
17
21
  */
18
22
  declare const openai: ProviderPlugin;
19
23
  //#endregion
package/dist/openai.mjs CHANGED
@@ -13,6 +13,10 @@ import { createOpenAI } from "@ai-sdk/openai";
13
13
  * Uses `.chat()` (Chat Completions) deliberately: the bare `openai()` call
14
14
  * (AI SDK v6+) defaults to the Responses API, which the AI Gateway run catalog
15
15
  * does not serve.
16
+ *
17
+ * @deprecated Pass the vendor's own model to `createAI` from
18
+ * `agents/models/ai-sdk` instead of a plugin plus a slug:
19
+ * `ai(createOpenAI({ apiKey: "cloudflare" }).chat("gpt-5.4"))`.
16
20
  */
17
21
  const openai = {
18
22
  wireFormat: "openai",
@@ -1 +1 @@
1
- {"version":3,"file":"openai.mjs","names":[],"sources":["../src/openai.ts"],"sourcesContent":["import { createOpenAI } from \"@ai-sdk/openai\";\nimport type { ProviderPlugin } from \"./gateway-delegate\";\n\n/**\n * OpenAI-wire provider plugin for the gateway delegate. Pass to\n * `createGatewayDelegate({ providers: [openai] })` to handle every\n * OpenAI-compatible provider in one go — `openai/…`, plus the OpenAI-compatible\n * long tail (`deepseek/…`, `xai/…`, `groq/…`, `mistral/…`, `perplexity/…`,\n * `openrouter/…`, `cohere/…`, …). The registry routes each slug to its gateway\n * provider id; this plugin only supplies the response parser.\n *\n * Requires `@ai-sdk/openai` (an optional peer dependency — install it yourself).\n *\n * Uses `.chat()` (Chat Completions) deliberately: the bare `openai()` call\n * (AI SDK v6+) defaults to the Responses API, which the AI Gateway run catalog\n * does not serve.\n */\nexport const openai: ProviderPlugin = {\n\twireFormat: \"openai\",\n\tcreate: ({ modelId, fetch, baseURL }) =>\n\t\t// apiKey is a placeholder — the gateway handles auth (unified billing / BYOK)\n\t\t// and the delegate strips the Authorization header on the gateway path.\n\t\t// baseURL (set by the registry for non-OpenAI openai-wire providers) makes\n\t\t// the generated URL host-strip to the right gateway-native endpoint.\n\t\tcreateOpenAI({ apiKey: \"unused\", fetch, ...(baseURL ? { baseURL } : {}) }).chat(modelId),\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAa,SAAyB;CACrC,YAAY;CACZ,SAAS,EAAE,SAAS,OAAO,cAK1B,aAAa;EAAE,QAAQ;EAAU;EAAO,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;CAAG,CAAC,CAAC,CAAC,KAAK,OAAO;AACzF"}
1
+ {"version":3,"file":"openai.mjs","names":[],"sources":["../src/openai.ts"],"sourcesContent":["import { createOpenAI } from \"@ai-sdk/openai\";\nimport type { ProviderPlugin } from \"./gateway-delegate\";\n\n/**\n * OpenAI-wire provider plugin for the gateway delegate. Pass to\n * `createGatewayDelegate({ providers: [openai] })` to handle every\n * OpenAI-compatible provider in one go — `openai/…`, plus the OpenAI-compatible\n * long tail (`deepseek/…`, `xai/…`, `groq/…`, `mistral/…`, `perplexity/…`,\n * `openrouter/…`, `cohere/…`, …). The registry routes each slug to its gateway\n * provider id; this plugin only supplies the response parser.\n *\n * Requires `@ai-sdk/openai` (an optional peer dependency — install it yourself).\n *\n * Uses `.chat()` (Chat Completions) deliberately: the bare `openai()` call\n * (AI SDK v6+) defaults to the Responses API, which the AI Gateway run catalog\n * does not serve.\n *\n * @deprecated Pass the vendor's own model to `createAI` from\n * `agents/models/ai-sdk` instead of a plugin plus a slug:\n * `ai(createOpenAI({ apiKey: \"cloudflare\" }).chat(\"gpt-5.4\"))`.\n */\nexport const openai: ProviderPlugin = {\n\twireFormat: \"openai\",\n\tcreate: ({ modelId, fetch, baseURL }) =>\n\t\t// apiKey is a placeholder — the gateway handles auth (unified billing / BYOK)\n\t\t// and the delegate strips the Authorization header on the gateway path.\n\t\t// baseURL (set by the registry for non-OpenAI openai-wire providers) makes\n\t\t// the generated URL host-strip to the right gateway-native endpoint.\n\t\tcreateOpenAI({ apiKey: \"unused\", fetch, ...(baseURL ? { baseURL } : {}) }).chat(modelId),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,SAAyB;CACrC,YAAY;CACZ,SAAS,EAAE,SAAS,OAAO,cAK1B,aAAa;EAAE,QAAQ;EAAU;EAAO,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;CAAG,CAAC,CAAC,CAAC,KAAK,OAAO;AACzF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workers-ai-provider",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Workers AI Provider for the vercel AI SDK",
5
5
  "keywords": [
6
6
  "ai",
package/src/anthropic.ts CHANGED
@@ -7,6 +7,10 @@ import type { ProviderPlugin } from "./gateway-delegate";
7
7
  * `"anthropic/<model>"` slugs.
8
8
  *
9
9
  * Requires `@ai-sdk/anthropic` (an optional peer dependency — install it yourself).
10
+ *
11
+ * @deprecated Pass the vendor's own model to `createAI` from
12
+ * `agents/models/ai-sdk` instead of a plugin plus a slug:
13
+ * `ai(createAnthropic({ apiKey: "cloudflare" })("claude-opus-4-8"))`.
10
14
  */
11
15
  export const anthropic: ProviderPlugin = {
12
16
  wireFormat: "anthropic",
@@ -25,6 +25,9 @@ export interface FallbackLeg {
25
25
  * Fallback triggers on `doGenerate`/`doStream` rejection (the dispatch never
26
26
  * produced a stream). Errors that surface *mid-stream* — after content has
27
27
  * already been emitted — are not recoverable here and propagate as-is.
28
+ *
29
+ * @deprecated Use the `fallback` option of `createAI` from
30
+ * `agents/models/ai-sdk`: `ai(primary, { fallback: [secondary, "@cf/…"] })`.
28
31
  */
29
32
  export function createClientFallbackModel(legs: FallbackLeg[]): LanguageModelV4 {
30
33
  if (legs.length === 0) {
@@ -56,6 +56,12 @@ interface AiGatewayRunner {
56
56
  * A `fetch` that dispatches the wrapped provider's request through AI Gateway.
57
57
  * Detects the gateway provider id from the request URL (or uses `config.provider`),
58
58
  * strips the provider host to the endpoint path, and forwards the body verbatim.
59
+ *
60
+ * @deprecated Route the vendor's model with `createAI` from
61
+ * `agents/models/ai-sdk`: `ai(model)` for language models, `ai.routed(model)`
62
+ * for embedding, image, speech and transcription models, on AI Gateway's
63
+ * provider-native path. `vendorKey: "request"` forwards the vendor key, as
64
+ * `byok: true` does here.
59
65
  */
60
66
  export function createGatewayFetch(config: GatewayFetchConfig): typeof globalThis.fetch {
61
67
  if (!config?.binding) {
@@ -130,6 +136,12 @@ export function createGatewayFetch(config: GatewayFetchConfig): typeof globalThi
130
136
  * });
131
137
  * const model = openai("gpt-5");
132
138
  * ```
139
+ *
140
+ * @deprecated Route the vendor's model with `createAI` from
141
+ * `agents/models/ai-sdk`: `ai(model)` for language models, `ai.routed(model)`
142
+ * for embedding, image, speech and transcription models, on AI Gateway's
143
+ * provider-native path. `vendorKey: "request"` forwards the vendor key, as
144
+ * `byok: true` does here.
133
145
  */
134
146
  export function createGatewayProvider<T>(
135
147
  factory: (opts: { apiKey?: string; baseURL?: string; fetch: typeof globalThis.fetch }) => T,
package/src/google.ts CHANGED
@@ -7,6 +7,10 @@ import type { ProviderPlugin } from "./gateway-delegate";
7
7
  * (Google AI Studio) and `"google-vertex/<model>"` slugs.
8
8
  *
9
9
  * Requires `@ai-sdk/google` (an optional peer dependency — install it yourself).
10
+ *
11
+ * @deprecated Pass the vendor's own model to `createAI` from
12
+ * `agents/models/ai-sdk` instead of a plugin plus a slug:
13
+ * `ai(createGoogle({ apiKey: "cloudflare" })("gemini-2.5-flash"))`.
10
14
  */
11
15
  export const google: ProviderPlugin = {
12
16
  wireFormat: "google",
package/src/index.ts CHANGED
@@ -276,6 +276,23 @@ export interface WorkersAI {
276
276
 
277
277
  /**
278
278
  * Create a Workers AI provider instance.
279
+ *
280
+ * @deprecated Use `createAI` from `agents/models/ai-sdk`, with the binding or
281
+ * with an account id and API token (credentials mode's `apiKey`):
282
+ *
283
+ * ```ts
284
+ * import { createAI } from "agents/models/ai-sdk";
285
+ * const ai = createAI({ binding: env.AI }); // or { accountId, apiToken }
286
+ * ai("@cf/zai-org/glm-4.7-flash"); // was workersai("@cf/…")
287
+ * ai("anthropic/claude-opus-4.8"); // was "anthropic/…" + providers; the catalog's spelling
288
+ * ai("dynamic/support"); // dynamic routes, as before
289
+ * ai(createAnthropic({ apiKey: "cloudflare" })("claude-opus-4-8")); // a vendor's own model
290
+ * ai.embedding("@cf/baai/bge-base-en-v1.5"); // .image/.speech/.transcription/.reranking alike
291
+ * ```
292
+ *
293
+ * `vendorKey`, `byokAlias` and `zdr` cover BYOK, and through the binding a
294
+ * catalog stream resumes after a dropped connection. For AI Search, use
295
+ * `ai-search-provider`.
279
296
  */
280
297
  export function createWorkersAI(options: WorkersAISettings): WorkersAI {
281
298
  if (!options.binding && !("accountId" in options && "apiKey" in options)) {
@@ -600,10 +617,22 @@ export function createWorkersAI(options: WorkersAISettings): WorkersAI {
600
617
  // AI Search (formerly AutoRAG)
601
618
  // ---------------------------------------------------------------------------
602
619
 
620
+ /**
621
+ * @deprecated Use `createAISearchNamespace` from `ai-search-provider`, over the
622
+ * `ai_search_namespaces` binding that replaces `env.AI.autorag()`:
623
+ * `createAISearchNamespace({ binding: env.AI_SEARCH }).get("my-instance").chat()`.
624
+ * @see https://developers.cloudflare.com/ai-search/api/migration/workers-binding/
625
+ */
603
626
  export type AISearchSettings = {
604
627
  binding: AutoRAG;
605
628
  };
606
629
 
630
+ /**
631
+ * @deprecated Use `createAISearchNamespace` from `ai-search-provider`, over the
632
+ * `ai_search_namespaces` binding that replaces `env.AI.autorag()`:
633
+ * `createAISearchNamespace({ binding: env.AI_SEARCH }).get("my-instance").chat()`.
634
+ * @see https://developers.cloudflare.com/ai-search/api/migration/workers-binding/
635
+ */
607
636
  export interface AISearchProvider {
608
637
  (settings?: AISearchChatSettings): AISearchChatLanguageModel;
609
638
  /**
@@ -616,7 +645,11 @@ export interface AISearchProvider {
616
645
  * Create an AI Search provider instance.
617
646
  *
618
647
  * AI Search (formerly AutoRAG) is Cloudflare's managed search service.
619
- * @see https://developers.cloudflare.com/ai-search/
648
+ *
649
+ * @deprecated Use `createAISearchNamespace` from `ai-search-provider`, over the
650
+ * `ai_search_namespaces` binding that replaces `env.AI.autorag()`:
651
+ * `createAISearchNamespace({ binding: env.AI_SEARCH }).get("my-instance").chat()`.
652
+ * @see https://developers.cloudflare.com/ai-search/api/migration/workers-binding/
620
653
  */
621
654
  export function createAISearch(
622
655
  options: AISearchSettings,
@@ -662,8 +695,9 @@ export type AutoRAGProvider = AISearchProvider;
662
695
  let autoRAGWarned = false;
663
696
 
664
697
  /**
665
- * @deprecated Use `createAISearch` instead. AutoRAG has been renamed to AI Search.
666
- * @see https://developers.cloudflare.com/ai-search/
698
+ * @deprecated Use `createAISearchNamespace` from `ai-search-provider`. AutoRAG
699
+ * has been renamed to AI Search.
700
+ * @see https://developers.cloudflare.com/ai-search/api/migration/workers-binding/
667
701
  */
668
702
  export function createAutoRAG(options: AISearchSettings): AISearchProvider {
669
703
  if (!autoRAGWarned) {
package/src/openai.ts CHANGED
@@ -14,6 +14,10 @@ import type { ProviderPlugin } from "./gateway-delegate";
14
14
  * Uses `.chat()` (Chat Completions) deliberately: the bare `openai()` call
15
15
  * (AI SDK v6+) defaults to the Responses API, which the AI Gateway run catalog
16
16
  * does not serve.
17
+ *
18
+ * @deprecated Pass the vendor's own model to `createAI` from
19
+ * `agents/models/ai-sdk` instead of a plugin plus a slug:
20
+ * `ai(createOpenAI({ apiKey: "cloudflare" }).chat("gpt-5.4"))`.
17
21
  */
18
22
  export const openai: ProviderPlugin = {
19
23
  wireFormat: "openai",