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.37.0"
".": "0.38.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: 11
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai/perplexity-bf28ac7f1a24d27aa2ba57b65aaf7fc99f492d28ab969f570d86abc339c842e9.yml
openapi_spec_hash: 2f086349fe584965e24e58bddbb91672
config_hash: 059988c88f0dc18e9e393daed94b5eb6
configured_endpoints: 13
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai/perplexity-6a9e741f72f36fa6c1f8ece842ba1616376107badbfdeaf6e88c5db7b9412437.yml
openapi_spec_hash: 76d7c6e6e7f84a1de30b869a7579e6b6
config_hash: 3f1487a29a16f85810ba4d77134da232
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.38.0 (2026-06-08)

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

### Features

* **responses:** add files subresource for sandbox file retrieval ([0dbfd9c](https://github.com/perplexityai/perplexity-py/commit/0dbfd9ce064505723a5dce4b40be6a766a08a733))

## 0.37.0 (2026-06-02)

Full Changelog: [v0.36.0...v0.37.0](https://github.com/perplexityai/perplexity-py/compare/v0.36.0...v0.37.0)
Expand Down
13 changes: 11 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ from perplexity.types import (
FunctionToolParam,
InputItemParam,
OutputItem,
ResponseFile,
ResponseFileList,
ResponseStreamChunk,
ResponseCreateParams,
ResponsesUsage,
Expand All @@ -68,8 +70,15 @@ from perplexity.types import (

Methods:

- <code title="post /v1/responses">client.responses.<a href="./src/perplexity/resources/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.py">retrieve</a>(response_id) -> <a href="./src/perplexity/types/response_retrieve_response.py">ResponseRetrieveResponse</a></code>
- <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>

## Files

Methods:

- <code title="get /v1/responses/{response_id}/files">client.responses.files.<a href="./src/perplexity/resources/responses/files.py">list</a>(response_id) -> <a href="./src/perplexity/types/response_file_list.py">ResponseFileList</a></code>
- <code title="get /v1/responses/{response_id}/files/{file_id}/content">client.responses.files.<a href="./src/perplexity/resources/responses/files.py">content</a>(file_id, \*, response_id) -> BinaryAPIResponse</code>

# Embeddings

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.37.0"
version = "0.38.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/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
from .resources import chat, async_, search, browser, responses, embeddings, contextualized_embeddings
from .resources.search import SearchResource, AsyncSearchResource
from .resources.chat.chat import ChatResource, AsyncChatResource
from .resources.responses import ResponsesResource, AsyncResponsesResource
from .resources.embeddings import EmbeddingsResource, AsyncEmbeddingsResource
from .resources.async_.async_ import AsyncResource, AsyncAsyncResource
from .resources.browser.browser import BrowserResource, AsyncBrowserResource
from .resources.responses.responses import ResponsesResource, AsyncResponsesResource
from .resources.contextualized_embeddings import (
ContextualizedEmbeddingsResource,
AsyncContextualizedEmbeddingsResource,
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.37.0" # x-release-please-version
__version__ = "0.38.0" # x-release-please-version
33 changes: 33 additions & 0 deletions src/perplexity/resources/responses/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .files import (
FilesResource,
AsyncFilesResource,
FilesResourceWithRawResponse,
AsyncFilesResourceWithRawResponse,
FilesResourceWithStreamingResponse,
AsyncFilesResourceWithStreamingResponse,
)
from .responses import (
ResponsesResource,
AsyncResponsesResource,
ResponsesResourceWithRawResponse,
AsyncResponsesResourceWithRawResponse,
ResponsesResourceWithStreamingResponse,
AsyncResponsesResourceWithStreamingResponse,
)

__all__ = [
"FilesResource",
"AsyncFilesResource",
"FilesResourceWithRawResponse",
"AsyncFilesResourceWithRawResponse",
"FilesResourceWithStreamingResponse",
"AsyncFilesResourceWithStreamingResponse",
"ResponsesResource",
"AsyncResponsesResource",
"ResponsesResourceWithRawResponse",
"AsyncResponsesResourceWithRawResponse",
"ResponsesResourceWithStreamingResponse",
"AsyncResponsesResourceWithStreamingResponse",
]
272 changes: 272 additions & 0 deletions src/perplexity/resources/responses/files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

import httpx

from ..._types import Body, Query, Headers, NotGiven, not_given
from ..._utils import path_template
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
BinaryAPIResponse,
AsyncBinaryAPIResponse,
StreamedBinaryAPIResponse,
AsyncStreamedBinaryAPIResponse,
to_raw_response_wrapper,
to_streamed_response_wrapper,
async_to_raw_response_wrapper,
to_custom_raw_response_wrapper,
async_to_streamed_response_wrapper,
to_custom_streamed_response_wrapper,
async_to_custom_raw_response_wrapper,
async_to_custom_streamed_response_wrapper,
)
from ..._base_client import make_request_options
from ...types.response_file_list import ResponseFileList

__all__ = ["FilesResource", "AsyncFilesResource"]


class FilesResource(SyncAPIResource):
@cached_property
def with_raw_response(self) -> FilesResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
"""
return FilesResourceWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> FilesResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.

For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
"""
return FilesResourceWithStreamingResponse(self)

def list(
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,
) -> ResponseFileList:
"""
Lists the files the model delivered via the share_file tool during this
response.

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._get(
path_template("/v1/responses/{response_id}/files", response_id=response_id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=ResponseFileList,
)

def content(
self,
file_id: str,
*,
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,
) -> BinaryAPIResponse:
"""Streams the raw bytes of one shared file.

Content-Disposition carries the
original filename.

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}")
if not file_id:
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})}
return self._get(
path_template(
"/v1/responses/{response_id}/files/{file_id}/content", response_id=response_id, file_id=file_id
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=BinaryAPIResponse,
)


class AsyncFilesResource(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncFilesResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/perplexityai/perplexity-py#accessing-raw-response-data-eg-headers
"""
return AsyncFilesResourceWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> AsyncFilesResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.

For more information, see https://www.github.com/perplexityai/perplexity-py#with_streaming_response
"""
return AsyncFilesResourceWithStreamingResponse(self)

async def list(
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,
) -> ResponseFileList:
"""
Lists the files the model delivered via the share_file tool during this
response.

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._get(
path_template("/v1/responses/{response_id}/files", response_id=response_id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=ResponseFileList,
)

async def content(
self,
file_id: str,
*,
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,
) -> AsyncBinaryAPIResponse:
"""Streams the raw bytes of one shared file.

Content-Disposition carries the
original filename.

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}")
if not file_id:
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})}
return await self._get(
path_template(
"/v1/responses/{response_id}/files/{file_id}/content", response_id=response_id, file_id=file_id
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=AsyncBinaryAPIResponse,
)


class FilesResourceWithRawResponse:
def __init__(self, files: FilesResource) -> None:
self._files = files

self.list = to_raw_response_wrapper(
files.list,
)
self.content = to_custom_raw_response_wrapper(
files.content,
BinaryAPIResponse,
)


class AsyncFilesResourceWithRawResponse:
def __init__(self, files: AsyncFilesResource) -> None:
self._files = files

self.list = async_to_raw_response_wrapper(
files.list,
)
self.content = async_to_custom_raw_response_wrapper(
files.content,
AsyncBinaryAPIResponse,
)


class FilesResourceWithStreamingResponse:
def __init__(self, files: FilesResource) -> None:
self._files = files

self.list = to_streamed_response_wrapper(
files.list,
)
self.content = to_custom_streamed_response_wrapper(
files.content,
StreamedBinaryAPIResponse,
)


class AsyncFilesResourceWithStreamingResponse:
def __init__(self, files: AsyncFilesResource) -> None:
self._files = files

self.list = async_to_streamed_response_wrapper(
files.list,
)
self.content = async_to_custom_streamed_response_wrapper(
files.content,
AsyncStreamedBinaryAPIResponse,
)
Loading