@ai-sdk/gateway 3.0.100 → 3.0.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/00-ai-gateway.mdx +14 -0
- package/package.json +1 -1
- package/src/gateway-provider-options.ts +8 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -556,6 +556,7 @@ declare const gateway: GatewayProvider;
|
|
|
556
556
|
declare const gatewayProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
557
557
|
only?: string[] | undefined;
|
|
558
558
|
order?: string[] | undefined;
|
|
559
|
+
sort?: "cost" | "ttft" | "tps" | undefined;
|
|
559
560
|
user?: string | undefined;
|
|
560
561
|
tags?: string[] | undefined;
|
|
561
562
|
models?: string[] | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -556,6 +556,7 @@ declare const gateway: GatewayProvider;
|
|
|
556
556
|
declare const gatewayProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
557
557
|
only?: string[] | undefined;
|
|
558
558
|
order?: string[] | undefined;
|
|
559
|
+
sort?: "cost" | "ttft" | "tps" | undefined;
|
|
559
560
|
user?: string | undefined;
|
|
560
561
|
tags?: string[] | undefined;
|
|
561
562
|
models?: string[] | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1624,7 +1624,7 @@ async function getVercelRequestId() {
|
|
|
1624
1624
|
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
1625
1625
|
|
|
1626
1626
|
// src/version.ts
|
|
1627
|
-
var VERSION = true ? "3.0.
|
|
1627
|
+
var VERSION = true ? "3.0.101" : "0.0.0-test";
|
|
1628
1628
|
|
|
1629
1629
|
// src/gateway-provider.ts
|
|
1630
1630
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
package/dist/index.mjs
CHANGED
|
@@ -1666,7 +1666,7 @@ async function getVercelRequestId() {
|
|
|
1666
1666
|
import { withUserAgentSuffix } from "@ai-sdk/provider-utils";
|
|
1667
1667
|
|
|
1668
1668
|
// src/version.ts
|
|
1669
|
-
var VERSION = true ? "3.0.
|
|
1669
|
+
var VERSION = true ? "3.0.101" : "0.0.0-test";
|
|
1670
1670
|
|
|
1671
1671
|
// src/gateway-provider.ts
|
|
1672
1672
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
package/docs/00-ai-gateway.mdx
CHANGED
|
@@ -776,6 +776,20 @@ The following gateway provider options are available:
|
|
|
776
776
|
|
|
777
777
|
Example: `only: ['anthropic', 'vertex']` will only allow routing to Anthropic or Vertex AI.
|
|
778
778
|
|
|
779
|
+
- **sort** _'cost' | 'ttft' | 'tps'_
|
|
780
|
+
|
|
781
|
+
Sorts available providers by a performance or cost metric before routing. The gateway will try the best-scoring provider first and fall back through the rest in sorted order. If unspecified, providers are ordered using the gateway's default system ranking.
|
|
782
|
+
|
|
783
|
+
- `'cost'` — lowest cost first
|
|
784
|
+
- `'ttft'` — lowest time-to-first-token first
|
|
785
|
+
- `'tps'` — highest tokens-per-second first
|
|
786
|
+
|
|
787
|
+
When combined with `order`, the user-specified providers are promoted to the front while remaining providers follow the sorted order.
|
|
788
|
+
|
|
789
|
+
Example: `sort: 'ttft'` will route to the provider with the fastest time-to-first-token.
|
|
790
|
+
|
|
791
|
+
When `sort` is active, the response's `providerMetadata.gateway.routing.sort` object contains the sort option used, the resulting execution order, per-provider metric values, and any providers that were deprioritized.
|
|
792
|
+
|
|
779
793
|
- **models** _string[]_
|
|
780
794
|
|
|
781
795
|
Specifies fallback models to use when the primary model fails or is unavailable. The gateway will try the primary model first (specified in the `model` parameter), then try each model in this array in order until one succeeds.
|
package/package.json
CHANGED
|
@@ -17,6 +17,14 @@ const gatewayProviderOptions = lazySchema(() =>
|
|
|
17
17
|
* Example: `['bedrock', 'anthropic']` will try Amazon Bedrock first, then Anthropic as fallback.
|
|
18
18
|
*/
|
|
19
19
|
order: z.array(z.string()).optional(),
|
|
20
|
+
/**
|
|
21
|
+
* Sort providers by a performance or cost metric before routing.
|
|
22
|
+
*
|
|
23
|
+
* - `'cost'`: lowest cost first
|
|
24
|
+
* - `'ttft'`: lowest time-to-first-token first
|
|
25
|
+
* - `'tps'`: highest tokens-per-second first
|
|
26
|
+
*/
|
|
27
|
+
sort: z.enum(['cost', 'ttft', 'tps']).optional(),
|
|
20
28
|
/**
|
|
21
29
|
* The unique identifier for the end user on behalf of whom the request was made.
|
|
22
30
|
*
|