$response = wp_remote_post( 'https://api.openai.com/v1/images/generations', array( 'headers' => array( 'Content-Type' => 'application/json', 'Authorization' => 'Bearer YOUR_API_KEY' ), 'body' => json_encode(array( 'model' => 'image-alpha-001', 'prompt' => 'Generate an image of a cat', 'num_images' => 1, 'size' => '256x256', 'response_format' => 'url' )) )); if ( is_wp_error( $response ) ) { // handle error } else { $response_body = json_decode( $response['body'] ); $image_url = $response_body->data[0]->url; // do something with the image URL } Hello world! – My Blog

1 thought on “Hello world!”

Leave a Comment

Your email address will not be published. Required fields are marked *