API client 

The Zak_ai API client layer consists of two classes:

  • \Wegewerk\Ai3Core\Api\ZakAiClient — low-level PSR HTTP wrapper
  • \Wegewerk\Ai3Core\Api\ZakAiAccount — account-level operations

Both classes are registered as services and can be injected via constructor DI.

ZakAiClient 

ZakAiClient handles authentication and the raw HTTP layer. It reads credentials from the environment at construction time (see Environment variables). The base URL defaults to https://www.zak-ai.com/api/v1/.

Public methods:

Method Description
postJson(string $path, array $payload, ...) Sends a JSON POST and returns the decoded response. Appends model to the payload automatically.
putJson(string $path, array $payload, ...) Sends a JSON PUT.
getJson(string $path, ...) Sends a GET request (no body).
hasApikey(): bool Returns true if ZAKAI_API_KEY is non-empty.
hasSecret(): bool Returns true if ZAKAI_SECRET is non-empty.

All request methods accept optional $extraHeaders and a $requireAuth flag. When $requireAuth is true (default) and no API key is set, a \RuntimeException is thrown before the request is sent.

ZakAiAccount 

ZakAiAccount wraps the account-related endpoints:

Method Description
requestApikey(mixed $email, string $secret) POST /accounts — request a new API key.
confirmApikey() PUT /accounts — confirm the pending API key.
queryCredits(): mixed GET /credits — return the current credit balance.
clientHasApikey(): bool Proxy for ZakAiClient::hasApikey().
clientHasSecret(): bool Proxy for ZakAiClient::hasSecret().