PHPackages                             opctim/chatgpt-schema-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. opctim/chatgpt-schema-generator

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

opctim/chatgpt-schema-generator
===============================

This bundle creates a JSON schema from your classes or DTOs to be used with the ChatGPT API so that you get back what you expect.

1.1.0(1y ago)031MITPHPPHP &gt;=8.3

Since Dec 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/opctim/chatgpt-schema-generator)[ Packagist](https://packagist.org/packages/opctim/chatgpt-schema-generator)[ RSS](/packages/opctim-chatgpt-schema-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

OpenAI ChatGPT JSON Schema Generator
====================================

[](#openai-chatgpt-json-schema-generator)

[![Latest Stable Version](https://camo.githubusercontent.com/f6a5e667ec2e382c87e3a89f9315ac12794dfc21c8c1c257a18ab9ccd81c8a94/68747470733a2f2f706f7365722e707567782e6f72672f6f706374696d2f636861746770742d736368656d612d67656e657261746f722f76)](https://packagist.org/packages/opctim/chatgpt-schema-generator) [![Total Downloads](https://camo.githubusercontent.com/933f0f2de427e3deadf80082e7616bc87be1dfc5535de8be597611105feba132/68747470733a2f2f706f7365722e707567782e6f72672f6f706374696d2f636861746770742d736368656d612d67656e657261746f722f646f776e6c6f616473)](https://packagist.org/packages/opctim/chatgpt-schema-generator) [![Latest Unstable Version](https://camo.githubusercontent.com/b26357d122c77bbad09f6a7a2156e9d5537b6ac7a6c3e74fdc1263f4545056a2/68747470733a2f2f706f7365722e707567782e6f72672f6f706374696d2f636861746770742d736368656d612d67656e657261746f722f762f756e737461626c65)](https://packagist.org/packages/opctim/chatgpt-schema-generator) [![License](https://camo.githubusercontent.com/cb5c0bda597c6399bbec0f8334cae46068ececd7c61b0d8abc726a2b18375446/68747470733a2f2f706f7365722e707567782e6f72672f6f706374696d2f636861746770742d736368656d612d67656e657261746f722f6c6963656e7365)](https://packagist.org/packages/opctim/chatgpt-schema-generator) [![PHP Version Require](https://camo.githubusercontent.com/cd970ce401b6ed01a9680536026829a5fdfb2afdc1aabb1ac7b98e6c6c8acbbc/68747470733a2f2f706f7365722e707567782e6f72672f6f706374696d2f636861746770742d736368656d612d67656e657261746f722f726571756972652f706870)](https://packagist.org/packages/opctim/chatgpt-schema-generator)

Easily generate JSON Schemas for OpenAI ChatGPT prompts using your PHP DTOs!

This package allows you to dynamically create JSON Schemas based on your DTO (Data Transfer Object) classes. These schemas can be passed to OpenAI’s ChatGPT API to ensure consistent, structured, and strongly-typed JSON responses. Ideal for developers who want precise control over ChatGPT outputs in their applications.

Key Features
------------

[](#key-features)

- Seamless Schema Generation: Automatically generate JSON Schemas from your PHP DTO classes.
- Enum Support: Define strict enums in your DTO, and ChatGPT will adhere to your choices.
- Integration Ready: Easily pass the generated schemas to OpenAI APIs for structured responses.
- Serialization Support: Deserialize the JSON response back into your DTO with ease.
- Clean and Reusable Code: Write less boilerplate and focus on building smarter applications.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.3

Installation
------------

[](#installation)

```
composer require opctim/chatgpt-schema-generator
```

Usage
-----

[](#usage)

```
