> ## Documentation Index
> Fetch the complete documentation index at: https://docs.platform.toloka.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# createClient

> Create a typed client for the platform's HTTP API.

```ts theme={null}
import type { ClientConfig, PotatoClient } from "@toloka-platform/sdk";

declare function createClient(config: ClientConfig): PotatoClient;
```

## Parameters

**config** `ClientConfig` *required*

The platform URL and exactly one credential.

**Configuration**

**baseUrl** `string` *required*

Absolute platform URL, usually `https://platform.toloka.ai`. Path prefixes are preserved. Do not append `/api/v2-beta`.

**apiKey** `string`

Sends `Authorization: ApiKey <key>`. A value starting with `pst_` sends `X-Scoped-Token` instead. Mutually exclusive with the other credentials.

**scopedToken** `string`

Sends `X-Scoped-Token: <token>`. Mutually exclusive with the other credentials.

**accessToken** `() =\> Promise\<string\>`

Called for each SDK request. Sends the returned value as `Authorization: Bearer <token>`. Mutually exclusive with the other credentials.

**fetch** `typeof globalThis.fetch` (default: globalThis.fetch)

Custom fetch implementation, for example to inspect response headers.

## Returns

**client** `PotatoClient`

A client with typed resource methods and `waitFor`. Construction makes no request. See the [client method index](https://docs.platform.toloka.ai/docs/sdk/reference/client-methods.md) for operations and [waitFor](https://docs.platform.toloka.ai/docs/sdk/reference/wait-for.md) for polling.

## Throws

Throws a local error for an empty base URL, an invalid absolute URL, or an empty API key or scoped token. It does not verify credentials against the platform during construction.

See [client and credentials](https://docs.platform.toloka.ai/docs/sdk/client.md) for token management, request bodies, and rate limits.

```ts theme={null}
import { createClient } from "@toloka-platform/sdk";

const apiKey = process.env.TOLOKA_API_KEY;
if (!apiKey) throw new Error("Set TOLOKA_API_KEY");

const client = createClient({
  baseUrl: process.env.TOLOKA_BASE_URL ?? "https://platform.toloka.ai",
  apiKey,
});

const me = await client.me();
console.log(me.id, me.email);
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.