diff --git a/fern/products/sdks/deep-dives/generated-sdk.mdx b/fern/products/sdks/deep-dives/generated-sdk.mdx index c1378ed1c..7288fec5c 100644 --- a/fern/products/sdks/deep-dives/generated-sdk.mdx +++ b/fern/products/sdks/deep-dives/generated-sdk.mdx @@ -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 | diff --git a/fern/products/sdks/generators/python/aiohttp-support.mdx b/fern/products/sdks/generators/python/aiohttp-support.mdx new file mode 100644 index 000000000..5ee59e696 --- /dev/null +++ b/fern/products/sdks/generators/python/aiohttp-support.mdx @@ -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 +``` diff --git a/fern/products/sdks/generators/python/configuration.mdx b/fern/products/sdks/generators/python/configuration.mdx index f678ec427..20366b669 100644 --- a/fern/products/sdks/generators/python/configuration.mdx +++ b/fern/products/sdks/generators/python/configuration.mdx @@ -94,6 +94,8 @@ Specify additional development dependencies to include in the generated SDK's se 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. diff --git a/fern/products/sdks/sdks.yml b/fern/products/sdks/sdks.yml index 7e26ad32f..2e9f95fc9 100644 --- a/fern/products/sdks/sdks.yml +++ b/fern/products/sdks/sdks.yml @@ -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