Skip to main content

API SDK Auto-Generator

Generate type-safe client SDKs from an OpenAPI specification for multiple languages with authentication, error handling, and retry logic built in.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
You are an API developer experience expert. Help me generate production-quality client SDKs from the MyPlatform API OpenAPI specification for 4 programming languages.

Step 1: Analyze the OpenAPI 3.1 specification file at docs/openapi.yaml. Extract all endpoints, request/response schemas, authentication methods, and error response formats. Identify reusable patterns: common query parameters (pagination, filtering, sorting), shared response envelopes, and polymorphic schemas. Report any spec issues (missing descriptions, inconsistent naming, incomplete error schemas) that should be fixed before SDK generation.

Step 2: Design the SDK architecture that is consistent across all 4 target languages (TypeScript, Python, Go, PHP). Define the core components: Client class (holds configuration and auth), Resource classes (one per API resource group), Request/Response models (generated from schemas), and Error classes (typed exceptions per error code). Follow the conventions and idioms of each target language.

Step 3: Generate the authentication layer. Support API key, OAuth2 client credentials, Bearer JWT authentication. Implement automatic token refresh for OAuth2 flows, API key injection in headers or query parameters, and credential storage best practices for each language. The auth configuration should be set once during client initialization and automatically applied to all requests.

Step 4: Implement the HTTP layer with built-in retry logic. Use fetch (TS), httpx (Python), net/http (Go), Guzzle (PHP) as the HTTP backend for each language. Configure automatic retries for 429 (rate limited, using Retry-After header) and 5xx errors with exponential with jitter backoff up to 3 attempts. Set configurable timeouts for connection (10 seconds) and read (30 seconds). Support request/response interceptors for custom logging or header injection.

Step 5: Generate comprehensive type-safe request builders and response models. Every endpoint should have a method with typed parameters (no raw strings for enums, proper date types, nullable fields marked optional). Response models should deserialize JSON automatically and provide helper methods for common operations (pagination iteration, file download streaming). Include inline documentation from the OpenAPI descriptions.

Step 6: Create the SDK documentation and publishing pipeline. Auto-generate API reference documentation from the code. Write a quickstart guide with examples for authentication, CRUD operations, pagination, error handling, and file uploads. Set up a CI pipeline that regenerates the SDK when the OpenAPI spec changes and publishes to npm, PyPI, Go modules, Packagist.

What this prompt does

This prompt turns an OpenAPI specification into production-quality client SDKs across several languages at once. It walks the AI through six ordered steps: analyzing the [api_name] spec at [spec_path], designing a consistent architecture, generating the auth layer, building the HTTP layer with retries, producing type-safe request/response models, and wiring up docs and a publishing pipeline. Because everything is driven from the spec, the SDKs stay honest as the API evolves, and the same source of truth feeds every target language.

The variables are what make the output specific instead of generic. [language_count] and [target_languages] decide how many idiomatic SDKs get designed, [spec_version] tells the model which OpenAPI dialect to parse, and [auth_methods] plus [http_client] shape the auth and transport layers per language. [retry_strategy], [max_retries], [connect_timeout], and [read_timeout] pin down resilience behavior, while [package_registries] defines where the finished SDKs publish. Adjusting any one of these reshapes a whole step of the output rather than a single line, which is why filling them thoughtfully pays off.

When to use it

  • You maintain an API and want first-class SDKs your integrators actually enjoy using.
  • You already have an OpenAPI document and want to avoid hand-writing clients per language.
  • You need typed clients that catch enum and nullable mistakes at compile time.
  • You want auth, token refresh, and retry logic baked in rather than left to each consumer.
  • You want SDK regeneration tied to spec changes through CI instead of manual updates.
  • You are standardizing client conventions across [target_languages] so they feel consistent.

Example output

The response is a multi-part deliverable rather than a single file. Expect a spec analysis with flagged issues (missing descriptions, inconsistent naming), an architecture description covering Client, Resource, model, and Error classes, then per-language code for the auth and HTTP layers, generated request builders and response models, plus a quickstart guide and a CI pipeline definition for [package_registries]. Because it spans [language_count] languages, the output is organized into clearly separated sections so each language's idioms stay intact.

Pro tips

  • Fix spec problems first. Set [spec_path] to a clean [spec_version] document; missing descriptions and vague error schemas produce weak SDKs.
  • Keep [language_count] and [target_languages] aligned, and let the model follow each language's idioms rather than forcing one pattern everywhere.
  • Match [http_client] to libraries your team already trusts so the generated transport code is maintainable.
  • Be explicit about [auth_methods]; OAuth2 refresh and API-key injection differ enough that vague input yields incomplete auth code.
  • Tune [retry_strategy], [max_retries], and the timeout values to your API's real rate limits instead of accepting defaults blindly.
  • Run the SDK generation per language in separate passes if the combined output gets truncated, then assemble them into one repository per registry.

Frequently Asked Questions

Does this prompt actually write the SDK code, or just a plan?
It produces both. The steps include real per-language code for the auth and HTTP layers plus typed request builders and response models, alongside the architecture plan. For large outputs across many languages you may need to run the generation steps language by language to avoid truncation.
Which languages can it target?
Whatever you put in `[target_languages]`; the default covers TypeScript, Python, Go, and PHP. The prompt instructs the model to follow each language's idioms, so the more languages you list in `[language_count]`, the larger and more segmented the response becomes.
How does it handle authentication and token refresh?
Step 3 generates an auth layer for the methods you list in `[auth_methods]`, including automatic OAuth2 token refresh and API-key injection. The configuration is set once at client initialization and applied to every request, so consumers do not wire auth per call.
Will the generated SDKs stay in sync with my API?
Step 6 sets up a CI pipeline that regenerates the SDK when the OpenAPI spec changes and publishes to `[package_registries]`. That keeps clients aligned with the spec, but you still need a clean, well-described spec at `[spec_path]` for the output to be reliable.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in API Development Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support