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
1 change: 1 addition & 0 deletions fern/products/sdks/deep-dives/generated-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Your SDK users can configure individual requests using language-specific options
| Timeouts | Configure request timeouts (default: 30 seconds for C# and PHP, 60 seconds for all other languages) | All languages |
| [Retries](/sdks/deep-dives/retries-with-backoff) | Configure maximum retries (default: 2 with exponential backoff for 408, 429, and 5xx responses) | All languages except Ruby and Swift |
| Custom HTTP client | Override the default HTTP client for unsupported environments or custom requirements | TypeScript, Python, Java, PHP, and Swift |
| [aiohttp transport](/learn/sdks/generators/python/aiohttp-support) | Opt into `aiohttp` as the async HTTP transport to resolve DNS concurrency bottlenecks | Python only |
| Custom headers | Send additional headers with any request | TypeScript, Java, and Swift |
| Raw response data | Access response headers alongside parsed data | TypeScript, Python, and Go |
| Query parameters | Add extra query string parameters | TypeScript and Swift |
Expand Down
53 changes: 53 additions & 0 deletions fern/products/sdks/generators/python/aiohttp-support.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: aiohttp support
headline: aiohttp support (Python)
description: Fern-generated Python SDKs auto-detect aiohttp for async HTTP operations, resolving DNS concurrency issues without requiring code changes.
---


Every Fern-generated Python SDK ships with opt-in support for [aiohttp](https://docs.aiohttp.org/) as an async HTTP transport. When the `aiohttp` optional extra is installed, the generated async client uses it automatically instead of the default `httpx.AsyncClient`.

This matters for SDKs that make many concurrent async API calls: `httpx.AsyncClient` serializes DNS lookups via `asyncio.getaddrinfo` under heavy concurrency, while `aiohttp` uses its own resolver to avoid that bottleneck.

No generator configuration is required. The `[aiohttp]` extra, runtime auto-detection, and CI coverage are generated for every Python SDK.

## Installation

SDK users opt in by installing the `aiohttp` extra alongside your package:

```bash
pip install your-package[aiohttp]
```

Or with Poetry:

```bash
poetry add "your-package[aiohttp]"
```

If a user passes a custom `httpx_client` to the async client constructor, auto-detection is skipped and the provided client is used as-is.

## Generated dependencies

The generated `pyproject.toml` includes an `[aiohttp]` optional dependency group:

```toml title="pyproject.toml"
[tool.poetry.extras]
aiohttp = ["aiohttp", "httpx-aiohttp"]
```

If you define your own extras via the [`extras`](/sdks/overview/python/configuration#extras) configuration option in `generators.yml`, the built-in `aiohttp` extra is preserved and merged with your custom configuration.

## CI testing

The generated GitHub Actions workflow runs tests in two passes so both transport paths are covered:

1. Standard tests without the aiohttp extra.
2. Tests marked `@pytest.mark.aiohttp` with the extra installed.

To verify the aiohttp path locally:

```bash
poetry install --extras aiohttp
poetry run pytest -m aiohttp
```
2 changes: 2 additions & 0 deletions fern/products/sdks/generators/python/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ Specify additional development dependencies to include in the generated SDK's se

<ParamField path="extras" type="object" default="{}" required={false} toc={true}>
Define optional dependency groups that users can install with your package using pip extras (e.g., `pip install your-package[extra-name]`).

Custom extras are merged with the built-in [`aiohttp` extra](/learn/sdks/generators/python/aiohttp-support) at generation time, so declaring your own extras won't clobber it.
</ParamField>

<ParamField path="flat_layout" type="bool" default="false" required={false} toc={true}>
Expand Down
3 changes: 3 additions & 0 deletions fern/products/sdks/sdks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ navigation:
- page: Dynamic authentication
path: ./generators/python/dynamic-authentication.mdx
slug: dynamic-authentication
- page: aiohttp support
path: ./generators/python/aiohttp-support.mdx
slug: aiohttp-support
- changelog: ./generators/python/changelog
slug: changelog
- link: Customer showcase
Expand Down
Loading