Speakeasy Logo
Skip to Content

In depth: Speakeasy vs liblab

Nolan Sullivan

Nolan Sullivan

July 5, 2024 - 11 min read


This analysis compares Speakeasy and liblab in terms of SDK generation, OpenAPI integration, language support, features, platform support, enterprise support, and pricing. We’ll also provide a technical walkthrough of generating SDKs using both services and compare the generated TypeScript SDKs.

In short: How do Speakeasy and liblab differ?

  1. OpenAPI integration: Speakeasy is built for OpenAPI, supporting advanced features of OpenAPI 3.0 and 3.1, while testing and implementing upcoming OpenAPI features like OpenAPI Overlays and Workflows. liblab uses OpenAPI as a starting point, but has not yet implemented advanced OpenAPI features like Overlays or Workflows, instead depending on its own configuration system. This can lead to a divergence between the OpenAPI document and the generated SDK, and may require additional configuration after spec changes.

  2. Velocity and language support: liblab was founded in January 2022 and gradually expanded its language support and features to support seven languages. In comparison, Speakeasy was founded in May 2022, found market traction in early 2023, and released support for ten languages within 12 months. Speakeasy meets the diverse needs of users, while supporting their existing stacks.

  3. SDK generator maturity: Speakeasy creates SDKs that are idiomatic to each target language, type safe during development and production, human-readable, and fault-tolerant. Our comparison found some room for improvement in liblab’s type safety, fault tolerance, and SDK project structure. Both products are under active development, and improvement should be expected.

Comparing Speakeasy and liblab

We’ll start by comparing the two services in terms of their SDK generation targets, features, platform support, enterprise support, and pricing.

SDK generation targets

As your user base grows, the diversity of their technical requirements will expand beyond the proficiencies of your team. At Speakeasy, we understand the importance of enabling users to onboard with our clients without making major changes to their tech stacks. Our solution is to offer support for a wide range of SDK generation targets.

The table below highlights the current SDK language support offered by Speakeasy and liblab as of June 2024. Please note that these lists are subject to change, so always refer to the official documentation for the most up-to-date information.

SDK Generation Targets

Language
Go
Speakeasy
liblab
Python
Speakeasy
liblab
Typescript
Speakeasy
liblab
Java
Speakeasy
liblab
C#
Speakeasy
liblab
PHP
Speakeasy
liblab
Swift
Speakeasy
liblab
Kotlin
Speakeasy
⚠ Java is Kotlin-compatible
liblab
⚠ Java is Kotlin-compatible
Terraform provider
Speakeasy
liblab
Ruby
Speakeasy
liblab
Unity
Speakeasy
liblab
Postman Collection
Speakeasy
liblab

Everyone has that one odd language that is critical to their business. In our first year, we’ve made a dent, but we’ve got further to go. See a language that you require that we don’t support? Join our Slack community  to let us know.

SDK features

This table shows the current feature support for Speakeasy and liblab as of June 2024. Refer to the official documentation for the most recent updates.

SDK Features

Feature
Union types
Speakeasy
liblab
Discriminated union types
Speakeasy
liblab
Server-sent events
Speakeasy
liblab
Retries
Speakeasy
liblab
⚠ Global retries only
Pagination
Speakeasy
liblab
Async support
Speakeasy
liblab
Streaming uploads
Speakeasy
liblab
OAuth 2.0
Speakeasy
liblab
Custom SDK naming
Speakeasy
liblab
Customize SDK structure
Speakeasy
liblab
Custom dependency injection
Speakeasy
liblab

Speakeasy creates SDKs that handle advanced authentication. For example, Speakeasy can generate SDKs that handle OAuth 2.0 with client credentials - handling the token lifecycle, retries, and error handling for you.

liblab leaves some of these features to be implemented by the user. For example, liblab’s configuration allows for global retries on all operations, but only recently released support for custom retries requiring custom implementation per SDK.

liblab also lacks support for pagination, server-sent events, and streaming uploads.

Platform features

Speakeasy is designed to be used locally, with a dependency-free CLI that allows for local experimentation and iteration. This makes it easier to test and iterate on your SDKs and allows for custom CI/CD workflows.

For local use, liblab provides an NPM package with a dependency tree of 749 modules. Installing and updating the liblab CLI is slower than Speakeasy’s single binary, the CLI is less feature-rich, and it depends on Node.js and NPM.

Platform Features

Feature
GitHub CI/CD
Speakeasy
liblab
CLI
Speakeasy
liblab
Web interface
Speakeasy
liblab
OpenAPI Overlays
Speakeasy
liblab
Package publishing
Speakeasy
liblab
Product documentation
Speakeasy
liblab
OpenAPI linting
Speakeasy
liblab
Change detection
Speakeasy
liblab

Enterprise support

Both Speakeasy and liblab offer support for Enterprise customers. This includes features like concierge onboarding, private Slack channels, and enterprise SLAs.

Enterprise Support

Feature
Concierge onboarding
Speakeasy
liblab
Private Slack channel
Speakeasy
liblab
Enterprise SLAs
Speakeasy
liblab
User issues triage
Speakeasy
liblab
SOC 2 compliance
Speakeasy
liblab

Pricing

Speakeasy offers a free tier, with paid plans starting at $250 per month.

liblab’s free tier is limited to open-source projects, with paid plans starting at $120 per month.

Both services offer custom enterprise plans.

Pricing

Plan
Free
Speakeasy
1 free Published SDK
liblab
Open-source projects only
Startup/Starter
Speakeasy
1 free + $250/mo/SDK; max 50 endpoints
liblab
$120/mo
Enterprise/Advanced
Speakeasy
Custom
liblab
Custom

TypeScript SDK comparison

Now that we have two TypeScript SDKs generated from a single OpenAPI document, let’s see how they differ.

SDK structure overview

Before we dive into the detail, let’s get an overall view of the default project structure for each SDK.

Speakeasy automatically generates detailed documentation with examples for each operation and component, while liblab generates an examples folder with a single example.

liblab generates a test folder, while Speakeasy does not. We’ll take a closer look at this shortly.

In the comparison below, comparing the folder structure might seem superficial at first, but keep in mind that SDK users get the same kind of high-level glance as their first impression of your SDK. Some of this may be a matter of opinion, but at Speakeasy we aim to generate SDKs that are as organized as SDKs coded by hand.

Speakeasy SDK structure

Speakeasy generates separate folders for models and operations, both in the documentation and in the source folder. This indicates a clear separation of concerns.

We also see separate files for each component and operation, indicating modularity and separation of concerns.

  • README.md
  • RUNTIMES.md
  • USAGE.md
  • jsr.json
  • package.json
  • tsconfig.json

liblab SDK structure

liblab generates an SDK that at a glance looks less organized, considering the greater number of configuration files at the root of the project, the lack of a docs folder, and the way the src folder is structured by OpenAPI tags instead of models and operations.

  • install.sh
  • jest.config.json
  • LICENSE
  • package.json
  • README.md
  • tsconfig.eslint.json
  • tsconfig.json

SDK code comparison

With the bird’s-eye view out of the way, let’s take a closer look at the code.

Runtime type checking

Speakeasy creates SDKs that are type safe from development to production. As our CEO recently wrote, Type Safe is better than Type Faith.

The SDK created by Speakeasy uses Zod  to validate data at runtime. Data sent to the server and data received from the server are validated against Zod definitions in the client.

This provides safer runtime code execution and helps developers who use your SDK to provide early feedback about data entered by their end users. Furthermore, trusting data validation on the client side allows developers more confidence to build optimistic UIs  that update as soon as an end user enters data, greatly improving end users’ perception of your API’s speed.

Let’s see how Speakeasy’s runtime type checking works in an example.

Consider the following Book component from our OpenAPI document:

The highlighted price field above has type integer.

The price field in the Book object in our test code is set to 29.99, which is a floating-point number. This will cause a validation error before the data is sent to the server, as the price field is expected to be an integer.

Handling Zod validation errors  is straightforward, and allows developers to provide meaningful feedback to their end users early in the process.

The same book object in code using the SDK generated by liblab will only be validated on the server. This means that the error will only be caught from the client’s perspective after the data is sent to the server, and the server responds with an error message.

If the server is not set up to validate the price field, the error will not be caught at all, leading to unexpected behavior in your developer-users’ applications.

As a result, developers using the SDK generated by liblab may need to write additional client-side validation code to catch these errors before they are sent to the server.

Components compared

Speakeasy creates SDKs that contain rich type information for each component in your OpenAPI document. This includes clear definitions of enums, discriminated unions, and other complex types, augmented with runtime validation using Zod.

Let’s compare the Order component from our OpenAPI document in the SDKs generated by Speakeasy and liblab.

Here’s the Order component as generated by liblab:

Note how the products field is defined as an array of FantasyBook, ProgrammingBook, or SciFiBook. This is a union type, but the SDK generated by liblab does not provide any runtime validation for this field, nor does it give any indication that this is a discriminated union.

Contrast this with the Order component as created by Speakeasy, which exports a useful Products type that is a discriminated union of FantasyBook, ProgrammingBook, and SciFiBook, along with a Status enum for use elsewhere in your code.

Verbose runtime validation is marked as @internal in the generated code, clearly indicating that it is not intended for direct use by developers, but rather for internal use by the SDK.

Here’s the Order component created by Speakeasy:

OAuth client credentials handling

Only Speakeasy’s SDKs handle OAuth 2.0 with client credentials, including managing the token lifecycle, retries, and error handling without any additional code.

Our bookstore API requires an OAuth 2.0 token with client credentials to access the API. Let’s see how the SDKs handle this.

Consider the following OAuth 2.0 configuration from our OpenAPI document:

Speakeasy’s generated SDK takes a clientID and clientSecret when instantiating the SDK. The SDK also includes ClientCredentialsHook class that implements BeforeRequestHook to check whether the token is expired and refresh it if necessary. The hook also checks whether the client has the necessary scopes to access the endpoint, and handles authentication errors.

The SDK generated by liblab does not support OAuth 2.0 client credentials at all.

Server-sent events (SSE) and streaming responses

Our bookstore API includes an operation that streams orders to the client using Server-Sent Events (SSE).

Let’s see how the SDKs handle this.

Speakeasy generates types and methods for handling SSE without any customization. Here’s an example of how to use the SDK to listen for new orders:

(The example above does not run against a local Prism server, but you can test it against Stoplight’s hosted Prism  server.)

liblab does not generate SSE handling code. Developers using the SDK generated by liblab will need to write additional code to handle SSE.

Streaming uploads

Speakeasy supports streaming uploads without any custom configuration. OpenAPI operations with multipart/form-data content types are automatically handled as streaming uploads.

The following example illustrates how to use an SDK created by Speakeasy to upload a large file:

React Hooks

React Hooks simplify state and data management in React apps, enabling developers to consume APIs more efficiently.

liblab does not support React Hooks natively. Developers must manually integrate SDK methods into state management tools like React Context, Redux, or TanStack Query.

Speakeasy generates built-in React Hooks using TanStack Query . These hooks provide features like intelligent caching, type safety, pagination, and seamless integration with modern React patterns such as SSR and Suspense.

Here’s an example:

For example, in this basic implementation, the useQuery hook fetches data from an API endpoint. The cache key ensures unique identification of the query. The status variable provides the current state of the query: loading, error, or success. Depending on the query status, the component renders loading, error, or the fetched data as a list.

Auto-pagination

Speakeasy’s React Hooks also enable auto-pagination, which automatically fetches more data when the user scrolls to the bottom of the page. This feature is useful for infinite scrolling in social media feeds or search results.

liblab also supports pagination, however this requires additional configuration using the liblab.config.json file.

For an in-depth look at how Speakeasy generates React Hooks, see our official release article .

OpenAPI extensions and Overlays vs liblab config

Speakeasy embraces OpenAPI as the source of truth for generating SDKs. This means that Speakeasy does not require any additional configuration files to generate SDKs, apart from minimal configuration in the gen.yaml file.

Any configuration related to individual operations or components is done in the OpenAPI document itself, using OpenAPI extensions. Speakeasy provides a list of supported OpenAPI extensions in its documentation.

If editing your OpenAPI document is not an option, Speakeasy also supports the OpenAPI Overlays specification, which allows you to add or override parts of an OpenAPI document without modifying the original document.

This step can form part of your CI/CD pipeline, ensuring that your SDKs are always up-to-date with your API, even if your OpenAPI document is generated from code.

Speakeasy’s CLI can also generate OpenAPI Overlays for you, based on the differences between two OpenAPI documents.

Instead of using OpenAPI extensions, liblab uses a configuration file  to customize SDKs. This configuration overrides many of the aspects Speakeasy allows you to configure in the OpenAPI document itself, or using overlays.

Linting and change detection

Speakeasy’s CLI includes a detailed and accurate linter that checks your OpenAPI document and provides feedback. This is especially useful during development, but can also catch errors in your CI/CD pipeline.

Speakeasy also keeps track of changes in your OpenAPI document, and versions the SDKs it creates based on those changes.

Building for the browser

Both Speakeasy and liblab generate SDKs that can be used in the browser. To use the SDKs in the browser, you need to bundle your application using a tool like webpack, Rollup, or esbuild.

Speakeasy creates SDKs that are tree-shakeable, meaning that you can include only the parts of the SDK that you need in your application. This can help reduce the size of your application bundle.

Because Speakeasy SDKs include runtime type checking, the Zod library is included in the bundle. However, if you use Zod in other parts of your application, you can share the Zod instance between the SDK and your application to reduce the bundle size.

Here’s an example of how to bundle an application that uses the Speakeasy SDK for the browser without Zod using esbuild:

Speakeasy compared to open-source generators

If you are interested in seeing how Speakeasy stacks up against other SDK generation tools, check out our post.

Last updated on

Organize your
dev universe,

faster and easier.

Try Speakeasy Now