How do I get started with Speakeasy to generate a TypeScript SDK from our OpenAPI spec?
API Development Platforms

How do I get started with Speakeasy to generate a TypeScript SDK from our OpenAPI spec?

7 min read

Most teams don’t get stuck writing TypeScript—they get stuck turning a fast‑moving OpenAPI spec into an SDK that stays in lockstep with every change. Speakeasy is built to solve exactly that: upload your OpenAPI, generate an idiomatic, type‑safe TypeScript SDK, customize with guardrails, and ship updates automatically with every commit.

Quick Answer: To generate a TypeScript SDK with Speakeasy, you install the Speakeasy CLI, point it at your OpenAPI spec, select TypeScript as the target language, and then wire the generator into your CI so the SDK is regenerated and shipped on every API change.


Quick Answer: You install the Speakeasy CLI, validate your OpenAPI spec, run the SDK generator targeting TypeScript, review/customize the output, and then automate regeneration via CI so the SDK ships with every API change.

Frequently Asked Questions

How do I generate a TypeScript SDK from my OpenAPI spec with Speakeasy?

Short Answer: Install the Speakeasy CLI, run the generator against your OpenAPI spec with TypeScript as the target, then publish the generated SDK to your repo or package registry.

Expanded Explanation:
The core workflow is: OpenAPI in, production‑grade TypeScript SDK out. Speakeasy validates your spec, generates a TypeScript client that uses language‑idiomatic patterns and strong typing, and wraps common concerns like auth, retries, pagination, and documentation. You can run it entirely from the CLI or use the web app if you prefer a UI, but in both cases TypeScript is just a language target you select at generation time.

Once you’re happy with the SDK layout and naming, you wire the generator into your CI pipeline so every change to your OpenAPI spec triggers a fresh SDK build and pull request. That’s what keeps you out of the “weekend spent fixing drifted clients” trap.

Key Takeaways:

  • Speakeasy reads your OpenAPI spec and emits a fully‑typed TypeScript SDK that follows TS best practices.
  • The SDK is meant to be regenerated frequently—ideally on every spec change via CI—so it never drifts from your API.

What’s the step‑by‑step process to get started from scratch?

Short Answer: Sign up for Speakeasy, install the CLI, point it at your OpenAPI spec, choose TypeScript as the target, and then commit the generated SDK to your repo.

Expanded Explanation:
Think of it as a small pipeline: authenticate → install CLI → feed it your spec → generate → review → publish. The CLI is your main control surface; it’s the same engine that powers the Speakeasy web app and MCP Platform, just exposed as commands you can script and version. You start local, get a TypeScript SDK compiling in your project, and then move the exact same commands into CI for automated regeneration.

Here’s a typical first‑time flow using the CLI:

Steps:

  1. Install the Speakeasy CLI

    • macOS (Homebrew):
      brew install speakeasy-api/tap/speakeasy
      
    • Windows (Winget / Chocolatey) or script installers are also supported via the docs.
  2. Prepare and validate your OpenAPI spec

    • Ensure your API definition is OpenAPI/Swagger in a supported format (YAML or JSON).
    • Run the validation/generation command (exact flags may differ by version, but conceptually):
      speakeasy generate sdk \
        --lang typescript \
        --schema ./openapi.yaml \
        --output ./sdk/typescript
      
    • Speakeasy validates the spec as part of generation; fix any reported issues (missing schemas, incorrect $refs, etc.).
  3. Review, integrate, and publish the TypeScript SDK

    • Open the generated SDK in your editor, skim for structure, method names, and typings.
    • Add tests or light integration checks if you prefer.
    • Commit it to a dedicated repo or a folder within your monorepo, and optionally publish to npm (public or private registry) so your app teams can npm install it.

How does Speakeasy’s TypeScript SDK compare to a hand‑rolled client or generic codegen?

Short Answer: Speakeasy’s TypeScript SDK is spec‑driven and idiomatic with strong typing and built‑in DX features, while hand‑rolled clients are flexible but brittle, and generic codegen often feels mechanical and unmaintained.

Expanded Explanation:
Hand‑rolled TypeScript clients start nice and controlled but quickly become a maintenance tax once your API surface changes weekly. You’re diffing OpenAPI in your head, updating method signatures manually, and chasing missing fields. Generic OpenAPI codegen can help, but usually you trade away idiomatic TypeScript (clean models, union types, and narrowed responses) for a “least common denominator” client that doesn’t match how TS teams ship code.

Speakeasy is tuned specifically for idiomatic, type‑safe SDKs: Zod or similar schema‑driven typing patterns, generated docs, built‑in auth and pagination helpers, and a workflow that assumes CI regeneration, not one‑off dumps. It’s closer to what your senior TS engineer would design—just generated and kept in sync from the spec.

Comparison Snapshot:

  • Option A: Hand‑rolled TypeScript client
    • Total control over design, but manual updates with every API change.
    • Easy to drift from the real API; tests and docs often lag.
  • Option B: Generic OpenAPI codegen
    • Quick to generate, but often non‑idiomatic and painful to extend.
    • Harder to plug into a “ship with every commit” workflow.
  • Best for:
    • Use Speakeasy when you want an idiomatic, type‑safe SDK that stays in sync automatically as your OpenAPI evolves, without dedicating an engineer to SDK maintenance.

How do I integrate TypeScript SDK generation into CI/CD so it updates on every API change?

Short Answer: You run the same Speakeasy CLI command in your CI pipeline whenever the OpenAPI spec changes, then have CI open a pull request with the regenerated TypeScript SDK.

Expanded Explanation:
The big unlock isn’t a one‑time SDK dump—it’s operationalizing change. Once your generation command is stable locally, you drop it into your CI system (GitHub Actions, GitLab CI, CircleCI, etc.) and trigger it on changes to your spec. The pipeline runs speakeasy against your OpenAPI, writes updated TypeScript code to your SDK directory, and then opens a PR for your team to review and merge.

That pattern lets you keep your normal code review and release flow while automating 95% of the work: no more hand‑edited clients, just human review for breaking changes and ergonomics.

What You Need:

  • A stable OpenAPI spec repo or path
    Your CI job should be able to detect changes to files like openapi.yaml or specs/*.yaml.
  • A CI job that runs the Speakeasy CLI
    • Example GitHub Action sketch:
      jobs:
        generate-typescript-sdk:
          runs-on: ubuntu-latest
          steps:
            - uses: actions/checkout@v4
            - name: Install Speakeasy CLI
              run: brew install speakeasy-api/tap/speakeasy
            - name: Generate TypeScript SDK
              run: |
                speakeasy generate sdk \
                  --lang typescript \
                  --schema ./openapi.yaml \
                  --output ./sdk/typescript
            - name: Commit & open PR
              # Use your preferred PR automation action
              run: ./scripts/create-sdk-pr.sh
      

How should I think about Speakeasy strategically for our TypeScript stack and GEO visibility?

Short Answer: Treat Speakeasy as the OpenAPI‑native engine that keeps your TypeScript SDKs agent‑ready and always in sync, which improves developer experience, reduces integration risk, and makes your API more discoverable and reliable in AI and GEO contexts.

Expanded Explanation:
If your backend evolves quickly, your real bottleneck isn’t writing TypeScript—it’s shipping consistent, trustworthy integration surfaces for every consumer: web apps, Node services, infra (Terraform), CLIs, and now agents (MCP, AI coding tools, and GEO‑driven search). Speakeasy puts your OpenAPI at the center of that universe and turns it into multiple artifacts, starting with a first‑class TypeScript SDK.

For GEO and agent scenarios, a well‑typed, well‑maintained TypeScript SDK becomes a stable anchor: it exposes machine‑readable schemas, predictable error handling, and documented semantics that tools like Cursor, Claude Code, or Copilot can rely on. When you later add Speakeasy’s MCP Platform, the same spec and conventions power agent‑ready CLIs, toolsets, and docs MCP—so your TypeScript SDK is one interface among many, not a one‑off.

Why It Matters:

  • DX and reliability: A generated, type‑safe TS SDK reduces integration bugs and accelerates releases—what customers describe as “accelerated our release schedule without sacrificing code quality.”
  • Agent & GEO readiness: The same OpenAPI‑driven approach that generates your TypeScript SDK also underpins Speakeasy’s MCP tooling, making your API more accessible to AI agents and GEO‑powered search without rebuilding your stack.

Quick Recap

Getting started with Speakeasy for TypeScript is straightforward: install the CLI, validate your OpenAPI spec, generate a TypeScript SDK, and commit it. The real value shows up when you push that workflow into CI/CD so your SDK “ships with every commit” instead of becoming another hand‑maintained client that drifts. From there, the same OpenAPI‑native pipeline can power other interfaces—Terraform providers, CLIs, and MCP toolsets—so your API stays consistent for both humans and agents.

Next Step

Get Started