{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# How to handle rate limits\n", "\n", "When you call the OpenAI API repeatedly, you may encounter error messages that say `429: 'Too Many Requests'` or `RateLimitError`. These error messages come from exceeding the API's rate limits.\n", "\n", "This guide shares tips for avoiding and handling rate limit errors.\n", "\n", "To see an example script for throttling parallel requests to avoid rate limit errors, see [api_request_parallel_processor.py](api_request_parallel_processor.py).\n", "\n", "## Why rate limits exist\n", "\n", "Rate limits are a common practice for APIs, and they're put in place for a few different reasons.\n", "\n", "- First, they help protect against abuse or misuse of the API. For example, a malicious actor could flood the API with requests in an attempt to overload it or cause disruptions in service. By setting rate limits, OpenAI can prevent this kind of activity.\n", "- Second, rate limits help ensure that everyone has fair access to the API. If one person or organization makes an excessive number of requests, it could bog down the API for everyone else. By throttling the number of requests that a single user can make, OpenAI ensures that everyone has an opportunity to use the API without experiencing slowdowns.\n", "- Lastly, rate limits can help OpenAI manage the aggregate load on its infrastructure. If requests to the API increase dramatically, it could tax the servers and cause performance issues. By setting rate limits, OpenAI can help maintain a smooth and consistent experience for all users.\n", "\n", "Although hitting rate limits can be frustrating, rate limits exist to protect the reliable operation of the API for its users." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Default rate limits\n", "\n", "As of Jan 2023, the default rate limits are:\n", "\n", "
\n", " | Text Completion & Embedding endpoints | \n", "Code & Edit endpoints | \n", "
---|---|---|
Free trial users | \n", "\n",
"
| \n",
" \n",
"
| \n",
"
Pay-as-you-go users (in your first 48 hours) | \n", "\n",
"
| \n",
" \n",
"
| \n",
"
Pay-as-you-go users (after your first 48 hours) | \n", "\n",
"
| \n",
" \n",
"
| \n",
"