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

# Rate Limits

> K-Router API 요청 제한 정책

# Rate Limits

K-Router는 안정적인 서비스 제공을 위해 고객별 요청 제한을 적용합니다.

## 기본 제한

| 구분    | 한도      | 리셋           |
| ----- | ------- | ------------ |
| 분당 요청 | 300회    | 1분마다 자동 리셋   |
| 일일 요청 | 50,000회 | 24시간마다 자동 리셋 |

## 테스트 키

| 구분    | 한도  |
| ----- | --- |
| 일일 요청 | 10회 |

## 인증 실패 보호

| 구분        | 한도                   |
| --------- | -------------------- |
| IP당 인증 실패 | 5분 내 10회 시 5분간 IP 차단 |

## Rate Limit 응답

한도 초과 시 `429 Too Many Requests`를 반환합니다:

```json theme={null}
{
  "error": {
    "message": "Rate limit exceeded: 300 requests per minute.",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded"
  }
}
```

## 권장 사항

* **지수 백오프**: 429 응답 시 1초, 2초, 4초... 순으로 대기 후 재시도
* **요청 배치**: 가능하면 여러 메시지를 하나의 요청으로 묶기
* **캐싱**: 동일한 요청은 클라이언트 측에서 캐싱

```python theme={null}
import time
from openai import OpenAI, RateLimitError

client = OpenAI(
    api_key="kr-your-api-key",
    base_url="https://api.k-router.com/v1"
)

def call_with_retry(messages, max_retries=3):
    for attempt in range(max_retries):
        try:
            return client.chat.completions.create(
                model="kr/gpt54",
                messages=messages
            )
        except RateLimitError:
            wait = 2 ** attempt
            print(f"Rate limited. {wait}초 후 재시도...")
            time.sleep(wait)
    raise Exception("최대 재시도 횟수 초과")
```

<Info>
  더 높은 한도가 필요하시면 [contact@k-router.com](mailto:contact@k-router.com)으로 문의해 주세요. 기업 고객을 위한 맞춤 한도를 제공합니다.
</Info>
