Hello world: PHP
Preview — installs from source. Not yet tested end to end.
Runs today on Linux x86-64. On macOS, Windows and ARM the on-device engine is not available yet; the SDK uses basic detection and shows a warning.
1. Get an API key
Create a key at app.cloakapi.io/api-keys. It starts with cloak_. Verify your email to unlock your trial balance.
2. Install
Set up the on-device engine and pin: Engine setup.
curl -fsSLO https://app.cloakapi.io/downloads/sdks/php/cloakapi-php-1.3.2-src.zipunzip -q cloakapi-php-1.3.2-src.zip -d third_partycomposer init -n --name you/hellocomposer config repositories.cloakapi path third_party/phpcomposer require cloakapi/cloakapi-php:@dev3. Set your key
export CLOAKAPI_API_KEY="cloak_your_key_here"4. Run hello world
<?phprequire __DIR__ . '/vendor/autoload.php';
use CloakAPI\ApiException;use CloakAPI\Client;
$apiKey = getenv('CLOAKAPI_API_KEY');if ($apiKey === false || $apiKey === '') { fwrite(STDERR, "CLOAKAPI_API_KEY is not set. Create a key at https://app.cloakapi.io/api-keys\n"); exit(1);}
$client = new Client($apiKey);$review = $client->messages()->review([ 'model' => 'claude-sonnet-4-6', 'max_tokens' => 100, 'messages' => [['role' => 'user', 'content' => 'Say hello to jane.doe@example.com in one short sentence.']],]);
echo "This exact request will leave your machine:\n\n", $review->serializedBody(), "\n\nSend it? [y/N] ";if (strtolower(trim((string) fgets(STDIN))) !== 'y') { echo "Not sent. You declined the request.\n"; exit(0);}$review->approve();
try { $resp = $client->messages()->create($review);} catch (ApiException $e) { fwrite(STDERR, "Request failed: {$e->getMessage()}\n"); exit(1);}echo "\nReply (restored on your device):\n", $resp['content'][0]['text'], "\n";cp path/to/examples/hello.php .php hello.php5. What you should see
You’ll see the exact request before it is sent. Your email address is replaced with a token like <<CLOAK:CONTACT_EM:3f9a1c>>. Type y. The reply comes back with the real address restored on your device. The reply text varies.
If something goes wrong
See the PHP SDK README for common messages and fixes.
What this does and does not do
- Detection is best-effort. Emails, phone numbers, cards and similar are matched by rules; names use an on-device list and an optional on-device model, and may be missed.
- You see the exact request before it is sent.
- CloakAPI does not refuse a request because of what it contains. Errors come from your key, balance, usage limits, request format or size, or the model provider.
- The gateway does not run detection on your content. It checks the request proof, then relays it to the model provider.