Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.40.0"
".": "0.41.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 13
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai/perplexity-f15eee99fec8579d1a543c4dfdc74f7633cc8e82004634be302f9c053cdc3934.yml
openapi_spec_hash: 5fe9895246acf0b07b2283b938a018fe
config_hash: 3f1487a29a16f85810ba4d77134da232
configured_endpoints: 14
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai/perplexity-0503b4a7abdf2cb4ad14af7b17bca179796f868729dfdfc8e09692e0dca99dda.yml
openapi_spec_hash: 629684ee997a5334c38080865371b0fa
config_hash: 25a3795c176e58c4127154760d603480
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.41.0 (2026-07-15)

Full Changelog: [v0.40.0...v0.41.0](https://github.com/perplexityai/perplexity-py/compare/v0.40.0...v0.41.0)

### Features

* **api:** manual updates ([7c20311](https://github.com/perplexityai/perplexity-py/commit/7c203118363c6a28fe1e1559afa3cf15a295d36a))

## 0.40.0 (2026-07-09)

Full Changelog: [v0.39.0...v0.40.0](https://github.com/perplexityai/perplexity-py/compare/v0.39.0...v0.40.0)
Expand Down
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ from perplexity.types import (
ResponsesUsage,
ResponseCreateResponse,
ResponseRetrieveResponse,
ResponseCancelResponse,
)
```

Methods:

- <code title="post /v1/responses">client.responses.<a href="./src/perplexity/resources/responses/responses.py">create</a>(\*\*<a href="src/perplexity/types/response_create_params.py">params</a>) -> <a href="./src/perplexity/types/response_create_response.py">ResponseCreateResponse</a></code>
- <code title="get /v1/responses/{response_id}">client.responses.<a href="./src/perplexity/resources/responses/responses.py">retrieve</a>(response_id) -> <a href="./src/perplexity/types/response_retrieve_response.py">ResponseRetrieveResponse</a></code>
- <code title="post /v1/responses/{response_id}/cancel">client.responses.<a href="./src/perplexity/resources/responses/responses.py">cancel</a>(response_id) -> <a href="./src/perplexity/types/response_cancel_response.py">ResponseCancelResponse</a></code>

## Files

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "perplexityai"
version = "0.40.0"
version = "0.41.0"
description = "The official Python library for the perplexity API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/perplexity/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "perplexity"
__version__ = "0.40.0" # x-release-please-version
__version__ = "0.41.0" # x-release-please-version
34 changes: 34 additions & 0 deletions src/perplexity/resources/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def create(
ranking_model: Optional[str] | Omit = omit,
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
response_formatting_locale: Optional[str] | Omit = omit,
response_metadata: Optional[Dict[str, object]] | Omit = omit,
return_images: Optional[bool] | Omit = omit,
return_related_questions: Optional[bool] | Omit = omit,
Expand Down Expand Up @@ -121,6 +122,10 @@ def create(
Generate a chat completion response for the given conversation.

Args:
response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style
values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical
form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -168,6 +173,7 @@ def create(
ranking_model: Optional[str] | Omit = omit,
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
response_formatting_locale: Optional[str] | Omit = omit,
response_metadata: Optional[Dict[str, object]] | Omit = omit,
return_images: Optional[bool] | Omit = omit,
return_related_questions: Optional[bool] | Omit = omit,
Expand Down Expand Up @@ -205,6 +211,10 @@ def create(
Generate a chat completion response for the given conversation.

Args:
response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style
values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical
form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -252,6 +262,7 @@ def create(
ranking_model: Optional[str] | Omit = omit,
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
response_formatting_locale: Optional[str] | Omit = omit,
response_metadata: Optional[Dict[str, object]] | Omit = omit,
return_images: Optional[bool] | Omit = omit,
return_related_questions: Optional[bool] | Omit = omit,
Expand Down Expand Up @@ -289,6 +300,10 @@ def create(
Generate a chat completion response for the given conversation.

Args:
response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style
values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical
form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -335,6 +350,7 @@ def create(
ranking_model: Optional[str] | Omit = omit,
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
response_formatting_locale: Optional[str] | Omit = omit,
response_metadata: Optional[Dict[str, object]] | Omit = omit,
return_images: Optional[bool] | Omit = omit,
return_related_questions: Optional[bool] | Omit = omit,
Expand Down Expand Up @@ -405,6 +421,7 @@ def create(
"ranking_model": ranking_model,
"reasoning_effort": reasoning_effort,
"response_format": response_format,
"response_formatting_locale": response_formatting_locale,
"response_metadata": response_metadata,
"return_images": return_images,
"return_related_questions": return_related_questions,
Expand Down Expand Up @@ -502,6 +519,7 @@ async def create(
ranking_model: Optional[str] | Omit = omit,
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
response_formatting_locale: Optional[str] | Omit = omit,
response_metadata: Optional[Dict[str, object]] | Omit = omit,
return_images: Optional[bool] | Omit = omit,
return_related_questions: Optional[bool] | Omit = omit,
Expand Down Expand Up @@ -540,6 +558,10 @@ async def create(
Generate a chat completion response for the given conversation.

Args:
response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style
values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical
form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -587,6 +609,7 @@ async def create(
ranking_model: Optional[str] | Omit = omit,
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
response_formatting_locale: Optional[str] | Omit = omit,
response_metadata: Optional[Dict[str, object]] | Omit = omit,
return_images: Optional[bool] | Omit = omit,
return_related_questions: Optional[bool] | Omit = omit,
Expand Down Expand Up @@ -624,6 +647,10 @@ async def create(
Generate a chat completion response for the given conversation.

Args:
response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style
values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical
form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -671,6 +698,7 @@ async def create(
ranking_model: Optional[str] | Omit = omit,
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
response_formatting_locale: Optional[str] | Omit = omit,
response_metadata: Optional[Dict[str, object]] | Omit = omit,
return_images: Optional[bool] | Omit = omit,
return_related_questions: Optional[bool] | Omit = omit,
Expand Down Expand Up @@ -708,6 +736,10 @@ async def create(
Generate a chat completion response for the given conversation.

Args:
response_formatting_locale: Optional locale tag used for response formatting conventions. Locale-style
values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical
form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -754,6 +786,7 @@ async def create(
ranking_model: Optional[str] | Omit = omit,
reasoning_effort: Optional[Literal["minimal", "low", "medium", "high"]] | Omit = omit,
response_format: Optional[completion_create_params.ResponseFormat] | Omit = omit,
response_formatting_locale: Optional[str] | Omit = omit,
response_metadata: Optional[Dict[str, object]] | Omit = omit,
return_images: Optional[bool] | Omit = omit,
return_related_questions: Optional[bool] | Omit = omit,
Expand Down Expand Up @@ -824,6 +857,7 @@ async def create(
"ranking_model": ranking_model,
"reasoning_effort": reasoning_effort,
"response_format": response_format,
"response_formatting_locale": response_formatting_locale,
"response_metadata": response_metadata,
"return_images": return_images,
"return_related_questions": return_related_questions,
Expand Down
93 changes: 93 additions & 0 deletions src/perplexity/resources/responses/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from ..._base_client import make_request_options
from ...types.input_item_param import InputItemParam
from ...types.response_stream_chunk import ResponseStreamChunk
from ...types.response_cancel_response import ResponseCancelResponse
from ...types.response_create_response import ResponseCreateResponse
from ...types.response_retrieve_response import ResponseRetrieveResponse
from ...types.shared_params.response_format import ResponseFormat
Expand Down Expand Up @@ -405,6 +406,46 @@ def retrieve(
cast_to=ResponseRetrieveResponse,
)

def cancel(
self,
response_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ResponseCancelResponse:
"""Request cancellation of a response.

Acts on durable state, so it works for
background responses that outlive the client connection as well as durably
routed foreground responses. The cancel is asynchronous: a 200 acknowledges the
request (status `cancelling`) and the run stops shortly after. Poll the retrieve
endpoint for the terminal status. Cancelling a run that is already terminal
returns 400. Ownership is enforced server side; an unknown id, or a response
belonging to a different account, returns 404.

Args:
extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not response_id:
raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}")
return self._post(
path_template("/v1/responses/{response_id}/cancel", response_id=response_id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=ResponseCancelResponse,
)


class AsyncResponsesResource(AsyncAPIResource):
@cached_property
Expand Down Expand Up @@ -774,6 +815,46 @@ async def retrieve(
cast_to=ResponseRetrieveResponse,
)

async def cancel(
self,
response_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ResponseCancelResponse:
"""Request cancellation of a response.

Acts on durable state, so it works for
background responses that outlive the client connection as well as durably
routed foreground responses. The cancel is asynchronous: a 200 acknowledges the
request (status `cancelling`) and the run stops shortly after. Poll the retrieve
endpoint for the terminal status. Cancelling a run that is already terminal
returns 400. Ownership is enforced server side; an unknown id, or a response
belonging to a different account, returns 404.

Args:
extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not response_id:
raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}")
return await self._post(
path_template("/v1/responses/{response_id}/cancel", response_id=response_id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=ResponseCancelResponse,
)


class ResponsesResourceWithRawResponse:
def __init__(self, responses: ResponsesResource) -> None:
Expand All @@ -785,6 +866,9 @@ def __init__(self, responses: ResponsesResource) -> None:
self.retrieve = to_raw_response_wrapper(
responses.retrieve,
)
self.cancel = to_raw_response_wrapper(
responses.cancel,
)

@cached_property
def files(self) -> FilesResourceWithRawResponse:
Expand All @@ -801,6 +885,9 @@ def __init__(self, responses: AsyncResponsesResource) -> None:
self.retrieve = async_to_raw_response_wrapper(
responses.retrieve,
)
self.cancel = async_to_raw_response_wrapper(
responses.cancel,
)

@cached_property
def files(self) -> AsyncFilesResourceWithRawResponse:
Expand All @@ -817,6 +904,9 @@ def __init__(self, responses: ResponsesResource) -> None:
self.retrieve = to_streamed_response_wrapper(
responses.retrieve,
)
self.cancel = to_streamed_response_wrapper(
responses.cancel,
)

@cached_property
def files(self) -> FilesResourceWithStreamingResponse:
Expand All @@ -833,6 +923,9 @@ def __init__(self, responses: AsyncResponsesResource) -> None:
self.retrieve = async_to_streamed_response_wrapper(
responses.retrieve,
)
self.cancel = async_to_streamed_response_wrapper(
responses.cancel,
)

@cached_property
def files(self) -> AsyncFilesResourceWithStreamingResponse:
Expand Down
1 change: 1 addition & 0 deletions src/perplexity/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .response_create_params import ResponseCreateParams as ResponseCreateParams
from .search_create_response import SearchCreateResponse as SearchCreateResponse
from .embedding_create_params import EmbeddingCreateParams as EmbeddingCreateParams
from .response_cancel_response import ResponseCancelResponse as ResponseCancelResponse
from .response_create_response import ResponseCreateResponse as ResponseCreateResponse
from .embedding_create_response import EmbeddingCreateResponse as EmbeddingCreateResponse
from .function_call_output_item import FunctionCallOutputItem as FunctionCallOutputItem
Expand Down
7 changes: 7 additions & 0 deletions src/perplexity/types/async_/chat/completion_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ class Request(TypedDict, total=False):

response_format: Optional[RequestResponseFormat]

response_formatting_locale: Optional[str]
"""Optional locale tag used for response formatting conventions.

Locale-style values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the
canonical form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored.
"""

response_metadata: Optional[Dict[str, object]]

return_images: Optional[bool]
Expand Down
7 changes: 7 additions & 0 deletions src/perplexity/types/chat/completion_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ class CompletionCreateParamsBase(TypedDict, total=False):

response_format: Optional[ResponseFormat]

response_formatting_locale: Optional[str]
"""Optional locale tag used for response formatting conventions.

Locale-style values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the
canonical form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored.
"""

response_metadata: Optional[Dict[str, object]]

return_images: Optional[bool]
Expand Down
Loading