ChatGPT API: Complete Guide
OpenAI API provides access to GPT-4o, GPT-4o-mini, o1 for chatbots, content generation, and automation.
PHP Integration
composer require openai-php/client<?php
$client = OpenAI::client($_ENV['OPENAI_API_KEY']);
$response = $client->chat()->create([
'model' => 'gpt-4o-mini',
'messages' => [
['role' => 'system', 'content' => 'You are a support assistant.'],
['role' => 'user', 'content' => 'How do I add a domain in cPanel?'],
],
]);
echo $response->choices[0]->message->content;Pricing (2025)
| Model | Input | Output |
|---|---|---|
| gpt-4o-mini | $0.15/1M | $0.60/1M |
| gpt-4o | $2.50/1M | $10.00/1M |
Save money: gpt-4o-mini is 15x cheaper than GPT-4o with comparable quality for simple tasks.