# Installation URL: /auth/installation Install and set up @onlyfansapi/auth in your project *** title: "Installation" description: "Install and set up @onlyfansapi/auth in your project" icon: Download -------------- import { Tabs, Tab } from "fumadocs-ui/components/tabs"; import { Step, Steps } from "fumadocs-ui/components/steps"; import { Card, Cards } from "fumadocs-ui/components/card"; import { TerminalIcon } from "lucide-react"; ## Package Manager Install `@onlyfansapi/auth` using your preferred package manager: ```bash npm install @onlyfansapi/auth ``` ```bash pnpm add @onlyfansapi/auth ``` ```bash yarn add @onlyfansapi/auth ``` ```bash bun add @onlyfansapi/auth ``` ## Prerequisites Before you begin, make sure you have: } href="https://app.onlyfansapi.com" title="An OnlyFans API account"> If you don't have one yet, registering takes just a few seconds. » Create a free account ## Get Your API Key Before creating a client session token, you'll need an API key to authenticate your requests to the OnlyFans API. ### Go to the OnlyFans API console → API Keys Navigate to your [OnlyFans API console](https://app.onlyfansapi.com) and click on **API Keys** in the navigation menu. ### Create a new API key Click the **"Create API Key"** button to generate a new API key. Copy and save your API key securely - you'll need it to create client session tokens. ## Create Your Client Session Token To use `@onlyfansapi/auth`, you'll need to create a client session token (starts with `ofapi_cs_`) through the [Create Client Session](/api-reference/client-sessions/create-client-session) API endpoint. ### Make a POST request to create a client session Use your API key to authenticate the request: ```bash curl -X POST "https://app.onlyfansapi.com/api/client-sessions" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "display_name": "My Application / Model: John Doe" }' ``` **Optional fields:** * `client_reference_id` - Your internal reference ID for the connected account * `proxy_country` - Proxy country value (`"us" | "uk" | "de" | "fr" | "it"`) ### Get the client session token from the response The response will include a `token` field that starts with `ofapi_cs_`: ```json { "data": { "token": "ofapi_cs_OriR8Sdocp0f97eFOdbMMZtiz4Aw5FLX", "display_name": "My Application / Model: John Doe" } } ``` This token is what you'll use with the `@onlyfansapi/auth` package. ### Use the client session token Copy the client session token and use it in your application with `@onlyfansapi/auth`. **Important:** Keep your client session token secure. While it's designed for client-side use, treat it with appropriate security measures. ## Next Steps Once you've installed the package and created your client session token, you're ready to start implementing authentication in your application. * [Quick Start Guide](/auth/quickstart) - Get up and running in minutes * [Create Client Session API Reference](/api-reference/client-sessions/create-client-session) - Full API documentation * [NPM Package](https://www.npmjs.com/package/@onlyfansapi/auth) - Full package documentation on npm