Python type definitions generated from OpenAI's OpenAPI specification
LMOS-openai-types provides strongly-typed Python models generated from OpenAI's official OpenAPI specification. It serves as a foundational package in the LMOS ecosystem, ensuring type safety and consistency across all LMOS services that interact with OpenAI-compatible APIs.
- 🔄 Auto-generated Types: Automatically generates Python types from OpenAI's OpenAPI specification
- 📦 Multiple Format Support: Generates both Pydantic and Msgspec models
- 🔍 Type Safety: Provides full type hints and validation for OpenAI API objects
- 🔄 CI/CD Integration: Automated builds via GitHub Actions
This repository automatically generates two Python packages:
-
Pydantic Models (branch:
pydantic-gen)- Built using Pydantic v2
- Full validation support
- IDE-friendly with complete type hints
-
Msgspec Models (branch:
msgspec-gen)- High-performance serialization
- Optimized for production deployments
- Reduced overhead compared to Pydantic
To set up the development environment:
-
Open in Dev Container (recommended)
# VSCode will automatically detect and open the dev container -
Install dependencies
pip install -r builder/requirements.txt
-
Generate types
# Generate Pydantic models python builder/generate_package.py # Generate Msgspec models python builder/generate_package.py --modeltype MsgspecStruct
The repository includes two GitHub Actions workflows:
build-pydantic.yml: Generates Pydantic modelsbuild-msgspec.yml: Generates Msgspec models
Both workflows:
- Trigger on pushes to main/master
- Generate respective Python packages
- Push to separate branches (
pydantic-genandmsgspec-gen)
The repository includes validation for the OpenAPI specification:
- Validates the OpenAPI definition using Swagger Editor
- Runs on pull requests
- Ensures specification compliance
├── builder/ # Type generation scripts
│ ├── requirements.txt # Python dependencies
│ └── generate_package.py # Main generation script
├── .devcontainer/ # Dev container configuration
├── .github/workflows/ # GitHub Actions workflows
└── openapi.yaml # OpenAI API specification
We welcome contributions! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request
Apache 2.0 - See LICENSE for details
This package is part of the larger LMOS (Language Model Orchestration System) ecosystem. Visit LMOS.io to learn more about our other packages and services.