Skip to main content
OpenAPI TypeScript Hero

What is OpenAPI TypeScript?

OpenAPI TypeScript is a powerful code generator that transforms your OpenAPI specifications into production-ready TypeScript code. Used by Vercel, OpenCode, and PayPal, it’s the OpenAPI codegen that just works. Generate type-safe SDKs, Zod schemas, TanStack Query hooks, or choose from 20+ other plugins to eliminate third-party boilerplate and accelerate your development workflow.

Quick Start

Get up and running in under 60 seconds with npx

Installation

Install with npm, pnpm, yarn, or bun

Configuration

Customize your code generation with powerful options

Plugins

Explore 20+ plugins for schemas, hooks, and more

Key Features

Generate clean, type-safe TypeScript code that compiles without errors. OpenAPI TypeScript produces code that’s ready for production use, with proper error handling and type inference.
Works in any Node.js 20+ environment and accepts any valid OpenAPI specification (OpenAPI 2.0, 3.0, 3.1). Support for both JSON and YAML formats.
Choose from multiple HTTP client implementations:
  • @hey-api/client-fetch - Native Fetch API
  • @hey-api/client-axios - Axios client
  • @hey-api/client-angular - Angular HttpClient
  • @hey-api/client-next - Next.js optimized
  • @hey-api/client-nuxt - Nuxt optimized
  • @hey-api/client-ky - Ky client
  • @hey-api/client-ofetch - ofetch client
Over 20 plugins to reduce third-party boilerplate:
  • Type Generation: TypeScript interfaces and types
  • Schema Validation: Zod, Valibot, JSON Schema
  • Data Fetching: TanStack Query, Pinia Colada, SWR
  • Framework Integration: Angular, Fastify, and more
The plugin system is highly customizable and extensible.
Sync with Hey API Registry for centralized OpenAPI specification management. Sign up at app.heyapi.dev to manage your API specifications in the cloud.

How It Works

OpenAPI TypeScript follows a simple three-step process:
1

Provide OpenAPI Specification

Point to your OpenAPI specification file (local path, URL, or object). Supports OpenAPI 2.0, 3.0, and 3.1 in JSON or YAML format.
npx @hey-api/openapi-ts -i ./openapi.json -o src/client
2

Configure Plugins

Select which plugins to use for code generation. By default, generates TypeScript types and SDK, but you can add schemas, hooks, and more.
export default defineConfig({
  input: './openapi.json',
  output: 'src/client',
  plugins: [
    '@hey-api/client-fetch',
    '@hey-api/sdk',
    '@hey-api/typescript',
    'zod',
  ],
});
3

Generate & Use

Run the generator and import the generated code in your application. All types are automatically inferred and type-safe.
import { client } from './client';
import { getPets } from './client/sdk.gen';

client.setConfig({
  baseUrl: 'https://api.example.com',
});

const { data, error } = await getPets();

Why OpenAPI TypeScript?

“OpenAPI codegen that just works.” — Guillermo Rauch, CEO of Vercel
OpenAPI TypeScript stands out for its reliability, flexibility, and production-readiness:
  • Type Safety: Full TypeScript support with accurate type inference
  • Framework Agnostic: Works with React, Vue, Angular, Svelte, and more
  • Battle Tested: Used by major companies like Vercel, OpenCode, and PayPal
  • Active Development: Regular updates with new features and improvements
  • Open Source: MIT licensed with a thriving community
  • Extensible: Build custom plugins to fit your specific needs

Next Steps

Try the Quick Start

Generate your first client in under a minute

Explore Examples

See OpenAPI TypeScript in action with live examples

Read the Docs

Explore comprehensive documentation and guides

Join the Community

Contribute or ask questions on GitHub

Build docs developers (and LLMs) love