@broberg/ai-sdk 0.61.0 → 0.61.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/index.d.ts CHANGED
@@ -48,6 +48,8 @@ interface SearchCredentials {
48
48
  braveApiKey?: string;
49
49
  cloudflareAccountId?: string;
50
50
  cloudflareApiToken?: string;
51
+ /** AI Gateway the search runs through. Default "default" (env CLOUDFLARE_GATEWAY_ID). */
52
+ cloudflareGatewayId?: string;
51
53
  tavilyApiKey?: string;
52
54
  }
53
55
  interface SearchCache {
@@ -2332,8 +2334,8 @@ declare const falStubAdapter: ProviderAdapter;
2332
2334
  * wires the live adapters. */
2333
2335
  declare const stubProviders: Record<string, ProviderAdapter>;
2334
2336
 
2335
- declare const VERSION: "0.61.0";
2336
- declare const SDK_TAG: "@broberg/ai-sdk@0.61.0";
2337
+ declare const VERSION: "0.61.1";
2338
+ declare const SDK_TAG: "@broberg/ai-sdk@0.61.1";
2337
2339
 
2338
2340
  /** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
2339
2341
  * per-call override.
package/dist/index.js CHANGED
@@ -58,7 +58,7 @@ async function cloudflareSearch(req, creds, f) {
58
58
  const res = await f(`https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(creds.accountId)}/ai/websearch/`, {
59
59
  method: "POST",
60
60
  headers: { authorization: `Bearer ${creds.apiToken}`, "content-type": "application/json" },
61
- body: JSON.stringify({ query: req.query, provider, limit: Math.min(req.limit ?? CLOUDFLARE_MAX_LIMIT, CLOUDFLARE_MAX_LIMIT) })
61
+ body: JSON.stringify({ query: req.query, provider, limit: Math.min(req.limit ?? CLOUDFLARE_MAX_LIMIT, CLOUDFLARE_MAX_LIMIT), options: { gateway: { id: creds.gatewayId } } })
62
62
  });
63
63
  if (!res.ok) throw Object.assign(new Error(`cloudflare search (${provider}): HTTP ${res.status} ${(await res.text()).slice(0, 200)}`), { status: res.status });
64
64
  const body = await res.json();
@@ -290,7 +290,8 @@ async function callProvider(provider, req, opts) {
290
290
  const apiToken = c.cloudflareApiToken ?? env.CLOUDFLARE_API_TOKEN;
291
291
  if (!accountId) throw new SearchKeyMissingError(provider, "CLOUDFLARE_ACCOUNT_ID");
292
292
  if (!apiToken) throw new SearchKeyMissingError(provider, "CLOUDFLARE_API_TOKEN");
293
- return cloudflareSearch({ ...req, provider }, { accountId, apiToken }, f);
293
+ const gatewayId = c.cloudflareGatewayId ?? env.CLOUDFLARE_GATEWAY_ID ?? "default";
294
+ return cloudflareSearch({ ...req, provider }, { accountId, apiToken, gatewayId }, f);
294
295
  }
295
296
  throw new Error(`search: unknown provider "${String(provider)}"`);
296
297
  }
@@ -3898,8 +3899,8 @@ var aiConfigSchema = z.object({
3898
3899
  import { randomUUID } from "crypto";
3899
3900
 
3900
3901
  // src/version.ts
3901
- var VERSION = "0.61.0";
3902
- var SDK_TAG = "@broberg/ai-sdk@0.61.0";
3902
+ var VERSION = "0.61.1";
3903
+ var SDK_TAG = "@broberg/ai-sdk@0.61.1";
3903
3904
 
3904
3905
  // src/cost/sinks/upmetrics.ts
3905
3906
  function isRetryableStatus(status) {