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

# Connecting the client

> How the TypeScript SDK relates to the hosted platform — most integrators call the REST API instead of embedding sessions locally.

Most production integrations **do not** construct an `OnlyFans` client with
raw session material. You [connect on the hosted API](/connect/overview), keep
the account `id`, and call methods over HTTP:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl "https://api.onlyfanskit.dev/v1/accounts/$ACCOUNT_ID/users/me" \
  -H "Authorization: Bearer $OFK_KEY"
```

The SDK powers that passthrough and documents every method and type. Use
[API reference](/api-reference/introduction) and [SDK resources](/sdk/overview)
for request shapes; use the REST surface to execute calls.

## When you use the SDK directly

The typed client is for runtimes that execute against OnlyFans with a session
already provisioned on onlyfanskit infrastructure (internal services, advanced
automation). It requires the same session fields the platform stores after a
successful connect:

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { OnlyFans } from "onlyfanskit";

const of = new OnlyFans({
  cookie: "<session-cookie>",
  xBc: "<x-bc>",
  userId: "123456789",
  userAgent: "<stable-user-agent>",
});
```

| Option      | Description                               |
| ----------- | ----------------------------------------- |
| `cookie`    | Session cookie for the connected account. |
| `xBc`       | `x-bc` value for the account.             |
| `userId`    | Numeric OnlyFans user id.                 |
| `userAgent` | Stable user agent per account.            |
| `fetch`     | Optional transport override.              |

<Tip>
  If you are building on onlyfanskit.dev, you should not extract cookies from a
  browser or import cURL. Use [embedded connect](/connect/embed) or
  [email + password](/connect/login) and act on the returned account `id`.
</Tip>

## Keeping a session healthy

When a session expires, start a new connect attempt or
[reauthenticate](/connect/two-factor#reauthentication) the account on the hosted
API, then continue calling with the same account `id`.

See [Handling errors](/sdk/errors) for session and upstream failures.
