@ai-sdk/perplexity 3.0.63 → 3.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @ai-sdk/perplexity
2
2
 
3
+ ## 3.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [29dc427]
8
+ - @ai-sdk/provider-utils@4.0.56
9
+
10
+ ## 3.1.0
11
+
12
+ ### Minor Changes
13
+
14
+ - 289e3cf: BREAKING: Migrate language generation from the Sonar Chat Completions API (supported by Perplexity only until September 27, 2026) to the Agent API. Replace Sonar model IDs and provider options with Agent API presets, models, and tools. The new API changes request and response metadata, raw stream events, usage and cost data, and does not support Sonar PDF input or image and video results. Reasoning effort is configured through `providerOptions.perplexity.reasoning`. Embeddings are unchanged. Agent API stream events with `null` fields are accepted.
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [3983fea]
19
+ - @ai-sdk/provider@3.0.18
20
+ - @ai-sdk/provider-utils@4.0.55
21
+
3
22
  ## 3.0.63
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -1,18 +1,15 @@
1
1
  # AI SDK - Perplexity Provider
2
2
 
3
3
  The **[Perplexity provider](https://ai-sdk.dev/providers/ai-sdk-providers/perplexity)** for the [AI SDK](https://ai-sdk.dev/docs)
4
- contains language model support for Perplexity's Sonar API - a powerful answer engine with real-time web search capabilities.
4
+ contains language model support for Perplexity's Agent API, including web search, citations, function tools, and structured output.
5
5
 
6
6
  ## Features
7
7
 
8
8
  - Real-time web search grounding for accurate, up-to-date responses
9
- - Support for advanced queries and follow-up questions
10
- - Multiple tiers available:
11
- - **Sonar Pro**: Enhanced capabilities for complex tasks with 2x more citations
12
- - **Sonar**: Lightweight offering optimized for speed and cost
13
- - Industry-leading answer quality
14
- - Data privacy - no training on customer data
15
- - Self-serve API access with scalable pricing
9
+ - Agent API presets from `fast` through `xhigh`
10
+ - Direct access to supported third-party models through Perplexity
11
+ - Native tools for web search, URL fetching, code execution, finance, MCP, and connectors
12
+ - AI SDK function tools, structured output, reasoning streams, and multi-turn tool calls
16
13
 
17
14
  > **Deploying to Vercel?** With Vercel's AI Gateway you can access Perplexity (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
18
15
 
@@ -47,11 +44,23 @@ import { perplexity } from '@ai-sdk/perplexity';
47
44
  import { generateText } from 'ai';
48
45
 
49
46
  const { text } = await generateText({
50
- model: perplexity('sonar-pro'),
47
+ model: perplexity('low'),
51
48
  prompt: 'What are the latest developments in quantum computing?',
52
49
  });
53
50
  ```
54
51
 
52
+ Version 3.1.0 is a breaking migration from Sonar Chat Completions to the Agent
53
+ API. Legacy Sonar model IDs and provider options are not mapped. Review the
54
+ [migration notes](https://ai-sdk.dev/providers/ai-sdk-providers/perplexity#migrating-from-v4-sonar-to-v5-agent-api)
55
+ before upgrading an existing application (the notes refer to the Sonar-based
56
+ releases as v4 and the Agent API releases as v5; for AI SDK 6 these are
57
+ 3.0.63 and earlier, and 3.1.0 and later).
58
+
59
+ Perplexity supports Sonar Chat Completions only until September 27, 2026.
60
+ Remaining on version 3.0.63 or earlier will not preserve language generation
61
+ after that date.
62
+ Migrate unsupported Sonar features using the alternatives in the migration notes.
63
+
55
64
  ## Documentation
56
65
 
57
66
  Please check out the **[Perplexity provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/perplexity)** for more information.
package/dist/index.d.mts CHANGED
@@ -12,15 +12,16 @@ declare const perplexityEmbeddingModelOptions: z.ZodObject<{
12
12
  }, z.core.$strip>;
13
13
  type PerplexityEmbeddingModelOptions = z.infer<typeof perplexityEmbeddingModelOptions>;
14
14
 
15
- type PerplexityLanguageModelId = 'sonar-deep-research' | 'sonar-reasoning-pro' | 'sonar-reasoning' | 'sonar-pro' | 'sonar' | (string & {});
15
+ type PerplexityAgentPreset = 'fast' | 'low' | 'medium' | 'high' | 'xhigh';
16
+ type PerplexityLanguageModelId = PerplexityAgentPreset | 'perplexity/sonar' | (string & {});
16
17
 
17
18
  interface PerplexityProvider extends ProviderV3 {
18
19
  /**
19
- * Creates an Perplexity chat model for text generation.
20
+ * Creates a Perplexity Agent API model or preset for text generation.
20
21
  */
21
22
  (modelId: PerplexityLanguageModelId): LanguageModelV3;
22
23
  /**
23
- * Creates an Perplexity language model for text generation.
24
+ * Creates a Perplexity Agent API model or preset for text generation.
24
25
  */
25
26
  languageModel(modelId: PerplexityLanguageModelId): LanguageModelV3;
26
27
  /**
@@ -38,7 +39,7 @@ interface PerplexityProvider extends ProviderV3 {
38
39
  }
39
40
  interface PerplexityProviderSettings {
40
41
  /**
41
- * Base URL for the perplexity API calls.
42
+ * Base URL for Perplexity API calls.
42
43
  */
43
44
  baseURL?: string;
44
45
  /**
@@ -58,6 +59,112 @@ interface PerplexityProviderSettings {
58
59
  declare function createPerplexity(options?: PerplexityProviderSettings): PerplexityProvider;
59
60
  declare const perplexity: PerplexityProvider;
60
61
 
62
+ declare const perplexityLanguageModelOptions: z.ZodObject<{
63
+ /** Top-level Agent API instructions. */
64
+ instructions: z.ZodOptional<z.ZodString>;
65
+ /**
66
+ * Native Agent API tools. AI SDK function tools can also be supplied through
67
+ * the top-level `tools` option on `generateText` and `streamText`.
68
+ */
69
+ tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
70
+ type: z.ZodLiteral<"web_search">;
71
+ filters: z.ZodOptional<z.ZodObject<{
72
+ search_domain_filter: z.ZodOptional<z.ZodArray<z.ZodString>>;
73
+ search_recency_filter: z.ZodOptional<z.ZodEnum<{
74
+ hour: "hour";
75
+ day: "day";
76
+ week: "week";
77
+ month: "month";
78
+ year: "year";
79
+ }>>;
80
+ search_after_date_filter: z.ZodOptional<z.ZodString>;
81
+ search_before_date_filter: z.ZodOptional<z.ZodString>;
82
+ last_updated_after_filter: z.ZodOptional<z.ZodString>;
83
+ last_updated_before_filter: z.ZodOptional<z.ZodString>;
84
+ }, z.core.$loose>>;
85
+ max_results: z.ZodOptional<z.ZodNumber>;
86
+ max_tokens: z.ZodOptional<z.ZodNumber>;
87
+ max_tokens_per_page: z.ZodOptional<z.ZodNumber>;
88
+ search_context_size: z.ZodOptional<z.ZodEnum<{
89
+ low: "low";
90
+ medium: "medium";
91
+ high: "high";
92
+ }>>;
93
+ user_location: z.ZodOptional<z.ZodObject<{
94
+ latitude: z.ZodOptional<z.ZodNumber>;
95
+ longitude: z.ZodOptional<z.ZodNumber>;
96
+ country: z.ZodOptional<z.ZodString>;
97
+ city: z.ZodOptional<z.ZodString>;
98
+ region: z.ZodOptional<z.ZodString>;
99
+ }, z.core.$loose>>;
100
+ }, z.core.$loose>, z.ZodObject<{
101
+ type: z.ZodLiteral<"fetch_url">;
102
+ max_urls: z.ZodOptional<z.ZodNumber>;
103
+ }, z.core.$loose>, z.ZodObject<{
104
+ type: z.ZodLiteral<"people_search">;
105
+ }, z.core.$loose>, z.ZodObject<{
106
+ type: z.ZodLiteral<"finance_search">;
107
+ }, z.core.$loose>, z.ZodObject<{
108
+ type: z.ZodLiteral<"sandbox">;
109
+ }, z.core.$loose>, z.ZodObject<{
110
+ type: z.ZodLiteral<"mcp">;
111
+ server_label: z.ZodString;
112
+ server_url: z.ZodString;
113
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
114
+ authorization: z.ZodOptional<z.ZodString>;
115
+ defer_loading: z.ZodOptional<z.ZodBoolean>;
116
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
117
+ }, z.core.$loose>, z.ZodObject<{
118
+ type: z.ZodLiteral<"connector">;
119
+ id: z.ZodString;
120
+ server_label: z.ZodString;
121
+ server_description: z.ZodOptional<z.ZodString>;
122
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
123
+ }, z.core.$loose>]>>>;
124
+ /** A fallback model list for Agent API routing. */
125
+ models: z.ZodOptional<z.ZodArray<z.ZodString>>;
126
+ /** Maximum number of agentic steps. */
127
+ max_steps: z.ZodOptional<z.ZodNumber>;
128
+ /** Maximum number of native tool calls. */
129
+ max_tool_calls: z.ZodOptional<z.ZodNumber>;
130
+ /** Continue a conversation from an earlier Agent API response. */
131
+ previous_response_id: z.ZodOptional<z.ZodString>;
132
+ /**
133
+ * Whether the response can be retrieved later. Setting this to false does
134
+ * not disable persistence or prevent previous_response_id continuations.
135
+ */
136
+ store: z.ZodOptional<z.ZodBoolean>;
137
+ /** Preferred response language as an ISO 639-1 language code. */
138
+ language_preference: z.ZodOptional<z.ZodString>;
139
+ /** Agent API reasoning configuration. */
140
+ reasoning: z.ZodOptional<z.ZodObject<{
141
+ effort: z.ZodOptional<z.ZodEnum<{
142
+ low: "low";
143
+ medium: "medium";
144
+ high: "high";
145
+ minimal: "minimal";
146
+ xhigh: "xhigh";
147
+ }>>;
148
+ }, z.core.$loose>>;
149
+ /** Agent API skill configuration. */
150
+ skills: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
151
+ type: z.ZodLiteral<"builtin">;
152
+ name: z.ZodEnum<{
153
+ office: "office";
154
+ "office/docx": "office/docx";
155
+ "office/pdf": "office/pdf";
156
+ "office/pptx": "office/pptx";
157
+ "office/xlsx": "office/xlsx";
158
+ }>;
159
+ }, z.core.$loose>, z.ZodObject<{
160
+ type: z.ZodLiteral<"inline">;
161
+ name: z.ZodString;
162
+ description: z.ZodString;
163
+ instructions: z.ZodString;
164
+ }, z.core.$loose>]>>>;
165
+ }, z.core.$loose>;
166
+ type PerplexityLanguageModelOptions = z.infer<typeof perplexityLanguageModelOptions>;
167
+
61
168
  declare const VERSION: string;
62
169
 
63
- export { type PerplexityEmbeddingModelId, type PerplexityEmbeddingModelOptions, type PerplexityProvider, type PerplexityProviderSettings, VERSION, createPerplexity, perplexity };
170
+ export { type PerplexityAgentPreset, type PerplexityEmbeddingModelId, type PerplexityEmbeddingModelOptions, type PerplexityLanguageModelId, type PerplexityLanguageModelOptions, type PerplexityProvider, type PerplexityProviderSettings, VERSION, createPerplexity, perplexity };
package/dist/index.d.ts CHANGED
@@ -12,15 +12,16 @@ declare const perplexityEmbeddingModelOptions: z.ZodObject<{
12
12
  }, z.core.$strip>;
13
13
  type PerplexityEmbeddingModelOptions = z.infer<typeof perplexityEmbeddingModelOptions>;
14
14
 
15
- type PerplexityLanguageModelId = 'sonar-deep-research' | 'sonar-reasoning-pro' | 'sonar-reasoning' | 'sonar-pro' | 'sonar' | (string & {});
15
+ type PerplexityAgentPreset = 'fast' | 'low' | 'medium' | 'high' | 'xhigh';
16
+ type PerplexityLanguageModelId = PerplexityAgentPreset | 'perplexity/sonar' | (string & {});
16
17
 
17
18
  interface PerplexityProvider extends ProviderV3 {
18
19
  /**
19
- * Creates an Perplexity chat model for text generation.
20
+ * Creates a Perplexity Agent API model or preset for text generation.
20
21
  */
21
22
  (modelId: PerplexityLanguageModelId): LanguageModelV3;
22
23
  /**
23
- * Creates an Perplexity language model for text generation.
24
+ * Creates a Perplexity Agent API model or preset for text generation.
24
25
  */
25
26
  languageModel(modelId: PerplexityLanguageModelId): LanguageModelV3;
26
27
  /**
@@ -38,7 +39,7 @@ interface PerplexityProvider extends ProviderV3 {
38
39
  }
39
40
  interface PerplexityProviderSettings {
40
41
  /**
41
- * Base URL for the perplexity API calls.
42
+ * Base URL for Perplexity API calls.
42
43
  */
43
44
  baseURL?: string;
44
45
  /**
@@ -58,6 +59,112 @@ interface PerplexityProviderSettings {
58
59
  declare function createPerplexity(options?: PerplexityProviderSettings): PerplexityProvider;
59
60
  declare const perplexity: PerplexityProvider;
60
61
 
62
+ declare const perplexityLanguageModelOptions: z.ZodObject<{
63
+ /** Top-level Agent API instructions. */
64
+ instructions: z.ZodOptional<z.ZodString>;
65
+ /**
66
+ * Native Agent API tools. AI SDK function tools can also be supplied through
67
+ * the top-level `tools` option on `generateText` and `streamText`.
68
+ */
69
+ tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
70
+ type: z.ZodLiteral<"web_search">;
71
+ filters: z.ZodOptional<z.ZodObject<{
72
+ search_domain_filter: z.ZodOptional<z.ZodArray<z.ZodString>>;
73
+ search_recency_filter: z.ZodOptional<z.ZodEnum<{
74
+ hour: "hour";
75
+ day: "day";
76
+ week: "week";
77
+ month: "month";
78
+ year: "year";
79
+ }>>;
80
+ search_after_date_filter: z.ZodOptional<z.ZodString>;
81
+ search_before_date_filter: z.ZodOptional<z.ZodString>;
82
+ last_updated_after_filter: z.ZodOptional<z.ZodString>;
83
+ last_updated_before_filter: z.ZodOptional<z.ZodString>;
84
+ }, z.core.$loose>>;
85
+ max_results: z.ZodOptional<z.ZodNumber>;
86
+ max_tokens: z.ZodOptional<z.ZodNumber>;
87
+ max_tokens_per_page: z.ZodOptional<z.ZodNumber>;
88
+ search_context_size: z.ZodOptional<z.ZodEnum<{
89
+ low: "low";
90
+ medium: "medium";
91
+ high: "high";
92
+ }>>;
93
+ user_location: z.ZodOptional<z.ZodObject<{
94
+ latitude: z.ZodOptional<z.ZodNumber>;
95
+ longitude: z.ZodOptional<z.ZodNumber>;
96
+ country: z.ZodOptional<z.ZodString>;
97
+ city: z.ZodOptional<z.ZodString>;
98
+ region: z.ZodOptional<z.ZodString>;
99
+ }, z.core.$loose>>;
100
+ }, z.core.$loose>, z.ZodObject<{
101
+ type: z.ZodLiteral<"fetch_url">;
102
+ max_urls: z.ZodOptional<z.ZodNumber>;
103
+ }, z.core.$loose>, z.ZodObject<{
104
+ type: z.ZodLiteral<"people_search">;
105
+ }, z.core.$loose>, z.ZodObject<{
106
+ type: z.ZodLiteral<"finance_search">;
107
+ }, z.core.$loose>, z.ZodObject<{
108
+ type: z.ZodLiteral<"sandbox">;
109
+ }, z.core.$loose>, z.ZodObject<{
110
+ type: z.ZodLiteral<"mcp">;
111
+ server_label: z.ZodString;
112
+ server_url: z.ZodString;
113
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
114
+ authorization: z.ZodOptional<z.ZodString>;
115
+ defer_loading: z.ZodOptional<z.ZodBoolean>;
116
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
117
+ }, z.core.$loose>, z.ZodObject<{
118
+ type: z.ZodLiteral<"connector">;
119
+ id: z.ZodString;
120
+ server_label: z.ZodString;
121
+ server_description: z.ZodOptional<z.ZodString>;
122
+ allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
123
+ }, z.core.$loose>]>>>;
124
+ /** A fallback model list for Agent API routing. */
125
+ models: z.ZodOptional<z.ZodArray<z.ZodString>>;
126
+ /** Maximum number of agentic steps. */
127
+ max_steps: z.ZodOptional<z.ZodNumber>;
128
+ /** Maximum number of native tool calls. */
129
+ max_tool_calls: z.ZodOptional<z.ZodNumber>;
130
+ /** Continue a conversation from an earlier Agent API response. */
131
+ previous_response_id: z.ZodOptional<z.ZodString>;
132
+ /**
133
+ * Whether the response can be retrieved later. Setting this to false does
134
+ * not disable persistence or prevent previous_response_id continuations.
135
+ */
136
+ store: z.ZodOptional<z.ZodBoolean>;
137
+ /** Preferred response language as an ISO 639-1 language code. */
138
+ language_preference: z.ZodOptional<z.ZodString>;
139
+ /** Agent API reasoning configuration. */
140
+ reasoning: z.ZodOptional<z.ZodObject<{
141
+ effort: z.ZodOptional<z.ZodEnum<{
142
+ low: "low";
143
+ medium: "medium";
144
+ high: "high";
145
+ minimal: "minimal";
146
+ xhigh: "xhigh";
147
+ }>>;
148
+ }, z.core.$loose>>;
149
+ /** Agent API skill configuration. */
150
+ skills: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
151
+ type: z.ZodLiteral<"builtin">;
152
+ name: z.ZodEnum<{
153
+ office: "office";
154
+ "office/docx": "office/docx";
155
+ "office/pdf": "office/pdf";
156
+ "office/pptx": "office/pptx";
157
+ "office/xlsx": "office/xlsx";
158
+ }>;
159
+ }, z.core.$loose>, z.ZodObject<{
160
+ type: z.ZodLiteral<"inline">;
161
+ name: z.ZodString;
162
+ description: z.ZodString;
163
+ instructions: z.ZodString;
164
+ }, z.core.$loose>]>>>;
165
+ }, z.core.$loose>;
166
+ type PerplexityLanguageModelOptions = z.infer<typeof perplexityLanguageModelOptions>;
167
+
61
168
  declare const VERSION: string;
62
169
 
63
- export { type PerplexityEmbeddingModelId, type PerplexityEmbeddingModelOptions, type PerplexityProvider, type PerplexityProviderSettings, VERSION, createPerplexity, perplexity };
170
+ export { type PerplexityAgentPreset, type PerplexityEmbeddingModelId, type PerplexityEmbeddingModelOptions, type PerplexityLanguageModelId, type PerplexityLanguageModelOptions, type PerplexityProvider, type PerplexityProviderSettings, VERSION, createPerplexity, perplexity };