'{username}', 'apiKey' => '{apiKey}', )); // 2. Create Compute service object $service = $client->computeService(null, '{region}'); // 3. Get empty keypair $keypair = $service->keypair(); // 4. Create $keypair->create(array( 'name' => 'new_keypair' )); echo $keypair->getPublicKey(); // 5. Save private key to a file so you can use it to SSH into your server later $filename = 'new_keypair_private'; $privateKey = $keypair->getPrivateKey(); file_put_contents($filename, $privateKey); chmod($filename, 0600);