# Quotas

4AICode charges based on **total tokens** (prompt + completion combined), and each team has a **monthly quota**.

## Units: What Is a Token

A token is neither a character nor a word. Rough estimates:

- English: 1 token ≈ 3–4 characters / 0.75 words
- Chinese: 1 Chinese character ≈ 1–2 tokens
- Code: somewhere between English and Chinese

Example: a 1,000-character Chinese document ≈ 1,500–2,000 input tokens; a 500-character response ≈ 800–1,000 output tokens.

## Monthly Quotas

- **Individual accounts**: receive free credits upon registration
- **Teams**: configured according to the plan

Progress is refreshed every minute in **Dashboard → View Usage**. Quotas reset at **00:00 UTC on the 1st of each month**.

## Overages

Immediately returns HTTP `429`:

```json
{
  "code": "quota_exceeded",
  "message": "monthly quota reached, contact admin"
}
```

The request is not sent upstream, so **no charges apply**. Access is automatically restored on the 1st of the following month.

## Cost Control

### Choose Smaller Models

- `claude-haiku-*` is an order of magnitude cheaper than sonnet / opus
- `gpt-5.4-mini` is cheaper than `gpt-5.4`

For simple tasks (summarization, classification, translation), **try haiku / mini first**.

### Control `max_tokens`

Anthropic `/v1/messages` requires `max_tokens`. Set it according to actual needs—**do not default to 4096**:

```json
{
  "max_tokens": 512,
  "messages": [...]
}
```

Truncating output and continuing is always cheaper than setting an excessively high limit in a single request.

### Deduplicate System Prompts

Resending a long `system` prompt (thousands of words) each time is expensive:

- Use **Prompt Caching** (supported by Claude, GPT-6 Astra, and GPT-5.6) to reuse stable prefixes
- Put stable content at the beginning and variable content at the end

### GPT-6 Astra / GPT-5.6 Caching and Long-Context Pricing

- Writing to the prompt cache is billed at **1.25×** the standard input rate; cache hits are billed at the cache-read rate.
- When total input for a single request exceeds **272,000 tokens**, input for the entire request is billed at **2×** and output at **1.5×**.
- Usage details separately record standard input, cache writes, cache reads, and output. Final charges are settled based on actual usage.

### Streaming and Non-Streaming Cost the Same

`stream: true` does not affect billing.

## Requesting a Higher Quota

Contact your administrator or support@4aicode.com. Administrators can update it in 30 seconds.

## FAQ

**Q: Can I see how much each token cost?**
A: Yes. Filter by token on the usage page.

**Q: When is billing applied?**
A: When the response completes (or when a stream disconnects). 4xx / 5xx responses are not billed.

**Q: Can I limit a specific token to spending only 20% of the team quota?**
A: Sub-quotas are not currently supported. For now, use **revocation + controlled distribution** to enforce limits.
