@ai-sdk/perplexity 5.0.15 → 5.0.17

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @ai-sdk/perplexity
2
2
 
3
+ ## 5.0.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 4b4c125: Defer construction of provider validation schemas until first use to reduce package import time.
8
+ - Updated dependencies [b089ce8]
9
+ - Updated dependencies [39a776b]
10
+ - @ai-sdk/provider-utils@5.0.65
11
+
12
+ ## 5.0.16
13
+
14
+ ### Patch Changes
15
+
16
+ - 0c2a9de: Add `maxOutputTokens` and `reasoning` to experimental decision calls and forward them to language-model-backed decisions. Language-model adapters keep reasoning disabled when omitted. Native decision providers warn when either setting is unsupported.
17
+ - Updated dependencies [0c2a9de]
18
+ - Updated dependencies [200c47f]
19
+ - @ai-sdk/provider@4.0.31
20
+ - @ai-sdk/provider-utils@5.0.64
21
+
3
22
  ## 5.0.15
4
23
 
5
24
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { EmbeddingModelV4, Experimental_DecisionModelV4, LanguageModelV4, ProviderV4 } from "@ai-sdk/provider";
2
- import { FetchFunction } from "@ai-sdk/provider-utils";
3
- import { z } from "zod/v4";
2
+ import { FetchFunction, InferSchema } from "@ai-sdk/provider-utils";
4
3
  //#region src/perplexity-decision-model-options.d.ts
5
4
  type PerplexityDecisionModelId = 'pplx-decider-v1.2' | 'pplx-decider-flash-v1.2' | 'pplx-decider-latest' | 'pplx-decider-flash-latest' | 'perplexity/pplx-decider-latest' | 'perplexity/pplx-decider-flash-latest' | 'pplx-decider-v1.1-27b' | 'pplx-decider-v1-27b' | (string & {});
6
5
  /** Perplexity decision models do not support provider-specific options. */
@@ -8,14 +7,11 @@ type PerplexityDecisionModelOptions = Record<string, never>;
8
7
  //#endregion
9
8
  //#region src/perplexity-embedding-model-options.d.ts
10
9
  type PerplexityEmbeddingModelId = 'pplx-embed-v1-0.6b' | 'pplx-embed-v1-4b' | (string & {});
11
- declare const perplexityEmbeddingModelOptions: z.ZodObject<{
12
- dimensions: z.ZodOptional<z.ZodNumber>;
13
- encodingFormat: z.ZodOptional<z.ZodEnum<{
14
- base64_int8: "base64_int8";
15
- base64_binary: "base64_binary";
16
- }>>;
17
- }, z.core.$strip>;
18
- type PerplexityEmbeddingModelOptions = z.infer<typeof perplexityEmbeddingModelOptions>;
10
+ declare const perplexityEmbeddingModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
11
+ dimensions?: number | undefined;
12
+ encodingFormat?: "base64_int8" | "base64_binary" | undefined;
13
+ }>;
14
+ type PerplexityEmbeddingModelOptions = InferSchema<typeof perplexityEmbeddingModelOptions>;
19
15
  //#endregion
20
16
  //#region src/perplexity-options.d.ts
21
17
  type PerplexityAgentPreset = 'fast' | 'low' | 'medium' | 'high' | 'xhigh';
@@ -69,111 +65,86 @@ export declare function createPerplexity(options?: PerplexityProviderSettings):
69
65
  export declare const perplexity: PerplexityProvider;
70
66
  //#endregion
71
67
  //#region src/perplexity-language-model-options.d.ts
72
- declare const perplexityLanguageModelOptions: z.ZodObject<{
73
- /** Top-level Agent API instructions. */
74
- instructions: z.ZodOptional<z.ZodString>;
75
- /**
76
- * Native Agent API tools. AI SDK function tools can also be supplied through
77
- * the top-level `tools` option on `generateText` and `streamText`.
78
- */
79
- tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
80
- type: z.ZodLiteral<"web_search">;
81
- filters: z.ZodOptional<z.ZodObject<{
82
- search_domain_filter: z.ZodOptional<z.ZodArray<z.ZodString>>;
83
- search_recency_filter: z.ZodOptional<z.ZodEnum<{
84
- hour: "hour";
85
- day: "day";
86
- week: "week";
87
- month: "month";
88
- year: "year";
89
- }>>;
90
- search_after_date_filter: z.ZodOptional<z.ZodString>;
91
- search_before_date_filter: z.ZodOptional<z.ZodString>;
92
- last_updated_after_filter: z.ZodOptional<z.ZodString>;
93
- last_updated_before_filter: z.ZodOptional<z.ZodString>;
94
- }, z.core.$loose>>;
95
- max_results: z.ZodOptional<z.ZodNumber>;
96
- max_tokens: z.ZodOptional<z.ZodNumber>;
97
- max_tokens_per_page: z.ZodOptional<z.ZodNumber>;
98
- search_context_size: z.ZodOptional<z.ZodEnum<{
99
- low: "low";
100
- medium: "medium";
101
- high: "high";
102
- }>>;
103
- user_location: z.ZodOptional<z.ZodObject<{
104
- latitude: z.ZodOptional<z.ZodNumber>;
105
- longitude: z.ZodOptional<z.ZodNumber>;
106
- country: z.ZodOptional<z.ZodString>;
107
- city: z.ZodOptional<z.ZodString>;
108
- region: z.ZodOptional<z.ZodString>;
109
- }, z.core.$loose>>;
110
- }, z.core.$loose>, z.ZodObject<{
111
- type: z.ZodLiteral<"fetch_url">;
112
- max_urls: z.ZodOptional<z.ZodNumber>;
113
- }, z.core.$loose>, z.ZodObject<{
114
- type: z.ZodLiteral<"people_search">;
115
- }, z.core.$loose>, z.ZodObject<{
116
- type: z.ZodLiteral<"finance_search">;
117
- }, z.core.$loose>, z.ZodObject<{
118
- type: z.ZodLiteral<"sandbox">;
119
- }, z.core.$loose>, z.ZodObject<{
120
- type: z.ZodLiteral<"mcp">;
121
- server_label: z.ZodString;
122
- server_url: z.ZodString;
123
- allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
124
- authorization: z.ZodOptional<z.ZodString>;
125
- defer_loading: z.ZodOptional<z.ZodBoolean>;
126
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
127
- }, z.core.$loose>, z.ZodObject<{
128
- type: z.ZodLiteral<"connector">;
129
- id: z.ZodString;
130
- server_label: z.ZodString;
131
- server_description: z.ZodOptional<z.ZodString>;
132
- allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
133
- }, z.core.$loose>]>>>;
134
- /** A fallback model list for Agent API routing. */
135
- models: z.ZodOptional<z.ZodArray<z.ZodString>>;
136
- /** Maximum number of agentic steps. */
137
- max_steps: z.ZodOptional<z.ZodNumber>;
138
- /** Maximum number of native tool calls. */
139
- max_tool_calls: z.ZodOptional<z.ZodNumber>;
140
- /** Continue a conversation from an earlier Agent API response. */
141
- previous_response_id: z.ZodOptional<z.ZodString>;
142
- /**
143
- * Whether the response can be retrieved later. Setting this to false does
144
- * not disable persistence or prevent previous_response_id continuations.
145
- */
146
- store: z.ZodOptional<z.ZodBoolean>;
147
- /** Preferred response language as an ISO 639-1 language code. */
148
- language_preference: z.ZodOptional<z.ZodString>;
149
- /** Agent API reasoning configuration. */
150
- reasoning: z.ZodOptional<z.ZodObject<{
151
- effort: z.ZodOptional<z.ZodEnum<{
152
- low: "low";
153
- medium: "medium";
154
- high: "high";
155
- minimal: "minimal";
156
- xhigh: "xhigh";
157
- }>>;
158
- }, z.core.$loose>>;
159
- /** Agent API skill configuration. */
160
- skills: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
161
- type: z.ZodLiteral<"builtin">;
162
- name: z.ZodEnum<{
163
- office: "office";
164
- "office/docx": "office/docx";
165
- "office/pdf": "office/pdf";
166
- "office/pptx": "office/pptx";
167
- "office/xlsx": "office/xlsx";
168
- }>;
169
- }, z.core.$loose>, z.ZodObject<{
170
- type: z.ZodLiteral<"inline">;
171
- name: z.ZodString;
172
- description: z.ZodString;
173
- instructions: z.ZodString;
174
- }, z.core.$loose>]>>>;
175
- }, z.core.$loose>;
176
- type PerplexityLanguageModelOptions = z.infer<typeof perplexityLanguageModelOptions>;
68
+ declare const perplexityLanguageModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
69
+ [x: string]: unknown;
70
+ instructions?: string | undefined;
71
+ tools?: ({
72
+ [x: string]: unknown;
73
+ type: "web_search";
74
+ filters?: {
75
+ [x: string]: unknown;
76
+ search_domain_filter?: string[] | undefined;
77
+ search_recency_filter?: "hour" | "day" | "week" | "month" | "year" | undefined;
78
+ search_after_date_filter?: string | undefined;
79
+ search_before_date_filter?: string | undefined;
80
+ last_updated_after_filter?: string | undefined;
81
+ last_updated_before_filter?: string | undefined;
82
+ } | undefined;
83
+ max_results?: number | undefined;
84
+ max_tokens?: number | undefined;
85
+ max_tokens_per_page?: number | undefined;
86
+ search_context_size?: "low" | "medium" | "high" | undefined;
87
+ user_location?: {
88
+ [x: string]: unknown;
89
+ latitude?: number | undefined;
90
+ longitude?: number | undefined;
91
+ country?: string | undefined;
92
+ city?: string | undefined;
93
+ region?: string | undefined;
94
+ } | undefined;
95
+ } | {
96
+ [x: string]: unknown;
97
+ type: "fetch_url";
98
+ max_urls?: number | undefined;
99
+ } | {
100
+ [x: string]: unknown;
101
+ type: "people_search";
102
+ } | {
103
+ [x: string]: unknown;
104
+ type: "finance_search";
105
+ } | {
106
+ [x: string]: unknown;
107
+ type: "sandbox";
108
+ } | {
109
+ [x: string]: unknown;
110
+ type: "mcp";
111
+ server_label: string;
112
+ server_url: string;
113
+ allowed_tools?: string[] | undefined;
114
+ authorization?: string | undefined;
115
+ defer_loading?: boolean | undefined;
116
+ headers?: Record<string, string> | undefined;
117
+ } | {
118
+ [x: string]: unknown;
119
+ type: "connector";
120
+ id: string;
121
+ server_label: string;
122
+ server_description?: string | undefined;
123
+ allowed_tools?: string[] | undefined;
124
+ })[] | undefined;
125
+ models?: string[] | undefined;
126
+ max_steps?: number | undefined;
127
+ max_tool_calls?: number | undefined;
128
+ previous_response_id?: string | undefined;
129
+ store?: boolean | undefined;
130
+ language_preference?: string | undefined;
131
+ reasoning?: {
132
+ [x: string]: unknown;
133
+ effort?: "low" | "medium" | "high" | "minimal" | "xhigh" | undefined;
134
+ } | undefined;
135
+ skills?: ({
136
+ [x: string]: unknown;
137
+ type: "builtin";
138
+ name: "office" | "office/docx" | "office/pdf" | "office/pptx" | "office/xlsx";
139
+ } | {
140
+ [x: string]: unknown;
141
+ type: "inline";
142
+ name: string;
143
+ description: string;
144
+ instructions: string;
145
+ })[] | undefined;
146
+ }>;
147
+ type PerplexityLanguageModelOptions = InferSchema<typeof perplexityLanguageModelOptions>;
177
148
  //#endregion
178
149
  //#region src/version.d.ts
179
150
  export declare const VERSION: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["DecisionModelV4"],"sources":["../src/perplexity-decision-model-options.ts","../src/perplexity-embedding-model-options.ts","../src/perplexity-options.ts","../src/perplexity-provider.ts","../src/perplexity-language-model-options.ts","../src/version.ts"],"mappings":";;;;KAAY;;KAYA,iCAAiC;;;KCTjC;cAKC,iCAA+B,EAAA;;;;;;GAe1C,EAAA,KAAA;KAEU,kCAAkC,EAAE,aACvC;;;KC1BG;KAOA,4BACR;;;UCca,2BAA2B;;EAE1C,cAAc,SAAS,4BAA4BA;;;;GAKlD,SAAS,4BAA4B;;;;EAKtC,cAAc,SAAS,4BAA4B;;;;EAKnD,UAAU,SAAS,6BAA6B;;;;EAKhD,eAAe,SAAS,6BAA6B;;;;EAKrD,mBAAmB,SAAS,6BAA6B;;UAG1C;;;;EAIf;;;;EAKA;;;;EAKA,UAAU;;;;;EAMV,QAAQ;;wBAGM,iBACd,UAAS,6BACR;qBA2DU,YAAU;;;cC9EV,gCAA8B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DzC,EAAA,KAAA;KAEU,iCAAiC,EAAE,aACtC;;;qBCxHI"}
1
+ {"version":3,"file":"index.d.ts","names":["DecisionModelV4"],"sources":["../src/perplexity-decision-model-options.ts","../src/perplexity-embedding-model-options.ts","../src/perplexity-options.ts","../src/perplexity-provider.ts","../src/perplexity-language-model-options.ts","../src/version.ts"],"mappings":";;;KAAY;;KAYA,iCAAiC;;;KCJjC;cAKC,kEAA+B;;;;KAqBhC,kCAAkC,mBACrC;;;KCnCG;KAOA,4BACR;;;UCca,2BAA2B;;EAE1C,cAAc,SAAS,4BAA4BA;;;;GAKlD,SAAS,4BAA4B;;;;EAKtC,cAAc,SAAS,4BAA4B;;;;EAKnD,UAAU,SAAS,6BAA6B;;;;EAKhD,eAAe,SAAS,6BAA6B;;;;EAKrD,mBAAmB,SAAS,6BAA6B;;UAG1C;;;;EAIf;;;;EAKA;;;;EAKA,UAAU;;;;;EAMV,QAAQ;;wBAGM,iBACd,UAAS,6BACR;qBA2DU,YAAU;;;cCrEV,iEAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAA9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqED,iCAAiC,mBACpC;;;qBCvII"}
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { APICallError, Experimental_DecisionUnsupportedQuestionTypeError, InvalidArgumentError, InvalidResponseDataError, NoSuchModelError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
2
- import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertBase64ToUint8Array, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createNullLanguageModelUsage, detectMediaType, generateId, getTopLevelMediaType, isCustomReasoning, isFullMediaType, loadApiKey, mapReasoningToProviderEffort, parseProviderOptions, postJsonToApi, resolve, resolveFullMediaType, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash } from "@ai-sdk/provider-utils";
2
+ import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertBase64ToUint8Array, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createNullLanguageModelUsage, detectMediaType, generateId, getTopLevelMediaType, isCustomReasoning, isFullMediaType, lazySchema, loadApiKey, mapReasoningToProviderEffort, parseProviderOptions, postJsonToApi, resolve, resolveFullMediaType, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
3
3
  import { z } from "zod/v4";
4
4
  //#region src/perplexity-embedding-model-options.ts
5
- const perplexityEmbeddingModelOptions = z.object({
5
+ const perplexityEmbeddingModelOptions = lazySchema(() => zodSchema(z.object({
6
6
  /**
7
7
  * The number of dimensions the resulting output embeddings should have
8
8
  * (Matryoshka truncation). Ranges from 128 up to the model's full size
@@ -16,7 +16,7 @@ const perplexityEmbeddingModelOptions = z.object({
16
16
  * - `base64_binary`: packed bits per byte (0-255), compare via Hamming distance.
17
17
  */
18
18
  encodingFormat: z.enum(["base64_int8", "base64_binary"]).optional()
19
- });
19
+ })));
20
20
  //#endregion
21
21
  //#region src/convert-perplexity-usage.ts
22
22
  function convertPerplexityUsage(usage) {
@@ -177,7 +177,7 @@ function mapPerplexityFinishReason({ status, incompleteReason, hasFunctionCall }
177
177
  }
178
178
  //#endregion
179
179
  //#region src/perplexity-agent-api.ts
180
- const perplexitySearchResultSchema = z.looseObject({
180
+ const perplexitySearchResultSchema = () => z.looseObject({
181
181
  id: z.number().optional(),
182
182
  title: z.string(),
183
183
  url: z.string(),
@@ -186,12 +186,12 @@ const perplexitySearchResultSchema = z.looseObject({
186
186
  last_updated: z.string().nullish(),
187
187
  source: z.string().optional()
188
188
  });
189
- const perplexityFetchedContentSchema = z.looseObject({
189
+ const perplexityFetchedContentSchema = () => z.looseObject({
190
190
  title: z.string(),
191
191
  url: z.string(),
192
192
  snippet: z.string().optional()
193
193
  });
194
- const perplexityContentPartSchema = z.looseObject({
194
+ const perplexityContentPartSchema = () => z.looseObject({
195
195
  type: z.string(),
196
196
  text: z.string().optional(),
197
197
  annotations: z.array(z.looseObject({
@@ -206,19 +206,19 @@ const handledOutputTypes = [
206
206
  "fetch_url_results",
207
207
  "function_call"
208
208
  ];
209
- const perplexityOutputItemSchema = z.union([
209
+ const perplexityOutputItemSchema = () => z.union([
210
210
  z.looseObject({
211
211
  type: z.literal("message"),
212
212
  id: z.string().nullish(),
213
- content: z.array(perplexityContentPartSchema).nullish()
213
+ content: z.array(perplexityContentPartSchema()).nullish()
214
214
  }),
215
215
  z.looseObject({
216
216
  type: z.literal("search_results"),
217
- results: z.array(perplexitySearchResultSchema).nullish()
217
+ results: z.array(perplexitySearchResultSchema()).nullish()
218
218
  }),
219
219
  z.looseObject({
220
220
  type: z.literal("fetch_url_results"),
221
- contents: z.array(perplexityFetchedContentSchema).nullish()
221
+ contents: z.array(perplexityFetchedContentSchema()).nullish()
222
222
  }),
223
223
  z.looseObject({
224
224
  type: z.literal("function_call"),
@@ -230,7 +230,7 @@ const perplexityOutputItemSchema = z.union([
230
230
  }),
231
231
  z.object({ type: z.string().refine((type) => !handledOutputTypes.includes(type)) }).transform(() => ({ type: "unhandled" }))
232
232
  ]);
233
- const perplexityCostSchema = z.looseObject({
233
+ const perplexityCostSchema = () => z.looseObject({
234
234
  currency: z.string().optional(),
235
235
  input_cost: z.number().optional(),
236
236
  output_cost: z.number().optional(),
@@ -239,7 +239,7 @@ const perplexityCostSchema = z.looseObject({
239
239
  cache_read_cost: z.number().nullish(),
240
240
  tool_calls_cost: z.number().nullish()
241
241
  });
242
- const perplexityUsageSchema = z.looseObject({
242
+ const perplexityUsageSchema = () => z.looseObject({
243
243
  input_tokens: z.number(),
244
244
  output_tokens: z.number(),
245
245
  total_tokens: z.number(),
@@ -250,14 +250,14 @@ const perplexityUsageSchema = z.looseObject({
250
250
  }).nullish(),
251
251
  output_tokens_details: z.looseObject({ reasoning_tokens: z.number().optional() }).nullish(),
252
252
  tool_calls_details: z.record(z.string(), z.looseObject({ invocation: z.number().optional() })).nullish(),
253
- cost: perplexityCostSchema.nullish()
253
+ cost: perplexityCostSchema().nullish()
254
254
  });
255
- const perplexityAgentResponseSchema = z.looseObject({
255
+ const perplexityAgentResponseSchema = () => z.looseObject({
256
256
  id: z.string(),
257
257
  created_at: z.number(),
258
258
  model: z.string(),
259
259
  object: z.literal("response"),
260
- output: z.array(perplexityOutputItemSchema),
260
+ output: z.array(perplexityOutputItemSchema()),
261
261
  status: z.string(),
262
262
  incomplete_details: z.looseObject({ reason: z.string() }).nullish(),
263
263
  error: z.looseObject({
@@ -265,13 +265,14 @@ const perplexityAgentResponseSchema = z.looseObject({
265
265
  message: z.string(),
266
266
  type: z.string().optional()
267
267
  }).nullish(),
268
- usage: perplexityUsageSchema.nullish()
268
+ usage: perplexityUsageSchema().nullish()
269
269
  });
270
- const perplexityAgentChunkSchema = z.looseObject({
270
+ const perplexityAgentResponseSchemaValidator = lazySchema(() => zodSchema(perplexityAgentResponseSchema()));
271
+ const perplexityAgentChunkSchema = lazySchema(() => zodSchema(z.looseObject({
271
272
  type: z.string(),
272
273
  sequence_number: z.number().nullish(),
273
- response: perplexityAgentResponseSchema.nullish(),
274
- item: perplexityOutputItemSchema.nullish(),
274
+ response: perplexityAgentResponseSchema().nullish(),
275
+ item: perplexityOutputItemSchema().nullish(),
275
276
  output_index: z.number().nullish(),
276
277
  item_id: z.string().nullish(),
277
278
  content_index: z.number().nullish(),
@@ -280,15 +281,15 @@ const perplexityAgentChunkSchema = z.looseObject({
280
281
  thought: z.string().nullish(),
281
282
  queries: z.array(z.string()).nullish(),
282
283
  urls: z.array(z.string()).nullish(),
283
- results: z.array(perplexitySearchResultSchema).nullish(),
284
- contents: z.array(perplexityFetchedContentSchema).nullish(),
284
+ results: z.array(perplexitySearchResultSchema()).nullish(),
285
+ contents: z.array(perplexityFetchedContentSchema()).nullish(),
285
286
  error: z.looseObject({
286
287
  code: z.string().nullish(),
287
288
  message: z.string(),
288
289
  type: z.string().nullish()
289
290
  }).nullish()
290
- });
291
- const perplexityErrorSchema = z.looseObject({
291
+ })));
292
+ const perplexityErrorSchema = lazySchema(() => zodSchema(z.looseObject({
292
293
  error: z.union([z.string(), z.looseObject({
293
294
  code: z.union([z.string(), z.number()]).nullish(),
294
295
  message: z.string().nullish(),
@@ -296,7 +297,7 @@ const perplexityErrorSchema = z.looseObject({
296
297
  })]).optional(),
297
298
  detail: z.union([z.string(), z.array(z.looseObject({ msg: z.string() }))]).optional(),
298
299
  message: z.string().optional()
299
- });
300
+ })));
300
301
  function perplexityErrorToMessage(data) {
301
302
  if (typeof data.error === "string") return data.error;
302
303
  if (data.error != null) return data.error.message ?? data.error.type ?? "unknown error";
@@ -306,14 +307,14 @@ function perplexityErrorToMessage(data) {
306
307
  }
307
308
  //#endregion
308
309
  //#region src/perplexity-language-model-options.ts
309
- const userLocationSchema = z.looseObject({
310
+ const userLocationSchema = () => z.looseObject({
310
311
  latitude: z.number().optional(),
311
312
  longitude: z.number().optional(),
312
313
  country: z.string().optional(),
313
314
  city: z.string().optional(),
314
315
  region: z.string().optional()
315
316
  });
316
- const webSearchFiltersSchema = z.looseObject({
317
+ const webSearchFiltersSchema = () => z.looseObject({
317
318
  search_domain_filter: z.array(z.string()).optional(),
318
319
  search_recency_filter: z.enum([
319
320
  "hour",
@@ -327,9 +328,9 @@ const webSearchFiltersSchema = z.looseObject({
327
328
  last_updated_after_filter: z.string().optional(),
328
329
  last_updated_before_filter: z.string().optional()
329
330
  });
330
- const webSearchToolSchema = z.looseObject({
331
+ const webSearchToolSchema = () => z.looseObject({
331
332
  type: z.literal("web_search"),
332
- filters: webSearchFiltersSchema.optional(),
333
+ filters: webSearchFiltersSchema().optional(),
333
334
  max_results: z.number().int().positive().optional(),
334
335
  max_tokens: z.number().optional(),
335
336
  max_tokens_per_page: z.number().optional(),
@@ -338,10 +339,10 @@ const webSearchToolSchema = z.looseObject({
338
339
  "medium",
339
340
  "high"
340
341
  ]).optional(),
341
- user_location: userLocationSchema.optional()
342
+ user_location: userLocationSchema().optional()
342
343
  });
343
- const nativeToolSchema = z.union([
344
- webSearchToolSchema,
344
+ const nativeToolSchema = () => z.union([
345
+ webSearchToolSchema(),
345
346
  z.looseObject({
346
347
  type: z.literal("fetch_url"),
347
348
  max_urls: z.number().optional()
@@ -366,14 +367,14 @@ const nativeToolSchema = z.union([
366
367
  allowed_tools: z.array(z.string()).optional()
367
368
  })
368
369
  ]);
369
- const perplexityLanguageModelOptions = z.looseObject({
370
+ const perplexityLanguageModelOptions = lazySchema(() => zodSchema(z.looseObject({
370
371
  /** Top-level Agent API instructions. */
371
372
  instructions: z.string().optional(),
372
373
  /**
373
374
  * Native Agent API tools. AI SDK function tools can also be supplied through
374
375
  * the top-level `tools` option on `generateText` and `streamText`.
375
376
  */
376
- tools: z.array(nativeToolSchema).optional(),
377
+ tools: z.array(nativeToolSchema()).optional(),
377
378
  /** A fallback model list for Agent API routing. */
378
379
  models: z.array(z.string()).optional(),
379
380
  /** Maximum number of agentic steps. */
@@ -413,7 +414,7 @@ const perplexityLanguageModelOptions = z.looseObject({
413
414
  description: z.string(),
414
415
  instructions: z.string()
415
416
  })])).optional()
416
- });
417
+ })));
417
418
  //#endregion
418
419
  //#region src/perplexity-prepare-tools.ts
419
420
  function preparePerplexityTools({ tools, toolChoice }) {
@@ -626,7 +627,7 @@ var PerplexityLanguageModel = class PerplexityLanguageModel {
626
627
  errorSchema: perplexityErrorSchema,
627
628
  errorToMessage: perplexityErrorToMessage
628
629
  }),
629
- successfulResponseHandler: createJsonResponseHandler(perplexityAgentResponseSchema),
630
+ successfulResponseHandler: createJsonResponseHandler(perplexityAgentResponseSchemaValidator),
630
631
  abortSignal: options.abortSignal,
631
632
  fetch: this.config.fetch
632
633
  });
@@ -1078,7 +1079,7 @@ function decodeEmbedding(base64, encodingFormat) {
1078
1079
  }
1079
1080
  return Array.from(bytes);
1080
1081
  }
1081
- const perplexityEmbeddingResponseSchema = z.object({
1082
+ const perplexityEmbeddingResponseSchema = lazySchema(() => zodSchema(z.object({
1082
1083
  data: z.array(z.object({ embedding: z.string() })),
1083
1084
  usage: z.object({
1084
1085
  prompt_tokens: z.number(),
@@ -1088,7 +1089,7 @@ const perplexityEmbeddingResponseSchema = z.object({
1088
1089
  currency: z.string().nullish()
1089
1090
  }).nullish()
1090
1091
  }).nullish()
1091
- });
1092
+ })));
1092
1093
  //#endregion
1093
1094
  //#region src/convert-to-perplexity-decision-state.ts
1094
1095
  function convertToPerplexityDecisionState(state) {
@@ -1157,7 +1158,7 @@ var DecisionPerplexityModel = class DecisionPerplexityModel {
1157
1158
  static [WORKFLOW_DESERIALIZE](options) {
1158
1159
  return new DecisionPerplexityModel(options.modelId, options.config);
1159
1160
  }
1160
- async doDecide({ state, questions, headers, abortSignal, providerOptions }) {
1161
+ async doDecide({ state, questions, maxOutputTokens, reasoning, headers, abortSignal, providerOptions }) {
1161
1162
  const entries = Object.entries(questions);
1162
1163
  if (entries.length === 0 || entries.length > 128) throw new InvalidArgumentError({
1163
1164
  argument: "questions",
@@ -1241,10 +1242,20 @@ var DecisionPerplexityModel = class DecisionPerplexityModel {
1241
1242
  inputTokens: response.usage.input_tokens ?? void 0,
1242
1243
  outputTokens: response.usage.output_tokens ?? void 0
1243
1244
  },
1244
- warnings: Object.keys(providerOptions?.perplexity ?? {}).map((option) => ({
1245
- type: "unsupported",
1246
- feature: `providerOptions.perplexity.${option}`
1247
- })),
1245
+ warnings: [
1246
+ ...maxOutputTokens != null ? [{
1247
+ type: "unsupported",
1248
+ feature: "maxOutputTokens"
1249
+ }] : [],
1250
+ ...reasoning != null ? [{
1251
+ type: "unsupported",
1252
+ feature: "reasoning"
1253
+ }] : [],
1254
+ ...Object.keys(providerOptions?.perplexity ?? {}).map((option) => ({
1255
+ type: "unsupported",
1256
+ feature: `providerOptions.perplexity.${option}`
1257
+ }))
1258
+ ],
1248
1259
  providerMetadata: { perplexity: {
1249
1260
  confidence: Object.fromEntries(Object.entries(response.answers).flatMap(([id, answer]) => answer.type !== "noul" && answer.confidence != null ? [[id, answer.confidence]] : [])),
1250
1261
  legend: Object.fromEntries(Object.entries(response.answers).flatMap(([id, answer]) => answer.type === "score" && answer.legend != null ? [[id, answer.legend]] : []))
@@ -1258,25 +1269,25 @@ var DecisionPerplexityModel = class DecisionPerplexityModel {
1258
1269
  };
1259
1270
  }
1260
1271
  };
1261
- const probability = z.number().min(0).max(1);
1262
- const perplexityDecisionResponseSchema = z.object({
1272
+ const probability = () => z.number().min(0).max(1);
1273
+ const perplexityDecisionResponseSchema = lazySchema(() => zodSchema(z.object({
1263
1274
  model: z.string().nullish(),
1264
1275
  answers: z.record(z.string(), z.discriminatedUnion("type", [
1265
1276
  z.object({
1266
1277
  type: z.literal("noul"),
1267
- noul: probability
1278
+ noul: probability()
1268
1279
  }),
1269
1280
  z.object({
1270
1281
  type: z.literal("choice"),
1271
1282
  choice: z.string(),
1272
- probabilities: z.record(z.string(), probability),
1273
- confidence: probability.nullish()
1283
+ probabilities: z.record(z.string(), probability()),
1284
+ confidence: probability().nullish()
1274
1285
  }),
1275
1286
  z.object({
1276
1287
  type: z.literal("score"),
1277
1288
  score: z.number(),
1278
- probabilities: z.record(z.string(), probability),
1279
- confidence: probability.nullish(),
1289
+ probabilities: z.record(z.string(), probability()),
1290
+ confidence: probability().nullish(),
1280
1291
  legend: z.record(z.string(), z.json()).nullish()
1281
1292
  })
1282
1293
  ])),
@@ -1284,10 +1295,10 @@ const perplexityDecisionResponseSchema = z.object({
1284
1295
  input_tokens: z.number().nullish(),
1285
1296
  output_tokens: z.number().nullish()
1286
1297
  }).nullish()
1287
- });
1298
+ })));
1288
1299
  //#endregion
1289
1300
  //#region src/version.ts
1290
- const VERSION = "5.0.15";
1301
+ const VERSION = "5.0.17";
1291
1302
  //#endregion
1292
1303
  //#region src/perplexity-provider.ts
1293
1304
  function createPerplexity(options = {}) {