perplexityai 0.4.0__py3-none-any.whl → 0.5.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.

perplexity/_client.py CHANGED
@@ -48,12 +48,12 @@ class Perplexity(SyncAPIClient):
48
48
  with_streaming_response: PerplexityWithStreamedResponse
49
49
 
50
50
  # client options
51
- bearer_token: str
51
+ api_key: str
52
52
 
53
53
  def __init__(
54
54
  self,
55
55
  *,
56
- bearer_token: str | None = None,
56
+ api_key: str | None = None,
57
57
  base_url: str | httpx.URL | None = None,
58
58
  timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
59
59
  max_retries: int = DEFAULT_MAX_RETRIES,
@@ -75,15 +75,15 @@ class Perplexity(SyncAPIClient):
75
75
  ) -> None:
76
76
  """Construct a new synchronous Perplexity client instance.
77
77
 
78
- This automatically infers the `bearer_token` argument from the `PERPLEXITY_API_KEY` environment variable if it is not provided.
78
+ This automatically infers the `api_key` argument from the `PERPLEXITY_API_KEY` environment variable if it is not provided.
79
79
  """
80
- if bearer_token is None:
81
- bearer_token = os.environ.get("PERPLEXITY_API_KEY")
82
- if bearer_token is None:
80
+ if api_key is None:
81
+ api_key = os.environ.get("PERPLEXITY_API_KEY")
82
+ if api_key is None:
83
83
  raise PerplexityError(
84
- "The bearer_token client option must be set either by passing bearer_token to the client or by setting the PERPLEXITY_API_KEY environment variable"
84
+ "The api_key client option must be set either by passing api_key to the client or by setting the PERPLEXITY_API_KEY environment variable"
85
85
  )
86
- self.bearer_token = bearer_token
86
+ self.api_key = api_key
87
87
 
88
88
  if base_url is None:
89
89
  base_url = os.environ.get("PERPLEXITY_BASE_URL")
@@ -113,8 +113,8 @@ class Perplexity(SyncAPIClient):
113
113
  @property
114
114
  @override
115
115
  def auth_headers(self) -> dict[str, str]:
116
- bearer_token = self.bearer_token
117
- return {"Authorization": f"Bearer {bearer_token}"}
116
+ api_key = self.api_key
117
+ return {"Authorization": f"Bearer {api_key}"}
118
118
 
119
119
  @property
120
120
  @override
@@ -128,7 +128,7 @@ class Perplexity(SyncAPIClient):
128
128
  def copy(
129
129
  self,
130
130
  *,
131
- bearer_token: str | None = None,
131
+ api_key: str | None = None,
132
132
  base_url: str | httpx.URL | None = None,
133
133
  timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
134
134
  http_client: httpx.Client | None = None,
@@ -162,7 +162,7 @@ class Perplexity(SyncAPIClient):
162
162
 
163
163
  http_client = http_client or self._client
164
164
  return self.__class__(
165
- bearer_token=bearer_token or self.bearer_token,
165
+ api_key=api_key or self.api_key,
166
166
  base_url=base_url or self.base_url,
167
167
  timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
168
168
  http_client=http_client,
@@ -216,12 +216,12 @@ class AsyncPerplexity(AsyncAPIClient):
216
216
  with_streaming_response: AsyncPerplexityWithStreamedResponse
217
217
 
218
218
  # client options
219
- bearer_token: str
219
+ api_key: str
220
220
 
221
221
  def __init__(
222
222
  self,
223
223
  *,
224
- bearer_token: str | None = None,
224
+ api_key: str | None = None,
225
225
  base_url: str | httpx.URL | None = None,
226
226
  timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
227
227
  max_retries: int = DEFAULT_MAX_RETRIES,
@@ -243,15 +243,15 @@ class AsyncPerplexity(AsyncAPIClient):
243
243
  ) -> None:
244
244
  """Construct a new async AsyncPerplexity client instance.
245
245
 
246
- This automatically infers the `bearer_token` argument from the `PERPLEXITY_API_KEY` environment variable if it is not provided.
246
+ This automatically infers the `api_key` argument from the `PERPLEXITY_API_KEY` environment variable if it is not provided.
247
247
  """
248
- if bearer_token is None:
249
- bearer_token = os.environ.get("PERPLEXITY_API_KEY")
250
- if bearer_token is None:
248
+ if api_key is None:
249
+ api_key = os.environ.get("PERPLEXITY_API_KEY")
250
+ if api_key is None:
251
251
  raise PerplexityError(
252
- "The bearer_token client option must be set either by passing bearer_token to the client or by setting the PERPLEXITY_API_KEY environment variable"
252
+ "The api_key client option must be set either by passing api_key to the client or by setting the PERPLEXITY_API_KEY environment variable"
253
253
  )
254
- self.bearer_token = bearer_token
254
+ self.api_key = api_key
255
255
 
256
256
  if base_url is None:
257
257
  base_url = os.environ.get("PERPLEXITY_BASE_URL")
@@ -281,8 +281,8 @@ class AsyncPerplexity(AsyncAPIClient):
281
281
  @property
282
282
  @override
283
283
  def auth_headers(self) -> dict[str, str]:
284
- bearer_token = self.bearer_token
285
- return {"Authorization": f"Bearer {bearer_token}"}
284
+ api_key = self.api_key
285
+ return {"Authorization": f"Bearer {api_key}"}
286
286
 
287
287
  @property
288
288
  @override
@@ -296,7 +296,7 @@ class AsyncPerplexity(AsyncAPIClient):
296
296
  def copy(
297
297
  self,
298
298
  *,
299
- bearer_token: str | None = None,
299
+ api_key: str | None = None,
300
300
  base_url: str | httpx.URL | None = None,
301
301
  timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
302
302
  http_client: httpx.AsyncClient | None = None,
@@ -330,7 +330,7 @@ class AsyncPerplexity(AsyncAPIClient):
330
330
 
331
331
  http_client = http_client or self._client
332
332
  return self.__class__(
333
- bearer_token=bearer_token or self.bearer_token,
333
+ api_key=api_key or self.api_key,
334
334
  base_url=base_url or self.base_url,
335
335
  timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
336
336
  http_client=http_client,
perplexity/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "perplexity"
4
- __version__ = "0.4.0" # x-release-please-version
4
+ __version__ = "0.5.0" # x-release-please-version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: perplexityai
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: The official Python library for the perplexity API
5
5
  Project-URL: Homepage, https://github.com/ppl-ai/perplexity-py
6
6
  Project-URL: Repository, https://github.com/ppl-ai/perplexity-py
@@ -64,7 +64,7 @@ import os
64
64
  from perplexity import Perplexity
65
65
 
66
66
  client = Perplexity(
67
- bearer_token=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
67
+ api_key=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
68
68
  )
69
69
 
70
70
  search = client.search.create(
@@ -73,10 +73,10 @@ search = client.search.create(
73
73
  print(search.id)
74
74
  ```
75
75
 
76
- While you can provide a `bearer_token` keyword argument,
76
+ While you can provide an `api_key` keyword argument,
77
77
  we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
78
- to add `PERPLEXITY_API_KEY="My Bearer Token"` to your `.env` file
79
- so that your Bearer Token is not stored in source control.
78
+ to add `PERPLEXITY_API_KEY="My API Key"` to your `.env` file
79
+ so that your API Key is not stored in source control.
80
80
 
81
81
  ## Async usage
82
82
 
@@ -88,7 +88,7 @@ import asyncio
88
88
  from perplexity import AsyncPerplexity
89
89
 
90
90
  client = AsyncPerplexity(
91
- bearer_token=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
91
+ api_key=os.environ.get("PERPLEXITY_API_KEY"), # This is the default and can be omitted
92
92
  )
93
93
 
94
94
 
@@ -125,7 +125,7 @@ from perplexity import AsyncPerplexity
125
125
 
126
126
  async def main() -> None:
127
127
  async with AsyncPerplexity(
128
- bearer_token="My Bearer Token",
128
+ api_key="My API Key",
129
129
  http_client=DefaultAioHttpClient(),
130
130
  ) as client:
131
131
  search = await client.search.create(
@@ -1,6 +1,6 @@
1
1
  perplexity/__init__.py,sha256=5epbvK3UiJEgvsBW9Ds6RFB6zObkUxYkA9fIQlgUaXA,2655
2
2
  perplexity/_base_client.py,sha256=DSeMteXutziRGJA9HqJaoLpG7ktzpU2GPcaIgQT1oZQ,67051
3
- perplexity/_client.py,sha256=6Jw9Vj9yIfis_IzBnveUSNcpuOc4Zja4RWjqw8belD4,15250
3
+ perplexity/_client.py,sha256=9vsUrMdMmEO8Hz7yAEQJbTd3jszVlJERm0TMLyCQuBY,15080
4
4
  perplexity/_compat.py,sha256=DQBVORjFb33zch24jzkhM14msvnzY7mmSmgDLaVFUM8,6562
5
5
  perplexity/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
6
6
  perplexity/_exceptions.py,sha256=v-hOXWSDTEtXcn_By7pPml3HjEmG5HXpbE-RK_A6_0Q,3228
@@ -11,7 +11,7 @@ perplexity/_resource.py,sha256=Pgc8KNBsIc1ltJn94uhDcDl0-3n5RLbe3iC2AiiNRnE,1124
11
11
  perplexity/_response.py,sha256=bpqzmVGq6jnivoMkUgt3OI0Rh6xHd6BMcp5PHgSFPb0,28842
12
12
  perplexity/_streaming.py,sha256=SQ61v42gFmNiO57uMFUZMAuDlGE0n_EulkZcPgJXt4U,10116
13
13
  perplexity/_types.py,sha256=XZYv2_G7oQGhQkjI28-TFIMP_yZZV590TRuKAoLJ3wM,7300
14
- perplexity/_version.py,sha256=QazGxOaPhzOlDQUA-C5O4AvYyIhQ_UnLWKUqg_rFehU,162
14
+ perplexity/_version.py,sha256=r7xvBu1r6SCzn2w8FnNCT0y6vSjIPhARbGd3iWRTuDU,162
15
15
  perplexity/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  perplexity/_utils/__init__.py,sha256=7fch0GT9zpNnErbciSpUNa-SjTxxjY6kxHxKMOM4AGs,2305
17
17
  perplexity/_utils/_compat.py,sha256=D8gtAvjJQrDWt9upS0XaG9Rr5l1QhiAx_I_1utT_tt0,1195
@@ -31,7 +31,7 @@ perplexity/resources/search.py,sha256=8wlC-XJbprA1q6Ba_MZQ4aABUKvPnpBuFoY__YWaZO
31
31
  perplexity/types/__init__.py,sha256=yc0WYtyPE_vei_eT8gwY9-g7otC7EJjQpKSdeBcte4Y,279
32
32
  perplexity/types/search_create_params.py,sha256=RR5716GptBeuX99P0VHICzd5fEYsiwKdz1bW8nAlujI,886
33
33
  perplexity/types/search_create_response.py,sha256=lOteaJs4qpULkx5GLtEs6HhetqIBhM0I1AC1moWTeI8,426
34
- perplexityai-0.4.0.dist-info/METADATA,sha256=Md245aFBmveFwVDcB6gAqZ3gEfC8Ze5YMxGPHuvZeEc,13655
35
- perplexityai-0.4.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
36
- perplexityai-0.4.0.dist-info/licenses/LICENSE,sha256=hkCriG3MT4vBhhc0roAOsrCE7IEDr1ywVEMonVHGmAQ,11340
37
- perplexityai-0.4.0.dist-info/RECORD,,
34
+ perplexityai-0.5.0.dist-info/METADATA,sha256=WoYAXSvZB8oFZKmFekj5FLK8z4vzq7mv9CXNEY4ijto,13621
35
+ perplexityai-0.5.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
36
+ perplexityai-0.5.0.dist-info/licenses/LICENSE,sha256=hkCriG3MT4vBhhc0roAOsrCE7IEDr1ywVEMonVHGmAQ,11340
37
+ perplexityai-0.5.0.dist-info/RECORD,,