Documentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/openai/llms.txt
Use this file to discover all available pages before exploring further.
aisdk/openai requires PHP 8.3 or higher and is distributed through Composer, the standard PHP dependency manager. Before you begin, make sure you have an OpenAI API key — the package will refuse to initialise without one. A PSR-18 compatible HTTP client (such as Guzzle or Symfony HttpClient) and matching PSR-17 factories must also be present in your project so that aisdk/core can dispatch requests.
Require the package
Add Composer will resolve
aisdk/openai to your project using Composer:aisdk/core ^0.2 and all other dependencies automatically.Set your API key
The recommended approach is to export your key as an environment variable so it is never written into source code:If you need to configure the provider programmatically — for example, to point at a custom base URL or supply an organisation ID — use
OpenAI::create():The
OPENAI_API_KEY environment variable is the recommended way to supply credentials. Avoid hard-coding keys in source files — use a .env file (excluded from version control) or your deployment platform’s secrets management.Requirements
| Requirement | Constraint |
|---|---|
| PHP | ^8.3 |
| aisdk/core | ^0.2 |
| PSR-18 HTTP client | e.g. guzzlehttp/guzzle or symfony/http-client |
| PSR-17 request & stream factories | e.g. nyholm/psr7 or guzzlehttp/psr7 |