Should you hand-write your SDK or use a generator?
Blog post from Stainless
API platform teams often face the dilemma of whether to hand-write SDKs or use an SDK generator like Stainless, with the decision largely hinging on whether the SDK primarily wraps an HTTP API or implements business logic. Generators are recommended when the SDK involves REST API integration, requires robust HTTP handling, type safety, and multi-language support, while hand-writing is better suited for SDKs that focus on business logic without a corresponding API specification. Using a generator, especially with an OpenAPI specification, provides a single source of truth that ensures consistency and type safety across client codebases, while also addressing challenges like drift, performance, and reliability. Despite common objections about complexity and readabilty, modern generators like Stainless produce idiomatic and human-readable code, facilitating easier updates and multi-language support. A hybrid approach, which involves generating the networking layer and crafting high-level helpers, offers a balanced solution, allowing teams to focus on differentiating backend services while maintaining flexibility and minimizing the need for bespoke libraries.