22
33from __future__ import annotations
44
5- from typing import Optional
5+ from typing import List , Optional
66from typing_extensions import Literal
77
88import httpx
99
1010from ..._types import Body , Omit , Query , Headers , NotGiven , SequenceNotStr , omit , not_given
11- from ..._utils import maybe_transform , async_maybe_transform
11+ from ..._utils import is_given , maybe_transform , strip_not_given , async_maybe_transform
1212from .task_run import (
1313 TaskRunResource ,
1414 AsyncTaskRunResource ,
3333 async_to_raw_response_wrapper ,
3434 async_to_streamed_response_wrapper ,
3535)
36- from ...types .beta import beta_search_params
36+ from ...types .beta import beta_search_params , beta_extract_params
3737from ..._base_client import make_request_options
3838from ...types .beta .search_result import SearchResult
39+ from ...types .beta .extract_response import ExtractResponse
40+ from ...types .beta .parallel_beta_param import ParallelBetaParam
3941from ...types .shared_params .source_policy import SourcePolicy
4042
4143__all__ = ["BetaResource" , "AsyncBetaResource" ]
@@ -69,15 +71,89 @@ def with_streaming_response(self) -> BetaResourceWithStreamingResponse:
6971 """
7072 return BetaResourceWithStreamingResponse (self )
7173
74+ def extract (
75+ self ,
76+ * ,
77+ urls : SequenceNotStr [str ],
78+ excerpts : beta_extract_params .Excerpts | Omit = omit ,
79+ fetch_policy : Optional [beta_extract_params .FetchPolicy ] | Omit = omit ,
80+ full_content : beta_extract_params .FullContent | Omit = omit ,
81+ objective : Optional [str ] | Omit = omit ,
82+ search_queries : Optional [SequenceNotStr [str ]] | Omit = omit ,
83+ betas : List [ParallelBetaParam ] | Omit = omit ,
84+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
85+ # The extra values given here take precedence over values defined on the client or passed to this method.
86+ extra_headers : Headers | None = None ,
87+ extra_query : Query | None = None ,
88+ extra_body : Body | None = None ,
89+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
90+ ) -> ExtractResponse :
91+ """
92+ Extracts relevant content from specific web URLs.
93+
94+ To access this endpoint, pass the `parallel-beta` header with the value
95+ `search-extract-2025-10-10`.
96+
97+ Args:
98+ excerpts: Include excerpts from each URL relevant to the search objective and queries.
99+ Note that if neither objective nor search_queries is provided, excerpts are
100+ redundant with full content.
101+
102+ fetch_policy: Fetch policy.
103+
104+ Determines when to return content from the cache (faster) vs fetching live
105+ content (fresher).
106+
107+ full_content: Include full content from each URL. Note that if neither objective nor
108+ search_queries is provided, excerpts are redundant with full content.
109+
110+ objective: If provided, focuses extracted content on the specified search objective.
111+
112+ search_queries: If provided, focuses extracted content on the specified keyword search queries.
113+
114+ betas: Optional header to specify the beta version(s) to enable.
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+ extra_headers = {
125+ ** strip_not_given ({"parallel-beta" : "," .join (str (e ) for e in betas ) if is_given (betas ) else not_given }),
126+ ** (extra_headers or {}),
127+ }
128+ return self ._post (
129+ "/v1beta/extract" ,
130+ body = maybe_transform (
131+ {
132+ "urls" : urls ,
133+ "excerpts" : excerpts ,
134+ "fetch_policy" : fetch_policy ,
135+ "full_content" : full_content ,
136+ "objective" : objective ,
137+ "search_queries" : search_queries ,
138+ },
139+ beta_extract_params .BetaExtractParams ,
140+ ),
141+ options = make_request_options (
142+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
143+ ),
144+ cast_to = ExtractResponse ,
145+ )
146+
72147 def search (
73148 self ,
74149 * ,
75150 max_chars_per_result : Optional [int ] | Omit = omit ,
76151 max_results : Optional [int ] | Omit = omit ,
77152 objective : Optional [str ] | Omit = omit ,
78- processor : Literal ["base" , "pro" ] | Omit = omit ,
153+ processor : Optional [ Literal ["base" , "pro" ] ] | Omit = omit ,
79154 search_queries : Optional [SequenceNotStr [str ]] | Omit = omit ,
80155 source_policy : Optional [SourcePolicy ] | Omit = omit ,
156+ betas : List [ParallelBetaParam ] | Omit = omit ,
81157 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
82158 # The extra values given here take precedence over values defined on the client or passed to this method.
83159 extra_headers : Headers | None = None ,
@@ -109,6 +185,8 @@ def search(
109185
110186 This policy governs which sources are allowed/disallowed in results.
111187
188+ betas: Optional header to specify the beta version(s) to enable.
189+
112190 extra_headers: Send extra headers
113191
114192 extra_query: Add additional query parameters to the request
@@ -117,6 +195,10 @@ def search(
117195
118196 timeout: Override the client-level default timeout for this request, in seconds
119197 """
198+ extra_headers = {
199+ ** strip_not_given ({"parallel-beta" : "," .join (str (e ) for e in betas ) if is_given (betas ) else not_given }),
200+ ** (extra_headers or {}),
201+ }
120202 return self ._post (
121203 "/v1beta/search" ,
122204 body = maybe_transform (
@@ -165,15 +247,89 @@ def with_streaming_response(self) -> AsyncBetaResourceWithStreamingResponse:
165247 """
166248 return AsyncBetaResourceWithStreamingResponse (self )
167249
250+ async def extract (
251+ self ,
252+ * ,
253+ urls : SequenceNotStr [str ],
254+ excerpts : beta_extract_params .Excerpts | Omit = omit ,
255+ fetch_policy : Optional [beta_extract_params .FetchPolicy ] | Omit = omit ,
256+ full_content : beta_extract_params .FullContent | Omit = omit ,
257+ objective : Optional [str ] | Omit = omit ,
258+ search_queries : Optional [SequenceNotStr [str ]] | Omit = omit ,
259+ betas : List [ParallelBetaParam ] | Omit = omit ,
260+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
261+ # The extra values given here take precedence over values defined on the client or passed to this method.
262+ extra_headers : Headers | None = None ,
263+ extra_query : Query | None = None ,
264+ extra_body : Body | None = None ,
265+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
266+ ) -> ExtractResponse :
267+ """
268+ Extracts relevant content from specific web URLs.
269+
270+ To access this endpoint, pass the `parallel-beta` header with the value
271+ `search-extract-2025-10-10`.
272+
273+ Args:
274+ excerpts: Include excerpts from each URL relevant to the search objective and queries.
275+ Note that if neither objective nor search_queries is provided, excerpts are
276+ redundant with full content.
277+
278+ fetch_policy: Fetch policy.
279+
280+ Determines when to return content from the cache (faster) vs fetching live
281+ content (fresher).
282+
283+ full_content: Include full content from each URL. Note that if neither objective nor
284+ search_queries is provided, excerpts are redundant with full content.
285+
286+ objective: If provided, focuses extracted content on the specified search objective.
287+
288+ search_queries: If provided, focuses extracted content on the specified keyword search queries.
289+
290+ betas: Optional header to specify the beta version(s) to enable.
291+
292+ extra_headers: Send extra headers
293+
294+ extra_query: Add additional query parameters to the request
295+
296+ extra_body: Add additional JSON properties to the request
297+
298+ timeout: Override the client-level default timeout for this request, in seconds
299+ """
300+ extra_headers = {
301+ ** strip_not_given ({"parallel-beta" : "," .join (str (e ) for e in betas ) if is_given (betas ) else not_given }),
302+ ** (extra_headers or {}),
303+ }
304+ return await self ._post (
305+ "/v1beta/extract" ,
306+ body = await async_maybe_transform (
307+ {
308+ "urls" : urls ,
309+ "excerpts" : excerpts ,
310+ "fetch_policy" : fetch_policy ,
311+ "full_content" : full_content ,
312+ "objective" : objective ,
313+ "search_queries" : search_queries ,
314+ },
315+ beta_extract_params .BetaExtractParams ,
316+ ),
317+ options = make_request_options (
318+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
319+ ),
320+ cast_to = ExtractResponse ,
321+ )
322+
168323 async def search (
169324 self ,
170325 * ,
171326 max_chars_per_result : Optional [int ] | Omit = omit ,
172327 max_results : Optional [int ] | Omit = omit ,
173328 objective : Optional [str ] | Omit = omit ,
174- processor : Literal ["base" , "pro" ] | Omit = omit ,
329+ processor : Optional [ Literal ["base" , "pro" ] ] | Omit = omit ,
175330 search_queries : Optional [SequenceNotStr [str ]] | Omit = omit ,
176331 source_policy : Optional [SourcePolicy ] | Omit = omit ,
332+ betas : List [ParallelBetaParam ] | Omit = omit ,
177333 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
178334 # The extra values given here take precedence over values defined on the client or passed to this method.
179335 extra_headers : Headers | None = None ,
@@ -205,6 +361,8 @@ async def search(
205361
206362 This policy governs which sources are allowed/disallowed in results.
207363
364+ betas: Optional header to specify the beta version(s) to enable.
365+
208366 extra_headers: Send extra headers
209367
210368 extra_query: Add additional query parameters to the request
@@ -213,6 +371,10 @@ async def search(
213371
214372 timeout: Override the client-level default timeout for this request, in seconds
215373 """
374+ extra_headers = {
375+ ** strip_not_given ({"parallel-beta" : "," .join (str (e ) for e in betas ) if is_given (betas ) else not_given }),
376+ ** (extra_headers or {}),
377+ }
216378 return await self ._post (
217379 "/v1beta/search" ,
218380 body = await async_maybe_transform (
@@ -237,6 +399,9 @@ class BetaResourceWithRawResponse:
237399 def __init__ (self , beta : BetaResource ) -> None :
238400 self ._beta = beta
239401
402+ self .extract = to_raw_response_wrapper (
403+ beta .extract ,
404+ )
240405 self .search = to_raw_response_wrapper (
241406 beta .search ,
242407 )
@@ -254,6 +419,9 @@ class AsyncBetaResourceWithRawResponse:
254419 def __init__ (self , beta : AsyncBetaResource ) -> None :
255420 self ._beta = beta
256421
422+ self .extract = async_to_raw_response_wrapper (
423+ beta .extract ,
424+ )
257425 self .search = async_to_raw_response_wrapper (
258426 beta .search ,
259427 )
@@ -271,6 +439,9 @@ class BetaResourceWithStreamingResponse:
271439 def __init__ (self , beta : BetaResource ) -> None :
272440 self ._beta = beta
273441
442+ self .extract = to_streamed_response_wrapper (
443+ beta .extract ,
444+ )
274445 self .search = to_streamed_response_wrapper (
275446 beta .search ,
276447 )
@@ -288,6 +459,9 @@ class AsyncBetaResourceWithStreamingResponse:
288459 def __init__ (self , beta : AsyncBetaResource ) -> None :
289460 self ._beta = beta
290461
462+ self .extract = async_to_streamed_response_wrapper (
463+ beta .extract ,
464+ )
291465 self .search = async_to_streamed_response_wrapper (
292466 beta .search ,
293467 )
0 commit comments