perplexityai 0.5.0__py3-none-any.whl → 0.7.0__py3-none-any.whl

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.

Potentially problematic release.


This version of perplexityai might be problematic. Click here for more details.

Files changed (40) hide show
  1. perplexity/_client.py +27 -1
  2. perplexity/_version.py +1 -1
  3. perplexity/resources/__init__.py +42 -0
  4. perplexity/resources/async_/__init__.py +33 -0
  5. perplexity/resources/async_/async_.py +102 -0
  6. perplexity/resources/async_/chat/__init__.py +33 -0
  7. perplexity/resources/async_/chat/chat.py +102 -0
  8. perplexity/resources/async_/chat/completions.py +347 -0
  9. perplexity/resources/chat/__init__.py +33 -0
  10. perplexity/resources/chat/chat.py +102 -0
  11. perplexity/resources/chat/completions.py +295 -0
  12. perplexity/resources/content.py +167 -0
  13. perplexity/resources/search.py +64 -2
  14. perplexity/types/__init__.py +8 -0
  15. perplexity/types/async_/__init__.py +3 -0
  16. perplexity/types/async_/chat/__init__.py +9 -0
  17. perplexity/types/async_/chat/completion_create_params.py +94 -0
  18. perplexity/types/async_/chat/completion_create_response.py +54 -0
  19. perplexity/types/async_/chat/completion_get_response.py +54 -0
  20. perplexity/types/async_/chat/completion_list_params.py +15 -0
  21. perplexity/types/async_/chat/completion_list_response.py +31 -0
  22. perplexity/types/chat/__init__.py +6 -0
  23. perplexity/types/chat/completion_create_params.py +90 -0
  24. perplexity/types/chat/completion_create_response.py +30 -0
  25. perplexity/types/content_create_params.py +14 -0
  26. perplexity/types/content_create_response.py +29 -0
  27. perplexity/types/search_create_params.py +26 -0
  28. perplexity/types/search_create_response.py +7 -0
  29. perplexity/types/shared/__init__.py +6 -0
  30. perplexity/types/shared/chat_choice.py +17 -0
  31. perplexity/types/shared/chat_message.py +31 -0
  32. perplexity/types/shared/search_result.py +15 -0
  33. perplexity/types/shared/usage_info.py +23 -0
  34. perplexity/types/shared_params/__init__.py +3 -0
  35. perplexity/types/shared_params/chat_message.py +31 -0
  36. {perplexityai-0.5.0.dist-info → perplexityai-0.7.0.dist-info}/METADATA +90 -22
  37. perplexityai-0.7.0.dist-info/RECORD +65 -0
  38. perplexityai-0.5.0.dist-info/RECORD +0 -37
  39. {perplexityai-0.5.0.dist-info → perplexityai-0.7.0.dist-info}/WHEEL +0 -0
  40. {perplexityai-0.5.0.dist-info → perplexityai-0.7.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,295 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Iterable, Optional
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
11
+ from ..._utils import maybe_transform, async_maybe_transform
12
+ from ..._compat import cached_property
13
+ from ..._resource import SyncAPIResource, AsyncAPIResource
14
+ from ..._response import (
15
+ to_raw_response_wrapper,
16
+ to_streamed_response_wrapper,
17
+ async_to_raw_response_wrapper,
18
+ async_to_streamed_response_wrapper,
19
+ )
20
+ from ...types.chat import completion_create_params
21
+ from ..._base_client import make_request_options
22
+ from ...types.shared_params.chat_message import ChatMessage
23
+ from ...types.chat.completion_create_response import CompletionCreateResponse
24
+
25
+ __all__ = ["CompletionsResource", "AsyncCompletionsResource"]
26
+
27
+
28
+ class CompletionsResource(SyncAPIResource):
29
+ @cached_property
30
+ def with_raw_response(self) -> CompletionsResourceWithRawResponse:
31
+ """
32
+ This property can be used as a prefix for any HTTP method call to return
33
+ the raw response object instead of the parsed content.
34
+
35
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#accessing-raw-response-data-eg-headers
36
+ """
37
+ return CompletionsResourceWithRawResponse(self)
38
+
39
+ @cached_property
40
+ def with_streaming_response(self) -> CompletionsResourceWithStreamingResponse:
41
+ """
42
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
43
+
44
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#with_streaming_response
45
+ """
46
+ return CompletionsResourceWithStreamingResponse(self)
47
+
48
+ def create(
49
+ self,
50
+ *,
51
+ messages: Iterable[ChatMessage],
52
+ model: Literal["sonar", "sonar-pro", "sonar-deep-research", "sonar-reasoning", "sonar-reasoning-pro"],
53
+ disable_search: bool | NotGiven = NOT_GIVEN,
54
+ enable_search_classifier: bool | NotGiven = NOT_GIVEN,
55
+ last_updated_after_filter: Optional[str] | NotGiven = NOT_GIVEN,
56
+ last_updated_before_filter: Optional[str] | NotGiven = NOT_GIVEN,
57
+ reasoning_effort: Optional[Literal["low", "medium", "high"]] | NotGiven = NOT_GIVEN,
58
+ return_images: bool | NotGiven = NOT_GIVEN,
59
+ return_related_questions: bool | NotGiven = NOT_GIVEN,
60
+ search_after_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
61
+ search_before_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
62
+ search_domain_filter: Optional[SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
63
+ search_mode: Optional[Literal["web", "academic", "sec"]] | NotGiven = NOT_GIVEN,
64
+ search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]] | NotGiven = NOT_GIVEN,
65
+ web_search_options: completion_create_params.WebSearchOptions | NotGiven = NOT_GIVEN,
66
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
67
+ # The extra values given here take precedence over values defined on the client or passed to this method.
68
+ extra_headers: Headers | None = None,
69
+ extra_query: Query | None = None,
70
+ extra_body: Body | None = None,
71
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
72
+ ) -> CompletionCreateResponse:
73
+ """
74
+ Generates a model's response for the given chat conversation with integrated
75
+ search capabilities
76
+
77
+ Args:
78
+ messages: A list of messages comprising the conversation so far
79
+
80
+ model: The name of the model that will complete your prompt
81
+
82
+ disable_search: Disables web search completely - model uses only training data
83
+
84
+ enable_search_classifier: Enables classifier that decides if web search is needed
85
+
86
+ last_updated_after_filter: Only include content last updated after this date (YYYY-MM-DD)
87
+
88
+ last_updated_before_filter: Only include content last updated before this date (YYYY-MM-DD)
89
+
90
+ reasoning_effort: Controls computational effort for sonar-deep-research model. Higher effort =
91
+ more thorough but more tokens
92
+
93
+ return_images: Whether to include images in search results
94
+
95
+ return_related_questions: Whether to return related questions
96
+
97
+ search_after_date_filter: Only include content published after this date (YYYY-MM-DD)
98
+
99
+ search_before_date_filter: Only include content published before this date (YYYY-MM-DD)
100
+
101
+ search_domain_filter: List of domains to limit search results to. Use '-' prefix to exclude domains
102
+
103
+ search_mode: Type of search: 'web' for general, 'academic' for scholarly, 'sec' for SEC
104
+ filings
105
+
106
+ search_recency_filter: Filter results by how recently they were published
107
+
108
+ extra_headers: Send extra headers
109
+
110
+ extra_query: Add additional query parameters to the request
111
+
112
+ extra_body: Add additional JSON properties to the request
113
+
114
+ timeout: Override the client-level default timeout for this request, in seconds
115
+ """
116
+ return self._post(
117
+ "/chat/completions",
118
+ body=maybe_transform(
119
+ {
120
+ "messages": messages,
121
+ "model": model,
122
+ "disable_search": disable_search,
123
+ "enable_search_classifier": enable_search_classifier,
124
+ "last_updated_after_filter": last_updated_after_filter,
125
+ "last_updated_before_filter": last_updated_before_filter,
126
+ "reasoning_effort": reasoning_effort,
127
+ "return_images": return_images,
128
+ "return_related_questions": return_related_questions,
129
+ "search_after_date_filter": search_after_date_filter,
130
+ "search_before_date_filter": search_before_date_filter,
131
+ "search_domain_filter": search_domain_filter,
132
+ "search_mode": search_mode,
133
+ "search_recency_filter": search_recency_filter,
134
+ "web_search_options": web_search_options,
135
+ },
136
+ completion_create_params.CompletionCreateParams,
137
+ ),
138
+ options=make_request_options(
139
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
140
+ ),
141
+ cast_to=CompletionCreateResponse,
142
+ )
143
+
144
+
145
+ class AsyncCompletionsResource(AsyncAPIResource):
146
+ @cached_property
147
+ def with_raw_response(self) -> AsyncCompletionsResourceWithRawResponse:
148
+ """
149
+ This property can be used as a prefix for any HTTP method call to return
150
+ the raw response object instead of the parsed content.
151
+
152
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#accessing-raw-response-data-eg-headers
153
+ """
154
+ return AsyncCompletionsResourceWithRawResponse(self)
155
+
156
+ @cached_property
157
+ def with_streaming_response(self) -> AsyncCompletionsResourceWithStreamingResponse:
158
+ """
159
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
160
+
161
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#with_streaming_response
162
+ """
163
+ return AsyncCompletionsResourceWithStreamingResponse(self)
164
+
165
+ async def create(
166
+ self,
167
+ *,
168
+ messages: Iterable[ChatMessage],
169
+ model: Literal["sonar", "sonar-pro", "sonar-deep-research", "sonar-reasoning", "sonar-reasoning-pro"],
170
+ disable_search: bool | NotGiven = NOT_GIVEN,
171
+ enable_search_classifier: bool | NotGiven = NOT_GIVEN,
172
+ last_updated_after_filter: Optional[str] | NotGiven = NOT_GIVEN,
173
+ last_updated_before_filter: Optional[str] | NotGiven = NOT_GIVEN,
174
+ reasoning_effort: Optional[Literal["low", "medium", "high"]] | NotGiven = NOT_GIVEN,
175
+ return_images: bool | NotGiven = NOT_GIVEN,
176
+ return_related_questions: bool | NotGiven = NOT_GIVEN,
177
+ search_after_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
178
+ search_before_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
179
+ search_domain_filter: Optional[SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
180
+ search_mode: Optional[Literal["web", "academic", "sec"]] | NotGiven = NOT_GIVEN,
181
+ search_recency_filter: Optional[Literal["hour", "day", "week", "month", "year"]] | NotGiven = NOT_GIVEN,
182
+ web_search_options: completion_create_params.WebSearchOptions | NotGiven = NOT_GIVEN,
183
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
184
+ # The extra values given here take precedence over values defined on the client or passed to this method.
185
+ extra_headers: Headers | None = None,
186
+ extra_query: Query | None = None,
187
+ extra_body: Body | None = None,
188
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
189
+ ) -> CompletionCreateResponse:
190
+ """
191
+ Generates a model's response for the given chat conversation with integrated
192
+ search capabilities
193
+
194
+ Args:
195
+ messages: A list of messages comprising the conversation so far
196
+
197
+ model: The name of the model that will complete your prompt
198
+
199
+ disable_search: Disables web search completely - model uses only training data
200
+
201
+ enable_search_classifier: Enables classifier that decides if web search is needed
202
+
203
+ last_updated_after_filter: Only include content last updated after this date (YYYY-MM-DD)
204
+
205
+ last_updated_before_filter: Only include content last updated before this date (YYYY-MM-DD)
206
+
207
+ reasoning_effort: Controls computational effort for sonar-deep-research model. Higher effort =
208
+ more thorough but more tokens
209
+
210
+ return_images: Whether to include images in search results
211
+
212
+ return_related_questions: Whether to return related questions
213
+
214
+ search_after_date_filter: Only include content published after this date (YYYY-MM-DD)
215
+
216
+ search_before_date_filter: Only include content published before this date (YYYY-MM-DD)
217
+
218
+ search_domain_filter: List of domains to limit search results to. Use '-' prefix to exclude domains
219
+
220
+ search_mode: Type of search: 'web' for general, 'academic' for scholarly, 'sec' for SEC
221
+ filings
222
+
223
+ search_recency_filter: Filter results by how recently they were published
224
+
225
+ extra_headers: Send extra headers
226
+
227
+ extra_query: Add additional query parameters to the request
228
+
229
+ extra_body: Add additional JSON properties to the request
230
+
231
+ timeout: Override the client-level default timeout for this request, in seconds
232
+ """
233
+ return await self._post(
234
+ "/chat/completions",
235
+ body=await async_maybe_transform(
236
+ {
237
+ "messages": messages,
238
+ "model": model,
239
+ "disable_search": disable_search,
240
+ "enable_search_classifier": enable_search_classifier,
241
+ "last_updated_after_filter": last_updated_after_filter,
242
+ "last_updated_before_filter": last_updated_before_filter,
243
+ "reasoning_effort": reasoning_effort,
244
+ "return_images": return_images,
245
+ "return_related_questions": return_related_questions,
246
+ "search_after_date_filter": search_after_date_filter,
247
+ "search_before_date_filter": search_before_date_filter,
248
+ "search_domain_filter": search_domain_filter,
249
+ "search_mode": search_mode,
250
+ "search_recency_filter": search_recency_filter,
251
+ "web_search_options": web_search_options,
252
+ },
253
+ completion_create_params.CompletionCreateParams,
254
+ ),
255
+ options=make_request_options(
256
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
257
+ ),
258
+ cast_to=CompletionCreateResponse,
259
+ )
260
+
261
+
262
+ class CompletionsResourceWithRawResponse:
263
+ def __init__(self, completions: CompletionsResource) -> None:
264
+ self._completions = completions
265
+
266
+ self.create = to_raw_response_wrapper(
267
+ completions.create,
268
+ )
269
+
270
+
271
+ class AsyncCompletionsResourceWithRawResponse:
272
+ def __init__(self, completions: AsyncCompletionsResource) -> None:
273
+ self._completions = completions
274
+
275
+ self.create = async_to_raw_response_wrapper(
276
+ completions.create,
277
+ )
278
+
279
+
280
+ class CompletionsResourceWithStreamingResponse:
281
+ def __init__(self, completions: CompletionsResource) -> None:
282
+ self._completions = completions
283
+
284
+ self.create = to_streamed_response_wrapper(
285
+ completions.create,
286
+ )
287
+
288
+
289
+ class AsyncCompletionsResourceWithStreamingResponse:
290
+ def __init__(self, completions: AsyncCompletionsResource) -> None:
291
+ self._completions = completions
292
+
293
+ self.create = async_to_streamed_response_wrapper(
294
+ completions.create,
295
+ )
@@ -0,0 +1,167 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import httpx
6
+
7
+ from ..types import content_create_params
8
+ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
9
+ from .._utils import maybe_transform, async_maybe_transform
10
+ from .._compat import cached_property
11
+ from .._resource import SyncAPIResource, AsyncAPIResource
12
+ from .._response import (
13
+ to_raw_response_wrapper,
14
+ to_streamed_response_wrapper,
15
+ async_to_raw_response_wrapper,
16
+ async_to_streamed_response_wrapper,
17
+ )
18
+ from .._base_client import make_request_options
19
+ from ..types.content_create_response import ContentCreateResponse
20
+
21
+ __all__ = ["ContentResource", "AsyncContentResource"]
22
+
23
+
24
+ class ContentResource(SyncAPIResource):
25
+ @cached_property
26
+ def with_raw_response(self) -> ContentResourceWithRawResponse:
27
+ """
28
+ This property can be used as a prefix for any HTTP method call to return
29
+ the raw response object instead of the parsed content.
30
+
31
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#accessing-raw-response-data-eg-headers
32
+ """
33
+ return ContentResourceWithRawResponse(self)
34
+
35
+ @cached_property
36
+ def with_streaming_response(self) -> ContentResourceWithStreamingResponse:
37
+ """
38
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
39
+
40
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#with_streaming_response
41
+ """
42
+ return ContentResourceWithStreamingResponse(self)
43
+
44
+ def create(
45
+ self,
46
+ *,
47
+ urls: SequenceNotStr[str],
48
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
49
+ # The extra values given here take precedence over values defined on the client or passed to this method.
50
+ extra_headers: Headers | None = None,
51
+ extra_query: Query | None = None,
52
+ extra_body: Body | None = None,
53
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
54
+ ) -> ContentCreateResponse:
55
+ """
56
+ Retrieve the full content from specified URLs
57
+
58
+ Args:
59
+ urls: List of URLs to retrieve content from
60
+
61
+ extra_headers: Send extra headers
62
+
63
+ extra_query: Add additional query parameters to the request
64
+
65
+ extra_body: Add additional JSON properties to the request
66
+
67
+ timeout: Override the client-level default timeout for this request, in seconds
68
+ """
69
+ return self._post(
70
+ "/content",
71
+ body=maybe_transform({"urls": urls}, content_create_params.ContentCreateParams),
72
+ options=make_request_options(
73
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
74
+ ),
75
+ cast_to=ContentCreateResponse,
76
+ )
77
+
78
+
79
+ class AsyncContentResource(AsyncAPIResource):
80
+ @cached_property
81
+ def with_raw_response(self) -> AsyncContentResourceWithRawResponse:
82
+ """
83
+ This property can be used as a prefix for any HTTP method call to return
84
+ the raw response object instead of the parsed content.
85
+
86
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#accessing-raw-response-data-eg-headers
87
+ """
88
+ return AsyncContentResourceWithRawResponse(self)
89
+
90
+ @cached_property
91
+ def with_streaming_response(self) -> AsyncContentResourceWithStreamingResponse:
92
+ """
93
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
94
+
95
+ For more information, see https://www.github.com/ppl-ai/perplexity-py#with_streaming_response
96
+ """
97
+ return AsyncContentResourceWithStreamingResponse(self)
98
+
99
+ async def create(
100
+ self,
101
+ *,
102
+ urls: SequenceNotStr[str],
103
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
104
+ # The extra values given here take precedence over values defined on the client or passed to this method.
105
+ extra_headers: Headers | None = None,
106
+ extra_query: Query | None = None,
107
+ extra_body: Body | None = None,
108
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
109
+ ) -> ContentCreateResponse:
110
+ """
111
+ Retrieve the full content from specified URLs
112
+
113
+ Args:
114
+ urls: List of URLs to retrieve content from
115
+
116
+ extra_headers: Send extra headers
117
+
118
+ extra_query: Add additional query parameters to the request
119
+
120
+ extra_body: Add additional JSON properties to the request
121
+
122
+ timeout: Override the client-level default timeout for this request, in seconds
123
+ """
124
+ return await self._post(
125
+ "/content",
126
+ body=await async_maybe_transform({"urls": urls}, content_create_params.ContentCreateParams),
127
+ options=make_request_options(
128
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
129
+ ),
130
+ cast_to=ContentCreateResponse,
131
+ )
132
+
133
+
134
+ class ContentResourceWithRawResponse:
135
+ def __init__(self, content: ContentResource) -> None:
136
+ self._content = content
137
+
138
+ self.create = to_raw_response_wrapper(
139
+ content.create,
140
+ )
141
+
142
+
143
+ class AsyncContentResourceWithRawResponse:
144
+ def __init__(self, content: AsyncContentResource) -> None:
145
+ self._content = content
146
+
147
+ self.create = async_to_raw_response_wrapper(
148
+ content.create,
149
+ )
150
+
151
+
152
+ class ContentResourceWithStreamingResponse:
153
+ def __init__(self, content: ContentResource) -> None:
154
+ self._content = content
155
+
156
+ self.create = to_streamed_response_wrapper(
157
+ content.create,
158
+ )
159
+
160
+
161
+ class AsyncContentResourceWithStreamingResponse:
162
+ def __init__(self, content: AsyncContentResource) -> None:
163
+ self._content = content
164
+
165
+ self.create = async_to_streamed_response_wrapper(
166
+ content.create,
167
+ )
@@ -53,6 +53,7 @@ class SearchResource(SyncAPIResource):
53
53
  last_updated_before_filter: Optional[str] | NotGiven = NOT_GIVEN,
54
54
  max_results: int | NotGiven = NOT_GIVEN,
55
55
  max_tokens: int | NotGiven = NOT_GIVEN,
56
+ max_tokens_per_page: int | NotGiven = NOT_GIVEN,
56
57
  safe_search: Optional[bool] | NotGiven = NOT_GIVEN,
57
58
  search_after_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
58
59
  search_before_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
@@ -67,9 +68,38 @@ class SearchResource(SyncAPIResource):
67
68
  timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
68
69
  ) -> SearchCreateResponse:
69
70
  """
70
- Search
71
+ Perform a search query with various filtering and customization options
71
72
 
72
73
  Args:
74
+ query: Search query string or array of query strings to search for
75
+
76
+ country: Country code to bias search results towards (e.g., 'US', 'GB', 'CA')
77
+
78
+ last_updated_after_filter: Only include results last updated after this date (ISO 8601 format: YYYY-MM-DD)
79
+
80
+ last_updated_before_filter: Only include results last updated before this date (ISO 8601 format: YYYY-MM-DD)
81
+
82
+ max_results: Maximum number of search results to return
83
+
84
+ max_tokens: Maximum number of tokens to return across all results
85
+
86
+ max_tokens_per_page: Maximum number of tokens to return per individual search result
87
+
88
+ safe_search: Enable safe search filtering to exclude adult content
89
+
90
+ search_after_date_filter: Only include results published after this date (ISO 8601 format: YYYY-MM-DD)
91
+
92
+ search_before_date_filter: Only include results published before this date (ISO 8601 format: YYYY-MM-DD)
93
+
94
+ search_domain_filter: List of domains to restrict search results to (e.g., ['example.com',
95
+ 'another.com'])
96
+
97
+ search_mode: Type of search to perform: 'web' for general web search, 'academic' for
98
+ scholarly articles, 'sec' for SEC filings
99
+
100
+ search_recency_filter: Filter results by how recently they were published (hour, day, week, month, or
101
+ year)
102
+
73
103
  extra_headers: Send extra headers
74
104
 
75
105
  extra_query: Add additional query parameters to the request
@@ -88,6 +118,7 @@ class SearchResource(SyncAPIResource):
88
118
  "last_updated_before_filter": last_updated_before_filter,
89
119
  "max_results": max_results,
90
120
  "max_tokens": max_tokens,
121
+ "max_tokens_per_page": max_tokens_per_page,
91
122
  "safe_search": safe_search,
92
123
  "search_after_date_filter": search_after_date_filter,
93
124
  "search_before_date_filter": search_before_date_filter,
@@ -133,6 +164,7 @@ class AsyncSearchResource(AsyncAPIResource):
133
164
  last_updated_before_filter: Optional[str] | NotGiven = NOT_GIVEN,
134
165
  max_results: int | NotGiven = NOT_GIVEN,
135
166
  max_tokens: int | NotGiven = NOT_GIVEN,
167
+ max_tokens_per_page: int | NotGiven = NOT_GIVEN,
136
168
  safe_search: Optional[bool] | NotGiven = NOT_GIVEN,
137
169
  search_after_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
138
170
  search_before_date_filter: Optional[str] | NotGiven = NOT_GIVEN,
@@ -147,9 +179,38 @@ class AsyncSearchResource(AsyncAPIResource):
147
179
  timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
148
180
  ) -> SearchCreateResponse:
149
181
  """
150
- Search
182
+ Perform a search query with various filtering and customization options
151
183
 
152
184
  Args:
185
+ query: Search query string or array of query strings to search for
186
+
187
+ country: Country code to bias search results towards (e.g., 'US', 'GB', 'CA')
188
+
189
+ last_updated_after_filter: Only include results last updated after this date (ISO 8601 format: YYYY-MM-DD)
190
+
191
+ last_updated_before_filter: Only include results last updated before this date (ISO 8601 format: YYYY-MM-DD)
192
+
193
+ max_results: Maximum number of search results to return
194
+
195
+ max_tokens: Maximum number of tokens to return across all results
196
+
197
+ max_tokens_per_page: Maximum number of tokens to return per individual search result
198
+
199
+ safe_search: Enable safe search filtering to exclude adult content
200
+
201
+ search_after_date_filter: Only include results published after this date (ISO 8601 format: YYYY-MM-DD)
202
+
203
+ search_before_date_filter: Only include results published before this date (ISO 8601 format: YYYY-MM-DD)
204
+
205
+ search_domain_filter: List of domains to restrict search results to (e.g., ['example.com',
206
+ 'another.com'])
207
+
208
+ search_mode: Type of search to perform: 'web' for general web search, 'academic' for
209
+ scholarly articles, 'sec' for SEC filings
210
+
211
+ search_recency_filter: Filter results by how recently they were published (hour, day, week, month, or
212
+ year)
213
+
153
214
  extra_headers: Send extra headers
154
215
 
155
216
  extra_query: Add additional query parameters to the request
@@ -168,6 +229,7 @@ class AsyncSearchResource(AsyncAPIResource):
168
229
  "last_updated_before_filter": last_updated_before_filter,
169
230
  "max_results": max_results,
170
231
  "max_tokens": max_tokens,
232
+ "max_tokens_per_page": max_tokens_per_page,
171
233
  "safe_search": safe_search,
172
234
  "search_after_date_filter": search_after_date_filter,
173
235
  "search_before_date_filter": search_before_date_filter,
@@ -2,5 +2,13 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from .shared import (
6
+ UsageInfo as UsageInfo,
7
+ ChatChoice as ChatChoice,
8
+ ChatMessage as ChatMessage,
9
+ SearchResult as SearchResult,
10
+ )
5
11
  from .search_create_params import SearchCreateParams as SearchCreateParams
12
+ from .content_create_params import ContentCreateParams as ContentCreateParams
6
13
  from .search_create_response import SearchCreateResponse as SearchCreateResponse
14
+ from .content_create_response import ContentCreateResponse as ContentCreateResponse
@@ -0,0 +1,3 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
@@ -0,0 +1,9 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from .completion_list_params import CompletionListParams as CompletionListParams
6
+ from .completion_get_response import CompletionGetResponse as CompletionGetResponse
7
+ from .completion_create_params import CompletionCreateParams as CompletionCreateParams
8
+ from .completion_list_response import CompletionListResponse as CompletionListResponse
9
+ from .completion_create_response import CompletionCreateResponse as CompletionCreateResponse