explaingit

hey-api/openapi-ts

4,654TypeScriptAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Hey API generates TypeScript SDK code, Zod schemas, and TanStack Query hooks from an OpenAPI spec file, used in production by Vercel, PayPal, and OpenCode.

Mindmap

mindmap
  root((Hey API))
    What it does
      OpenAPI to TypeScript
      Code generation
      SDK and hooks
    Plugins 20 plus
      Fetch Axios Angular
      Zod schemas
      TanStack Query hooks
    Python support
      openapi-python
      Pydantic models
    Used by
      Vercel
      PayPal
      OpenCode
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Generate a typed TypeScript HTTP client from an OpenAPI spec so you stop writing fetch calls by hand.

USE CASE 2

Produce Zod validation schemas for all API request and response types from an existing OpenAPI definition.

USE CASE 3

Generate TanStack Query hooks from an OpenAPI spec for a React app that fetches data from a REST API.

USE CASE 4

Create a Python SDK with Pydantic models from an OpenAPI spec using the openapi-python package.

Tech stack

TypeScriptNode.jsOpenAPIZodTanStack QueryAxiosFetch API

Getting it running

Difficulty · easy Time to first run · 5min

Requires Node.js 22 or later.

MIT license: use, modify, and distribute freely for any purpose including commercial.

In plain English

Hey API (openapi-ts) is a code generator that reads an OpenAPI specification file and produces TypeScript code for calling that API. Instead of writing HTTP client code by hand, you point the tool at an API spec and it generates typed functions, request and response types, and validation schemas automatically. Vercel, PayPal, and OpenCode are among the organizations using it. The core package, openapi-ts, works in any Node.js 22 or later environment and accepts OpenAPI specifications in any version. It ships with more than 20 plugins that cover a wide range of common needs. HTTP client plugins cover the Fetch API, Axios, Angular, Next.js, Nuxt, and HTTPX. Other plugins generate Zod validation schemas for runtime type checking, TanStack Query hooks for React data-fetching patterns, and Pydantic models for Python consumers. A separate openapi-python package handles Python SDK generation. The generated code is described as production-grade: it compiles without errors and is designed to be used directly in real applications, not just as a starting point for manual editing. The plugin system lets you customize what gets generated and how, so teams can adapt the output to their own conventions. A companion package called spec-types provides TypeScript definitions for OpenAPI and JSON Schema specifications with inline documentation, which can be useful when writing tools that read or validate API specs. This tool is for frontend and backend TypeScript developers who work with REST APIs that have an OpenAPI spec. Rather than maintaining handwritten API client code that drifts from the actual API, you regenerate the client whenever the spec changes. It is particularly useful in monorepos or teams where the API and its consumer are both under active development. The project is MIT licensed.

Copy-paste prompts

Prompt 1
I have an OpenAPI 3.1 spec file at ./api/openapi.yaml. Show me how to run @hey-api/openapi-ts to generate a TypeScript client using the Fetch API plugin.
Prompt 2
Set up @hey-api/openapi-ts with the Zod plugin so that every response type from my OpenAPI spec gets a Zod schema I can use for runtime validation.
Prompt 3
I'm using TanStack Query in my React app. Show me how to configure @hey-api/openapi-ts to generate TanStack Query hooks for every endpoint in my OpenAPI spec.
Prompt 4
Write a package.json script that regenerates my @hey-api/openapi-ts client every time I run npm run codegen, pointing at a local openapi.yaml file.
Open on GitHub → Explain another repo

← hey-api on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.