mirror of
https://github.com/hanzoai/php-sdk.git
synced 2026-10-30 18:24:25 +00:00
The quickstart used KeysApi and the untyped-response example ModelsApi, and the auth notes named DefaultApi and CommandsApi. None exists in src/Api or in the v8.5.156 tag Packagist serves, so `composer require hanzoai/hanzoai` followed by the quickstart died with "Class Hanzo\Cloud\Api\KeysApi not found". They now use AccountApi::getAccountKeys (GET /v1/account/keys, what examples/hello.php calls) and AiApi::getModelsRequest, both present at v8.5.156 and here. scripts/readme refuses any *Api class the README names that src/Api lacks; it runs in the hanzo.yml gate. It exits 1 on the old README and 0 now. Co-authored-by: Hanzo Dev <[email protected]>
31 lines
936 B
PHP
31 lines
936 B
PHP
<?php
|
|
|
|
/**
|
|
* hello ā prove the key works, and print what it can reach.
|
|
*
|
|
* GET /v1/account/keys declares a response schema, so this one comes back as a model:
|
|
* `ApiKeyList` of `ApiKey`, typed, with the prefix and type of every key the
|
|
* caller holds. It is the flow that fails on a bad credential ā that is the
|
|
* point of it ā where models.php succeeds with none.
|
|
*
|
|
* The key is never printed. `prefix` and `type` are what the server returns to
|
|
* identify a key without disclosing it.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
require __DIR__ . '/client.php';
|
|
|
|
use Hanzo\Cloud\Api\AccountApi;
|
|
|
|
try {
|
|
$keys = (new AccountApi(null, authed()))->getAccountKeys()->getKeys() ?? [];
|
|
|
|
printf("%d keys on this account at %s\n", count($keys), base_url());
|
|
foreach ($keys as $key) {
|
|
printf(" %s⦠%s\n", $key->getPrefix() ?? '(no prefix)', $key->getType() ?? 'untyped');
|
|
}
|
|
} catch (Throwable $e) {
|
|
fail($e);
|
|
}
|