
Should you hand-write your SDK or use a generator?

Kevin Whinnery
Head of Marketing & DevRel

CJ Avilla
Developer Relations Engineer
For API platform teams, the "build vs. buy" conversation inevitably lands on a specific dilemma: should you hand-write your SDKs or use an SDK generator like Stainless? The answer depends on what you're building.
You can watch the discussion in the video below.
For those who prefer words, we’ve also included a written summary of the key points from the conversation after the video.
Start with the right question: what kind of SDK are you building?
The most important factor is whether your SDK primarily wraps an HTTP API or implements business logic.
Use a generator when:
Your SDK wraps a REST API
You're making network requests and need robust HTTP handling (retries, timeouts, connection pooling)
You want type safety in your SDKs that stays in sync with your API specification
You want to support several programming languages
Consider hand-writing when:
Your SDK is primarily business logic without a corresponding API spec. For example, a game engine, a media manipulation library, or a UI toolkit
You're interfacing with browser APIs, devices, or frameworks that lack OpenAPI definitions
The "product" is the logic of the SDK itself, not an underlying service accessed via API
Many SDKs fall somewhere in between. Even if your SDK is 80% business logic, like an error monitoring tool with heavy instrumentation code, the HTTP component still benefits from generation. Use the generated API client as your dependable foundation while you invest in the business logic that sets your product apart.
The hidden complexity of "simple" HTTP
Providing SDKs that meet the performance and reliability bar of the best API platforms involves more than most teams expect:
Retry logic with exponential backoff
Connection pooling for performance
Configurable timeouts across different operations
Consistent error handling patterns
Server-sent events for streaming APIs
This work isn’t differentiated; it’s table stakes. But getting it wrong creates friction that slows adoption. Generation handles these uniformly across every endpoint, freeing your team to focus on what sets your API apart.
The single source of truth advantage
When you generate an SDK from an OpenAPI specification, you ensure that type-safe objects in your users' codebases match the reality of your backend. This eliminates the "drift" that occurs when hand-written libraries fail to keep up with API updates.
This creates a virtuous cycle:
Your OpenAPI spec becomes the single source of truth
Your SDKs, documentation, and tests are all generated from that truth
Developers avoid the frustration of errors caused by outdated or missing types
Multi-language support
The most practical constraint: internal expertise. Your team might excel at Python and TypeScript, but do you have experts in C#, Java, PHP, and Go?
Hand-writing SDKs limits you to the languages your team knows. Generating SDKs allows you to offer high-quality, idiomatic client experiences in ecosystems where you lack internal resources. Unless you have Fortune 500-level resources, maintaining bespoke libraries across six or seven languages is a challenge few teams can sustain.
Addressing common objections
"My API is too complex for generation"
This is rarely true in practice. APIs with hundreds of endpoints successfully use generation. The underlying mechanics of HTTP integration follow predictable patterns regardless of your specific domain.
For genuine edge cases—custom serialization, encryption, legacy quirks—modern generators allow you to inject custom code at any point in the generated output without losing the benefits of generation.
"Generated code is unreadable"
Legacy generators earned this reputation fairly. However, Stainless was built specifically to produce code that looks handcrafted, idiomatic to each target language, and readable by humans. Paradoxically, human-readable code is also better for AI coding assistants: if an LLM can read the generated code and understand the logic, it can better assist the end user.
"Hand-written SDKs are always superior"
Only if you have dedicated experts for every language you need to support. Can your team maintain production-quality SDKs in Python, TypeScript, Go, Java, C#, and PHP simultaneously? And keep them all accurate as your API evolves?
The hybrid approach: often the sweet spot
The decision doesn't have to be binary. The ideal modern workflow combines both approaches:
Generate the networking layer for types, reliability, and accuracy
Handcraft high-level helpers, "porcelain" methods, or domain-specific flows on top
With Stainless, you can configure SDK naming and namespaces per language, alias critical endpoints with ergonomic top-level methods, and add custom code.
The bottom line
SDK generation lets your team focus on what differentiates your API: the backend services and capabilities.
The modern approach isn't choosing between generation and customization—it's using generation as your foundation while retaining flexibility to add custom helpers, adjust naming, and implement language-specific idioms where they matter.
Sign up for Stainless and generate your first SDK today
Turn your spec into production-ready clients across languages, then customize from a solid foundation instead of rebuilding HTTP plumbing by hand.
Originally posted
Dec 8, 2025