> For the complete documentation index, see [llms.txt](https://docs.tensorx.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tensorx.ai/account/api-keys.md).

# API Keys

Create, manage, and secure your API keys.

***

## Creating an API Key

1. Go to [Dashboard → API Keys](https://app.tensorx.ai/dashboard/keys)
2. Click **Generate New Key**
3. Enter a descriptive name (3-50 characters)
4. Click **Create**

{% hint style="warning" %}
**Important:** Your API key is only shown once at creation. Copy it immediately and store it securely.
{% endhint %}

### Key Format

Your API key looks like this:

```
sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

In your dashboard, keys are displayed as: `sk-a1b2...wxyz` (first 8 + last 4 characters)

***

## Naming Your Keys

Use descriptive names to track usage and organize your keys:

| Good Names          | Purpose          |
| ------------------- | ---------------- |
| `Production API`    | Live application |
| `Development`       | Local testing    |
| `CI/CD Pipeline`    | Automated builds |
| `Mobile App v2`     | Specific project |
| `Analytics Service` | Internal tool    |

{% hint style="info" %}
Key names appear in your usage logs, making it easy to track which key generated which costs.
{% endhint %}

***

## Managing Keys

### Enable / Disable

You can temporarily disable a key without deleting it:

1. Go to **API Keys** in your dashboard
2. Click the toggle next to the key
3. Disabled keys reject all API requests immediately

This is useful for:

* Pausing a project temporarily
* Testing what happens when a key is invalid
* Security incidents (disable first, investigate later)

### Regenerate

If you suspect a key has been compromised:

1. Click **Regenerate** next to the key
2. Confirm the action
3. Copy the new key immediately

{% hint style="warning" %}
The old key stops working instantly. Update your applications before regenerating.
{% endhint %}

### Delete

Deleting a key is permanent:

* The key stops working immediately
* Usage history is preserved for your records
* This action cannot be undone

***

## Per-Key Usage Tracking

Every API request is logged with the key that made it. View usage by key in your dashboard:

* **Total cost** per key
* **Request count**
* **Tokens used** (input/output)
* **Last used** timestamp
* **Models accessed**

This helps you:

* Track costs per project or environment
* Identify unused keys to clean up
* Spot unexpected usage patterns

***

## Rate Limits

| Limit                              | Value                |
| ---------------------------------- | -------------------- |
| Key operations (create/regenerate) | 15 per hour          |
| API requests                       | 60 per minute        |
| Tokens                             | 2,000,000 per minute |

These limits apply **per API key**. Each key has its own independent rate limit.

***

## Security Best Practices

### Do ✅

* **Use environment variables** - Never hardcode keys in source code
* **Different keys per environment** - Separate dev, staging, and production
* **Name keys descriptively** - Makes auditing easier
* **Rotate regularly** - Use the regenerate feature periodically
* **Delete unused keys** - Reduce your attack surface
* **Monitor usage** - Check logs for unexpected activity

### Don't ❌

* **Never commit keys to git** - Use `.env` files (add to `.gitignore`)
* **Never share keys publicly** - Treat them like passwords
* **Never expose in client-side code** - Keys belong on the server only

### Environment Variables Example

```bash
# .env file (add to .gitignore!)
TENSORX_API_KEY=sk-your-key-here
```

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["TENSORX_API_KEY"],
    base_url="https://api.tensorx.ai/v1"
)
```

***

## Team API Keys

When you're part of a team:

* Team owners and admins can create keys for the team
* All team members can use team API keys
* Usage is billed to the team balance
* Your personal keys are archived while on a team

See [Team Account](/account/team.md) for more details.

***

## Troubleshooting

### "Invalid API Key"

* Verify you copied the complete key (including `sk-` prefix)
* Check the key isn't disabled in your dashboard
* Confirm you're using the correct base URL: `https://api.tensorx.ai/v1`

### "Insufficient Balance"

* Keys require a wallet balance > $0 to create
* Keys are auto-disabled when balance drops to $0.05
* Add funds to re-enable your keys

### Lost Your Key?

API keys cannot be recovered once lost. You'll need to:

1. Delete the old key (if you remember which one)
2. Create a new key
3. Update your applications with the new key

***

## Need Help?

* 📧 **Email**: <support@tensorx.ai>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tensorx.ai/account/api-keys.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
