# Client

Source: https://docs.orbytelabs.com/sdk/client

Authenticate requests and handle their results.

```typescript title="TypeScript"
import { Orbyte } from "orbytelabs";

const client = new Orbyte({ accessToken: process.env.ORBYTE_API_KEY });
```

`accessToken` accepts an environment API key or a user OAuth access token.
API keys select their own environment. See [authentication](/authentication)
to create one.

With OAuth, set `environmentId` or `orgId` on the client, or pass scope to the
resource operation:

```typescript title="TypeScript"
const client = new Orbyte({ accessToken: oauthAccessToken, environmentId });
await client.balances.get({ identity: "customer_123" });
```

The `balance`, `check`, and `track` shortcuts read `ORBYTE_API_KEY` directly.
The SDK does not load environment files. An optional constructor `signal`
cancels requests and provisioning waits. Cancellation does not undo server work.

## Exact values [#exact-values]

Use `credits()` for integer ledger units and `usd()` for integer nano dollars.
Balances are `bigint`; convert them to decimal strings when returning JSON.

```typescript title="TypeScript"
import { credits, usd } from "orbytelabs";

credits("0.01"); // 10000000n
usd("9.99"); // 9990000000n
```

## Errors and retries [#errors-and-retries]

API, validation, and transport failures reject with `Error`. A denied check
returns `allowed: false`. The SDK does not retry requests automatically.

Reuse a stable idempotency key and unchanged input when retrying tracking or
grants. Inspect created resources before repeating an uncertain checkout or
deployment. See [errors and retries](/errors) for response details.