fork download
  1. <?php
  2. $curl = curl_init();
  3.  
  4. CURLOPT_URL => "https://g...content-available-to-author-only...i.com/chat/completions",
  5. CURLOPT_RETURNTRANSFER => true,
  6. CURLOPT_ENCODING => "",
  7. CURLOPT_MAXREDIRS => 10,
  8. CURLOPT_TIMEOUT => 30,
  9. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  10. CURLOPT_CUSTOMREQUEST => "POST",
  11. CURLOPT_POSTFIELDS => json_encode([
  12. 'model' => 'gpt-4o',
  13. 'messages' => [
  14. [
  15. 'role' => 'user',
  16. 'content' => 'There are ten birds in a tree. A hunter shoots one. How many are left in the tree?'
  17. ]
  18. ]
  19. ]),
  20. CURLOPT_HTTPHEADER => [
  21. "Content-Type: application/json",
  22. "x-rapidapi-host: gpt-4o.p.rapidapi.com",
  23. "x-rapidapi-key: 24a6b153acmsh331da384778626dp1b846djsnd4b0f10c24e8"
  24. ],
  25. ]);
  26.  
  27. $response = curl_exec($curl);
  28. $err = curl_error($curl);
  29.  
  30. curl_close($curl);
  31.  
  32. if ($err) {
  33. echo "cURL Error #:" . $err;
  34. } else {
  35. echo $response;
  36. }
  37. ?>
  38.  
Success #stdin #stdout 0.04s 26412KB
stdin
Standard input is empty
stdout
cURL Error #:Could not resolve host: gpt-4o.p.rapidapi.com