# Key

> Read the calling key's limit and spend, and the account's available credit and free credit.

**GET** `https://deference.si/v1/key`

Returns details about the key in the request. Use it to check credit from a script or a statusline. Send the key as `Authorization: Bearer sk-df-...` or `x-api-key`.

## Example

**curl**

```bash
curl https://deference.si/v1/key \
  -H "Authorization: Bearer $DEFERENCE_API_KEY"
```

**Python**

```python
import os
import requests

response = requests.get(
    "https://deference.si/v1/key",
    headers={"Authorization": f"Bearer {os.environ['DEFERENCE_API_KEY']}"},
)
print(response.json()["data"]["credit_available"])
```

**TypeScript**

```typescript
const response = await fetch("https://deference.si/v1/key", {
  headers: { Authorization: `Bearer ${process.env.DEFERENCE_API_KEY}` },
});
const { data } = await response.json();
console.log(data.credit_available);
```

## Response

```json
{
  "data": {
    "name": "claude-code",
    "label": "sk-df-Ab3x…Qz9k",
    "limit": 50,
    "usage": 12.4,
    "limit_remaining": 37.6,
    "credit_available": 112.8,
    "free_credit_available": 1.25,
    "free_credit_expires_at": "2026-11-07T00:00:00.000Z",
    "expires_at": null
  }
}
```

## Fields

* `name` (string): The key's name.
* `label` (string): The masked key.
* `limit` (number | null): The key's credit limit in dollars, or `null` for no limit.
* `usage` (number): Dollars the key has spent.
* `limit_remaining` (number | null): The limit minus usage and minus the credit the key's running requests hold, never below `0`, or `null` for no limit. This is what a new request on the key can use.
* `credit_available` (number): The account's credit balance minus held credit, in dollars, and `0` when that is negative. This does not include free credit.
* `free_credit_available` (number): The account's free credit that can still be spent, in dollars: grants that have not expired, less what running requests hold. `0` when there is none. See [Free credit](https://deference.si/docs/concepts/free-credit).
* `free_credit_expires_at` (string | null): An ISO 8601 time: when the next free credit expires. `null` when there is no free credit, or none of it expires.
* `expires_at` (string | null): An ISO 8601 time, or `null` if the key does not expire.

## Errors

A bad key returns the key errors in [Authentication](https://deference.si/docs/api-reference/authentication), in the OpenAI envelope.
