Fetch
Create Freestyle Fetch

OpenAPI Generator

Generate type-safe API clients from OpenAPI specifications.

What is create-freestyle-fetch?

create-freestyle-fetch is a CLI tool that transforms OpenAPI specifications into fully type-safe TypeScript API clients powered by the @freestylejs/fetch library.

It eliminates manual API client code and keeps your client in sync with your API specification.

The generated code uses Zod v4 for runtime validation and provides complete type inference for requests and responses.

Key Features

Quick Example

Generate a fully typed API client from your OpenAPI specification:

npx create-freestyle-fetch generate \
  --input ./api-spec.json \
  --output ./src/api

Use the generated client in your code:

import { createClient } from './api'

// Initialize the client
const client = createClient({
  baseUrl: 'https://api.example.com'
})

// Fully typed request and response
const user = await client.users.$userId.GET({
  params: { userId: '123' }
})

// TypeScript knows the shape of `user`
console.log(user.name, user.email)

What is Next?