@allternit/platform is a typed client for the Platform API. It has no runtime dependencies and uses the global fetch, so it runs on Node 18+, Deno, Bun and in browsers (keep live keys on your server).
PaymentRequiredError (402, code: "payment_method_required") with err.url, the console billing page. See Billing.
Create a client
client.accounts, client.agents (also model keys), client.conversations, client.numbers, client.messaging, client.webhooks, client.usage. Requests and responses are typed from the OpenAPI file.
client.http.request({ method: "GET", path: "/v1/…" }).
Request options
The last argument of every method is{ idempotencyKey?, signal?, timeout?, headers?, query? }.
Idempotency
EveryPOST carries an Idempotency-Key header. The SDK makes a random one per call; pass your own to make a retry safe across process restarts:
Errors
Non-2xx answers throw a subclass ofAPIError with status, type, code, message, param and requestId:
Network failures throw
APIConnectionError; a timeout throws APITimeoutError. Codes are listed in Errors.
Pagination
Streaming replies
stream.finalMessage() reads to the end and returns the stored reply. An error event throws a typed APIError (for example code: "turn_failed"). Pass { signal } to stop reading; the reply is still stored on the server.
Regenerating
The typed layer (src/generated/) is generated from cmd/allternit-cloud-api/openapi/platform-v1.yaml: