File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ header ('Content-Type: application/json ' );
3+ header ('Access-Control-Allow-Origin: * ' );
4+ header ('Access-Control-Allow-Methods: POST ' );
5+ header ('Access-Control-Allow-Headers: Content-Type, Authorization ' );
6+
7+ // Replace YOUR_API_KEY with your actual GPTChat API key
8+ define ('API_KEY ' , 'YOUR_API_KEY ' );
9+
10+ if ($ _SERVER ['REQUEST_METHOD ' ] === 'POST ' ) {
11+ $ input = json_decode (file_get_contents ('php://input ' ), true );
12+ $ message = urlencode ($ input ['message ' ]);
13+
14+ $ url = "https://api.gptchat.com/v1/engines/gpt-4/complete?api_key= " . API_KEY . "&message= " . $ message ;
15+
16+ $ response = file_get_contents ($ url );
17+ echo $ response ;
18+ } else {
19+ http_response_code (405 );
20+ echo json_encode (['error ' => 'Method not allowed ' ]);
21+ }
You can’t perform that action at this time.
0 commit comments