---
title: "OpenAPI to TypeScript in seconds."
description: "Generate production-grade API infrastructure from your OpenAPI spec. Typed SDKs, Zod schemas, TanStack Query hooks, and 20+ plugins. Free and open source."
url: "https://heyapi.dev/codegen/openapi/typescript"
---

[soon Python code generator](#email-cta)

# OpenAPI to TypeScriptTypeScript✓ Python✓ in seconds.

Production-grade API infrastructure. Typed SDKs, Zod schemas, TanStack Query hooks, and 20+ plugins. Free and open source.

$ `npx @hey-api/openapi-ts`

2.7M downloads last week

[Get Started → ](https://heyapi.dev/docs/openapi/typescript/get-started) [View Demo ↗](https://stackblitz.com/edit/hey-api-example)

types  Zod  Valibot  SDK  TanStack Query

```typescript
export type Order = {
  id: string;
  symbol: string;
  side: 'buy' | 'sell';
  type: 'market' | 'limit' | 'stop' | 'stop_limit';
  quantity: number;
  price?: number;
  status: 'pending' | 'open' | 'filled' | 'partially_filled' | 'cancelled' | 'rejected';
  createdAt: string;
};


export type CreateOrderData = {
  body: Order;
};


export type CreateOrderResponse = Order;
```

```typescript
import { z } from 'zod';


export const zOrder = z.object({
  id: z.string().uuid(),
  symbol: z.string(),
  side: z.enum(['buy', 'sell']),
  type: z.enum(['market', 'limit', 'stop', 'stop_limit']),
  quantity: z.number(),
  price: z.number().optional(),
  status: z.enum(['pending', 'open', 'filled', 'partially_filled', 'cancelled', 'rejected']),
  createdAt: z.string().datetime(),
});


export type Order = z.infer<typeof zOrder>;
```

```typescript
import * as v from 'valibot';


export const vOrder = v.object({
  id: v.pipe(v.string(), v.uuid()),
  symbol: v.string(),
  side: v.picklist(['buy', 'sell']),
  type: v.picklist(['market', 'limit', 'stop', 'stop_limit']),
  quantity: v.number(),
  price: v.optional(v.number()),
  status: v.picklist(['pending', 'open', 'filled', 'partially_filled', 'cancelled', 'rejected']),
  createdAt: v.pipe(v.string(), v.isoTimestamp()),
});


export type Order = v.InferOutput<typeof vOrder>;
```

```typescript
import { createOrder } from './sdk.gen';


const { data, error } = await createOrder({
  symbol: 'AAPL',
  side: 'buy',
  type: 'limit',
  quantity: 10,
  price: 189.5,
});


if (error) {
  console.error('Order failed:', error.message);
  return;
}


console.log('Order placed:', data.id);
```

```typescript
import { useMutation } from '@tanstack/react-query';
import { createOrderMutation } from './react-query.gen';


const { mutate, data, isPending } = useMutation({
  ...createOrderMutation(),
});


mutate({
  body: {
    symbol: 'AAPL',
    side: 'buy',
    type: 'limit',
    quantity: 10,
    price: 189.5,
  },
});
```

Pydantic  SDK

```python
from pydantic import BaseModel, AwareDatetime
from typing import Literal
from uuid import UUID


class Order(BaseModel):
    id: UUID
    symbol: str
    side: Literal['buy', 'sell']
    type: Literal['market', 'limit', 'stop', 'stop_limit']
    quantity: float
    price: float | None = None
    status: Literal['pending', 'open', 'filled', 'partially_filled', 'cancelled', 'rejected']
    createdAt: AwareDatetime
```

```python
from client import Client, CreateOrderData


client = Client()


order, error = client.create_order(CreateOrderData(
    symbol='AAPL',
    side='buy',
    type='limit',
    quantity=10,
    price=189.50,
))


if error:
    print(f'Order failed: {error.message}')
else:
    print(f'Order placed: {order.id}')
```

GR ![Guillermo Rauch](https://heyapi.dev/_astro/guillermo-rauch.CXfXwXLP_1He5jC.webp)

"OpenAPI codegen that just works."

Guillermo Rauch CEO of Vercel

Trusted by

[ Vercel](https://vercel.com/blog/how-we-built-the-v0-ios-app)

OpenCode

PayPal

Amazon

Autodesk

## Up and running in minutes

One config file. One command. Every time your spec changes.

01 / 04 Define your API

01

Define your API

02

Connect your spec

03

Compose your output

04

Use it

### Define your API

Start with an existing spec or create one from scratch. OpenAPI is the foundation that powers everything.

```typescript
openapi: 3.2.0
info:
  title: Equity Trading API
  version: 1.2.0
paths:
  /orders:
    post:
      operationId: createOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Order'
      responses:
        '201':
          description: Order placed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
```

### Connect your spec

Pass a local path, remote URL, or an API registry shorthand. All valid OpenAPI versions and file formats supported, including inline spec objects.

```typescript
export default defineConfig({
  input: 'https://api.tradespark.io/openapi.json',
  output: 'src/trading-client',
});
```

### Compose your output

Choose exactly what gets generated – nothing more, nothing less. Each plugin is independent and composable.

```typescript
export default defineConfig({
  input: 'https://api.tradespark.io/openapi.json',
  output: 'src/trading-client',
  plugins: ['@hey-api/sdk', 'zod', '@tanstack/react-query'],
});
```

### Use it

Run once or integrate into CI. Generated code is fully typed and deterministic. Same spec, same output, every time.

```typescript
import { createOrder, zOrder } from './trading-client';


const { data, error } = await createOrder({
  body: {
    symbol: 'AAPL',
    side: 'buy',
    type: 'limit',
    quantity: 10,
    price: 189.5,
  },
});


if (error) {
  console.error('Order rejected:', error.message);
  return;
}


const order = zOrder.parse(data);
console.log(`Order ${order.id} is ${order.status}`);
```

Skip section ↓

## Everything your API layer needs

Pick what you need. Everything works together.

### SDKs & Types

Typed SDK clients that regenerate as your API evolves. No handwritten interfaces to maintain.

[Get started →](https://heyapi.dev/docs/openapi/typescript/get-started)

### Plugin Ecosystem

From TanStack Query to Zod. Every plugin is opt-in, independently useful, and built to work together.

[Explore plugins →](https://heyapi.dev/docs/openapi/typescript/core)

### HTTP Clients

Native support for your runtime. Fetch API, Axios, Angular, Next.js, Nuxt, and more.

[Explore clients →](https://heyapi.dev/docs/openapi/typescript/clients)

### Extensibility

Build custom plugins and clients with the same APIs powering the built-ins. A platform, not a black box.

[Build a plugin →](https://heyapi.dev/docs/openapi/typescript/plugins/custom)

20+

plugins available

TanStack Query, Zod, Valibot, Fastify, and more.

[Find your plugin →](https://heyapi.dev/docs/openapi/typescript/core)

Skip section ↓

Honest take

## Not the right fit if…

* — Your spec is broken or out of date.
* — You're building a one-off integration, not a long-term API contract.
* — You already have a codegen workflow that works.
* — You want zero build steps.
* — We don't support your language yet.

If none of these apply, you'll probably love it.

> The API tooling I always wanted.
>
> I built API clients for years using every tool out there. They all felt like an afterthought – I was always sacrificing quality, workflow, cost, or speed.
>
> Eventually, I decided to reject those trade-offs. But I didn't want to build yet another code generator. I wanted to create the last code generator. After years of work, I'm excited to finally share it with you.
>
> Hey API is purpose-built from scratch to handle all kinds of APIs, yours included. It's fast, open source, and deeply customizable. The output is production-grade. Most importantly, it just works.
>
> I can't wait to see what you build with it.

[L](https://linkedin.com/in/mrlubos)

[![Lubos](https://heyapi.dev/_astro/mrlubos_2l8XdT.webp)](https://linkedin.com/in/mrlubos)

[**Lubos**  Founder, Hey API](https://linkedin.com/in/mrlubos)

Coming soon

## Python is next.

The ecosystem trusted by TypeScript developers is coming to Python codebases. Production-grade SDKs, Pydantic models, and more. Sign up for early access.

<stan.smith@company.com> Notify me

## Sponsors

They make this possible. We make it worth sponsoring.

gold

* [![Stainless logo](https://heyapi.dev/_astro/stainless.BaBOViba_1sm8nf.webp)](https://kutt.to/pkEZyc)

  [Best-in-class interfaces for developers and agents.](https://kutt.to/pkEZyc)
* [The open source AI coding agent.](https://kutt.to/QM9Q2N)

silver

* [](https://kutt.to/skQUVd)
* [](https://kutt.to/Dr9GuW)

[Become a sponsor →](https://heyapi.dev/sponsors)

## Ready when you are.

Player 1 OpenAPI Spec READY

VS

Player 2 Your Client READY?

[Get Started → ](https://heyapi.dev/docs/openapi/typescript/get-started)[View on GitHub ↗](https://github.com/hey-api/openapi-ts)
