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

# Authentication

> API key management, Bearer token auth, and SDK configuration

Every request to Forii requires an API key via the `Authorization` header.

<img src="https://mintcdn.com/forii-docs/cNsW6DAG7qkXCpMH/docs/images/dashboards/dashboard-keys.svg?fit=max&auto=format&n=cNsW6DAG7qkXCpMH&q=85&s=4d4a186d96fe9f38540c73a136822b16" alt="API Key Management" width="1200" height="560" data-path="docs/images/dashboards/dashboard-keys.svg" />

## API keys

API keys start with `forii_sk_` and are created in the [Dashboard](https://app.forii.in/dashboard/keys).

### Key types

| Type    | Prefix         | Scope       | When to use                         |
| ------- | -------------- | ----------- | ----------------------------------- |
| SDK key | `forii_sk_...` | Full access | Server-side code, backend services  |
| API key | `forii_...`    | Full access | API management, programmatic access |

<Warning>
  API keys are shown only once at creation time. Store them securely — in environment variables, not in source code.
</Warning>

## Using your API key

### Environment variable

```bash theme={null}
export FORII_API_KEY="forii_sk_..."
```

### Python (OpenAI SDK)

```python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://api.forii.in/inference/v1",
    api_key=os.environ["FORII_API_KEY"],
)
```

### JavaScript (OpenAI SDK)

```javascript theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.FORII_API_KEY,
  baseURL: "https://api.forii.in/inference/v1",
});
```

### cURL

```bash theme={null}
curl https://api.forii.in/inference/v1/chat/completions \
  -H "Authorization: Bearer $FORII_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "forii/deepseek-v3", "messages": [...]}'
```

## Key management

### Create a key

```bash theme={null}
curl -X POST https://api.forii.in/v1/accounts/{account_id}/apiKeys \
  -H "Authorization: Bearer {session_token}" \
  -H "Content-Type: application/json" \
  -d '{"name": "prod-api"}'
```

```json theme={null}
{
  "id": "key_abc123",
  "name": "prod-api",
  "key": "forii_sk_xxxxxxxxxxxxxxxxxxxxxxxx",
  "created": "2025-01-15T10:30:00Z",
  "status": "active"
}
```

### List keys

```bash theme={null}
curl https://api.forii.in/v1/accounts/{account_id}/apiKeys \
  -H "Authorization: Bearer {session_token}"
```

### Revoke a key

```bash theme={null}
curl -X DELETE https://api.forii.in/v1/accounts/{account_id}/apiKeys/{key_id} \
  -H "Authorization: Bearer {session_token}"
```

<Info>
  Currently, all keys have full access. Scoped keys (read-only, inference-only) are coming soon.
</Info>

## Rate limits

Forii is on the **Free Plan** today. Paid tiers are on the roadmap.

| Plan       | RPM (requests per minute) | TPM (tokens per minute)      | Status        |
| ---------- | ------------------------- | ---------------------------- | ------------- |
| Free       | 60                        | 100K prompt / 10K completion | Available now |
| Starter    | 600                       | 1M prompt / 100K completion  | Coming soon   |
| Pro        | 6,000                     | 10M prompt / 1M completion   | Coming soon   |
| Enterprise | Custom                    | Custom                       | Coming soon   |

Rate limit headers are included in every response:

```
X-Ratelimit-Limit-Requests: 600
X-Ratelimit-Remaining-Requests: 543
X-Ratelimit-Reset: 1705312200
```

When you exceed rate limits, the API returns `429 Too Many Requests` with a `Retry-After` header.

## Related

* [Errors](/docs/api-reference/errors) — Error codes and rate limit details
* [Dashboard → Keys](/docs/webapp/dashboard) — Key management in the UI
