BaseAsyncPage Class — anthropic-sdk-python Architecture
Architecture documentation for the BaseAsyncPage class in _base_client.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 974ecd7e_1e02_c86a_c8bf_b2cfbc7e936e["BaseAsyncPage"] 31e60ad8_cac8_652d_176d_4f7cf7dda1ad["_base_client.py"] 974ecd7e_1e02_c86a_c8bf_b2cfbc7e936e -->|defined in| 31e60ad8_cac8_652d_176d_4f7cf7dda1ad 8020c6f2_f57e_e98f_ae36_1d4aacd2956d["_set_private_attributes()"] 974ecd7e_1e02_c86a_c8bf_b2cfbc7e936e -->|method| 8020c6f2_f57e_e98f_ae36_1d4aacd2956d 31ef0ce0_b025_215f_225c_da41e5e8a88f["__aiter__()"] 974ecd7e_1e02_c86a_c8bf_b2cfbc7e936e -->|method| 31ef0ce0_b025_215f_225c_da41e5e8a88f 35930acd_d2ee_1216_f971_249073823731["iter_pages()"] 974ecd7e_1e02_c86a_c8bf_b2cfbc7e936e -->|method| 35930acd_d2ee_1216_f971_249073823731 3373294a_f5ae_b05d_174c_724dcb380905["get_next_page()"] 974ecd7e_1e02_c86a_c8bf_b2cfbc7e936e -->|method| 3373294a_f5ae_b05d_174c_724dcb380905
Relationship Graph
Source Code
src/anthropic/_base_client.py lines 323–361
class BaseAsyncPage(BasePage[_T], Generic[_T]):
_client: AsyncAPIClient = pydantic.PrivateAttr()
def _set_private_attributes(
self,
model: Type[_T],
client: AsyncAPIClient,
options: FinalRequestOptions,
) -> None:
if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None:
self.__pydantic_private__ = {}
self._model = model
self._client = client
self._options = options
async def __aiter__(self) -> AsyncIterator[_T]:
async for page in self.iter_pages():
for item in page._get_page_items():
yield item
async def iter_pages(self: AsyncPageT) -> AsyncIterator[AsyncPageT]:
page = self
while True:
yield page
if page.has_next_page():
page = await page.get_next_page()
else:
return
async def get_next_page(self: AsyncPageT) -> AsyncPageT:
info = self.next_page_info()
if not info:
raise RuntimeError(
"No next page expected; please check `.has_next_page()` before calling `.get_next_page()`."
)
options = self._info_to_options(info)
return await self._client._request_api_list(self._model, page=self.__class__, options=options)
Domain
Defined In
Source
Frequently Asked Questions
What is the BaseAsyncPage class?
BaseAsyncPage is a class in the anthropic-sdk-python codebase, defined in src/anthropic/_base_client.py.
Where is BaseAsyncPage defined?
BaseAsyncPage is defined in src/anthropic/_base_client.py at line 323.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free