Skip to content
Host your specs. Generate from anywhere.

Get Started

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

“The ecosystem trusted by TypeScript developers is coming to Python codebases.”

— Lubos, Founder of Hey API
  • production-grade code that compiles
  • runs in any Node.js 22+ environment
  • accepts any OpenAPI specification
  • core plugin for SDKs
  • HTTP client for HTTPX
  • highly customizable via plugins
  • sync with Hey API Registry for spec management

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

Terminal window
npx @hey-api/openapi-python -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.

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

Terminal window
npm install @hey-api/openapi-python -D -E

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.

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

package.json
"scripts": {
"openapi-python": "openapi-python"
}

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

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

script.ts
import { createClient } from '@hey-api/openapi-python';
createClient({
input: 'hey-api/backend', // sign up at app.heyapi.dev
output: 'src/client',
});

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.