@ai-sdk/gateway 4.0.0-beta.45 → 4.0.0-beta.46
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
|
@@ -554,6 +554,7 @@ declare const gateway: GatewayProvider;
|
|
|
554
554
|
declare const gatewayProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
555
555
|
only?: string[] | undefined;
|
|
556
556
|
order?: string[] | undefined;
|
|
557
|
+
sort?: "cost" | "ttft" | "tps" | undefined;
|
|
557
558
|
user?: string | undefined;
|
|
558
559
|
tags?: string[] | undefined;
|
|
559
560
|
models?: string[] | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -554,6 +554,7 @@ declare const gateway: GatewayProvider;
|
|
|
554
554
|
declare const gatewayProviderOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
555
555
|
only?: string[] | undefined;
|
|
556
556
|
order?: string[] | undefined;
|
|
557
|
+
sort?: "cost" | "ttft" | "tps" | undefined;
|
|
557
558
|
user?: string | undefined;
|
|
558
559
|
tags?: string[] | undefined;
|
|
559
560
|
models?: string[] | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1609,7 +1609,7 @@ async function getVercelRequestId() {
|
|
|
1609
1609
|
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
1610
1610
|
|
|
1611
1611
|
// src/version.ts
|
|
1612
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1612
|
+
var VERSION = true ? "4.0.0-beta.46" : "0.0.0-test";
|
|
1613
1613
|
|
|
1614
1614
|
// src/gateway-provider.ts
|
|
1615
1615
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
package/dist/index.mjs
CHANGED
|
@@ -1651,7 +1651,7 @@ async function getVercelRequestId() {
|
|
|
1651
1651
|
import { withUserAgentSuffix } from "@ai-sdk/provider-utils";
|
|
1652
1652
|
|
|
1653
1653
|
// src/version.ts
|
|
1654
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1654
|
+
var VERSION = true ? "4.0.0-beta.46" : "0.0.0-test";
|
|
1655
1655
|
|
|
1656
1656
|
// src/gateway-provider.ts
|
|
1657
1657
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
package/docs/00-ai-gateway.mdx
CHANGED
|
@@ -778,6 +778,20 @@ The following gateway provider options are available:
|
|
|
778
778
|
|
|
779
779
|
Example: `only: ['anthropic', 'vertex']` will only allow routing to Anthropic or Vertex AI.
|
|
780
780
|
|
|
781
|
+
- **sort** _'cost' | 'ttft' | 'tps'_
|
|
782
|
+
|
|
783
|
+
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.
|
|
784
|
+
|
|
785
|
+
- `'cost'` — lowest input cost per token first
|
|
786
|
+
- `'ttft'` — lowest time-to-first-token first
|
|
787
|
+
- `'tps'` — highest tokens-per-second first
|
|
788
|
+
|
|
789
|
+
When combined with `order`, the user-specified providers are promoted to the front while remaining providers follow the sorted order.
|
|
790
|
+
|
|
791
|
+
Example: `sort: 'ttft'` will route to the provider with the fastest time-to-first-token.
|
|
792
|
+
|
|
793
|
+
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.
|
|
794
|
+
|
|
781
795
|
- **models** _string[]_
|
|
782
796
|
|
|
783
797
|
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 input 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
|
*
|