I am trying the following using PHP Curl
$curl = curl_init();
CURLOPT_URL => ‘ https://api.openai.com/v1/images/generations’,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => ‘’,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => ‘POST’,
“prompt”: “Need two tigers with puppy”,
CURLOPT_HTTPHEADER => array(
‘Authorization: Bearer sk-UWGEEW@ksdk## @UoebT3BlbkFJveMcC99999f682hjsd’
$response = curl_exec($curl);
but i am getting following result only
please help, but when run the above code in Postman then it’s working but it’s not working using PHP
I don’t have an answer for you, but I do have two recommendations in order of importance.
Redact your auth token immediately
Use a code block with indentation to help readers understand your code better.
He does not need to do that because he added some random noise to his key so its just noise and not his actual API key.
I’m glad this is the case, but a hacker at Blackhat Las Vegas once showed me how to use a key with random changes to determine the actual key. I was stunned, not because he did it, but because he did it in 11 seconds.
Well, that is a nice CYA reply
There is no risk in how
@chetanprakashsharma obfuscated his key and he did what any prudent person would have done.
I can accept that, but will everyone who is less informed get a false sense that it’s okay to include their keys openly? After all, a good number of people in this community are new to APIs and auth tokens, right?
I think you are pushing a non-issue and you should let it rest
@bill.french , TBH.
There is nothing technically wrong in what
@chetanprakashsharma posted and he added random noise as he deemed appropriate.
I do the exact same thing all the time and I have many decades of cybersecurity experience.
OBTW . It was trivial to look at what
@chetanprakashsharma posted to see that he masked out his key as he deemed appropriate.
If you search the forums, you will see a number of PHP examples.
For example, here is one related to fine-tuning which you can easily modify to apply toward your image completion request:
Finally, I have managed to do it like this
$headers = array();
$headers = "Content-Type: multipart/form-data";
$headers = "Authorization: Bearer sk...";
$cf = new CURLFile("trainingdata.jsonl");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.openai.com/v1/files");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, ["purpose" => "fine-tune" ,"file" => $cf]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers)…