Get Started

@hey-api/openapi-ts generates TypeScript code from OpenAPI specifications. Point it at your spec, pick your plugins, and get production-ready code in seconds.

Used by companies like Vercel, OpenCode, and PayPal.

“OpenAPI codegen that just works.”

— Guillermo Rauch, CEO of Vercel

Demo

Features

  • production-ready code that compiles
  • runs in any Node.js 20+ environment
  • accepts any OpenAPI specification
  • core plugins for SDKs, types, and schemas
  • HTTP clients for Fetch API, Angular, Axios, Next.js, Nuxt, and more
  • 20+ plugins to reduce third-party boilerplate
  • highly customizable via plugins
  • sync with Hey API Registry for spec management

Quick Start

The fastest way to use @hey-api/openapi-ts is via npx

sh

npx @hey-api/openapi-ts -i hey-api/backend -o src/client

Congratulations on creating your first client! 🎉 You can learn more about the generated files on the Output page.

Installation

You can download @hey-api/openapi-ts from npm using your favorite package manager.

sh

npm install @hey-api/openapi-ts -D -E

sh

pnpm add @hey-api/openapi-ts -D -E

sh

yarn add @hey-api/openapi-ts -D -E

sh

bun add @hey-api/openapi-ts -D -E

Versioning

This package is in initial development. Please pin an exact version so you can safely upgrade when you're ready.

We publish migration notes for every breaking release. You might not be impacted by a breaking change if you don't use the affected features.

Usage

CLI

Most people run @hey-api/openapi-ts via CLI. To do that, add a script to your package.json file which will make openapi-ts executable through script.

json

"scripts": {
  "openapi-ts": "openapi-ts"
}

The above script can be executed by running npm run openapi-ts or equivalent command in other package managers. Next, we will create a configuration file and move our options from Quick Start to it.

Node.js

You can also generate output programmatically by calling createClient() in a JavaScript/TypeScript file.

ts

import { createClient } from '@hey-api/openapi-ts';

createClient({
  input: 'hey-api/backend', // sign up at app.heyapi.dev
  output: 'src/client',
});

Configuration

It's a good practice to extract your configuration into a separate file. Learn how to do that and discover available options on the Configuration page.

Examples

You can view live examples on StackBlitz.

Hey API is sponsor-funded. If you rely on Hey API in production, consider becoming a sponsor to accelerate the roadmap.