What this prompt does
This prompt asks the AI to build a typed Python client library for any REST API rather than scattering raw HTTP calls through your code. It specifies eight things: typed request/response models with [typing_library], both sync and async (aiohttp) clients, authentication via [auth_type], automatic retry with configurable backoff, rate limiting and request queuing, a proper exception hierarchy, request/response logging, and unit tests with [test_framework] using recorded fixtures — packaged with a pyproject.toml.
The structure works because it treats a third-party integration as a real library, not glue code. The [api_name] variable names the target, [auth_type] shapes the credential handling, and [typing_library] (defaulting to Pydantic v2) makes responses validated and typed so failures surface at the boundary. Recorded fixtures in [test_framework] keep the tests fast and deterministic instead of hammering the live API.
When to use it
- You're integrating a third-party service (payments, email, AI provider) and want a reusable, typed client.
- You need both sync and async access to the same API without duplicating logic.
- You want retries, rate limiting, and a clean exception hierarchy instead of ad-hoc try/except.
- You need typed models so malformed responses fail loudly at the edge of your system.
- You want a properly packaged, installable SDK with fast fixture-based tests.
Example output
Expect an installable package: Pydantic (or your [typing_library]) models for requests and responses, a sync client and an aiohttp async client sharing config, an auth layer for [auth_type], retry and rate-limit middleware, a structured exception hierarchy, request/response logging, and a [test_framework] suite backed by recorded fixtures. A pyproject.toml ties it together so it installs and imports like any real dependency.
Pro tips
- Name
[api_name]specifically; a well-known API (the default is Stripe) lets the AI infer realistic endpoints and error shapes. - Match
[auth_type]to the real scheme — API key, OAuth, and bearer tokens need different refresh and header handling. - Stick with Pydantic v2 in
[typing_library]unless you have a reason not to; its validation is what makes the client trustworthy. - Always verify the generated models against the API's real docs — the AI can hallucinate field names it hasn't seen.
- Re-record fixtures from real (sanitized) responses so
[test_framework]tests reflect actual payloads, not invented ones. - Start by exercising the sync client end to end, then confirm the async client mirrors its behavior before relying on it.