openapi-python-client
Generate modern Python clients from OpenAPI
What it is and what it does
openapi-python-client is a code generator that reads OpenAPI 3.0 and 3.1 specifications and produces a complete, modern Python HTTP client library. It uses Jinja2 templates and outputs type-annotated models, endpoint functions organized by tag, and both plain and authenticated client classes. The generated code includes a pyproject.toml, README, and optional post-generation hooks (via ruff) for formatting and linting.
The tool is designed for Python developers who want to avoid hand-writing boilerplate HTTP client code. It depends on attrs, httpx, pydantic, ruamel-yaml, jinja2, typer, colorama, shellingham, and ruff. The project is actively maintained but explicitly notes it is still in development and does not support all OpenAPI features; it also does not support OpenAPI 2.x (Swagger).
Use it for:
- Generate a typed Python client library from a published OpenAPI spec to avoid manual HTTP boilerplate and ensure type safety.
- Automate client updates when an API's OpenAPI spec changes, regenerating models and endpoint functions without hand-editing.
- Create multiple client libraries from different OpenAPI documents using custom Jinja2 templates to match your project's code style.
- Integrate client generation into a CI/CD pipeline to keep generated clients in sync with API specifications.
- Override model class names and customize generated code structure via YAML configuration for non-standard API schemas.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates type-annotated Python HTTP clients from OpenAPI 3.0 and 3.1 specifications, producing ready-to-use client libraries with models, API functions, and authentication support.
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real problem—eliminating hand-written HTTP client boilerplate for OpenAPI-documented APIs. The MIT license is permissive. Trade-off: it is still in beta and does not support all OpenAPI features; verify that your API's spec is compatible before committing to it in production workflows.
Install
openapi-python-client on PyPI
pip
pip install openapi-python-clientuv
uv add openapi-python-clientpoetry
poetry add openapi-python-clientInstalling openapi-python-client
Before you install
Low friction install with a pure-Python wheel. Active maintenance (last commit 2026-08-13), 1980 repository stars, and no known vulnerabilities. Requires Python 3.11 or later. Recommended installation via pipx with --include-deps to ensure ruff is available for post-generation code cleanup.
License in practice
MIT license (permissive) means you can use generated clients freely in commercial and private projects with minimal restrictions. No license compatibility concerns for typical Python development workflows.
Quickstart
pip install openapi-python-client
openapi-python-client generate --url https://api.example.com/openapi.json
# Generates a client library with Client class, API functions, and models
Requires Python 3.11 or later. For full functionality (code formatting), install with pipx and --include-deps flag so ruff is available in your PATH.
Verify before relying
- Extent of OpenAPI feature coverage beyond the note that 'not all OpenAPI features' are supported—which specific features are missing or incomplete
- Performance characteristics when generating clients from very large OpenAPI documents
- Stability of the custom template API, given the description notes it is 'beta-level' and 'undocumented and unstable'
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 9 — attrs, colorama, httpx, jinja2, pydantic, ruamel-yaml, ruff, shellingham, typer |
| Maintenance | actively maintained — 76 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,455,604/month — #2,617 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: openapi_python_client-0.29.0-py3-none-any.whl
Keywords: Client, Generator, OpenAPI
Tags
More Code Generators packages
Proto Plus wraps protocol buffers to provide…
permissive · top 1,000 on PyPI
CythonCython is a source code translator that…
permissive · top 1,000 on PyPI
asttokensAnnotates Python abstract syntax trees with the…
permissive · top 1,000 on PyPI
beartypeBeartype is a runtime type checker that…
permissive · top 1,000 on PyPI
llvmlitellvmlite provides a lightweight Python binding…
permissive · top 1,000 on PyPI
astorastor converts Python abstract syntax trees…
permissive · top 5,000 on PyPI
openapi-generator-cliProvides a Python CLI wrapper for OpenAPI…
permissive · top 15,000 on PyPI
tapipyTapipy is a Python SDK that automatically…
permissive · top 15,000 on PyPI
essentials-openapiGenerates OpenAPI v2 and v3 documentation in…
permissive · top 15,000 on PyPI
openapi3Parses and validates OpenAPI 3 specifications,…
permissive · top 15,000 on PyPI
openapi-schema-pydanticProvides Pydantic classes that map to the…
permissive · top 5,000 on PyPI
benchling-api-clientA low-level HTTP client for Benchling's API,…
permissive · top 15,000 on PyPI
openapi-pydanticProvides Pydantic-based classes that implement…
permissive · top 1,000 on PyPI
sphinxcontrib-openapiSphinx extension that renders OpenAPI (Swagger)…
permissive · top 15,000 on PyPI
aiopenapi3Parses and validates OpenAPI 3 specifications…
permissive · top 15,000 on PyPI
spectreeGenerates OpenAPI documents and validates HTTP…
permissive · top 15,000 on PyPI