This PHP package provides a comprehensive client for interacting with the OpenAI API, targeting PHP developers who need to integrate AI capabilities like text generation, image creation, and audio processing into their applications. It offers fully typed Data Transfer Objects (DTOs) for requests and responses, enhancing code maintainability and IDE support.
How It Works
The client leverages a PSR-18 compatible HTTP client (like Guzzle or Symfony HTTP Client) to make requests to the OpenAI API. It abstracts API endpoints into distinct "handlers" (e.g., ChatCompletions
, ImagesGenerations
) and provides methods for each operation. Responses can be retrieved as typed DTOs (toModel()
), associative arrays (toArray()
), or raw PSR-7 response objects (getResponse()
), offering flexibility in data handling.
Quick Start & Requirements
- Install via Composer:
composer require tectalic/openai
- Requires PHP 7.2.5 or newer.
- Requires a PSR-18 compatible HTTP client (e.g., Guzzle, Symfony HTTP Client).
- OpenAI API key is required for authentication.
- Official documentation: https://tectalic.com/apis/openai
Highlighted Details
- Supports 19 API Handlers and 28 API Methods, including Chat Completions (GPT-3.5, GPT-4), Text Completions (GPT-3), Code Completions (Codex), Image Generation (DALL·E), and Speech-to-Text (Whisper).
- Includes DTOs for all request and response models, enabling IDE autocompletion and type safety.
- Supports function calling for ChatGPT.
- Provides methods for managing files and fine-tuning jobs.
Maintenance & Community
- The README explicitly states: "This package is no longer supported or maintained."
- Support is available via a discussion board.
Licensing & Compatibility
- Licensed under a proprietary license (copyright © 2022-present Tectalic). The specific license terms are in the LICENSE file, which is not provided in the README.
- Compatibility for commercial use or closed-source linking is not specified and should be verified with the LICENSE file.
Limitations & Caveats
- The package is explicitly stated as no longer supported or maintained, indicating a lack of future updates or bug fixes.
- Several API methods (Edits, older FineTunes) are marked as deprecated.
- The LICENSE file is not included in the README, making it difficult to assess commercial use restrictions.