All samples

Simulate throttling of the OpenAI API

This sample contains a preset and mocks to simulate the throttling of the OpenAI API. As more and more applications use OpenAI API to use AI, it's important that developers can verify that their apps can properly handle cases when the API is throttled. Especially when the app is using lower-tier API plans, throttling is more likely to happen so validating the app's behavior is crucial to ensure great user experience. Using this preset you can simulate throttling of the OpenAI API and see how your app will handle it. The preset includes 3 different throttling scenarios: exceeded tokens per minute, exceeded number of requests per minute and service overload, which includes dynamic simulation of handling retry-after. Proxy will simulate throttling the API using one of these modes at random.

Waldek Mastykarz

Simulate throttling of the OpenAI API

Summary

This sample contains a preset and mocks to simulate the throttling of the OpenAI API.

As more and more applications use OpenAI API to use AI, it’s important that developers can verify that their apps can properly handle cases when the API is throttled. Especially when the app is using lower-tier API plans, throttling is more likely to happen so validating the app’s behavior is crucial to ensure great user experience.

Using this preset you can simulate throttling of the OpenAI API and see how your app will handle it.

Dev Proxy simulating throttling of the OpenAI API when exceeded the number of tokens per minute

Compatibility

Dev Proxy v2.1.0

Contributors

Version history

VersionDateComments
1.10February 4, 2026Updated to Dev Proxy v2.1.0
1.9January 18, 2026Moved config files to .devproxy folder
1.8January 5, 2026Updated to Dev Proxy v2.0.0
1.7June 27, 2025Updated to Dev Proxy v0.29.2
1.6January 9, 2025Updated to Dev Proxy v0.23
1.5January 17, 2024Updated plugin path
1.4January 11, 2024Updated to new format
1.3January 7, 2024Added new throttling error
1.2December 22, 2023Updated to new format
1.1November 14, 2023Renamed to Dev Proxy
1.0August 10, 2023Initial release

Minimal path to awesome

  • Get the sample:
    • Download just this sample:

      npx gitload-cli https://github.com/pnp/proxy-samples/tree/main/samples/openai-throttling

      or

    • Download as a .ZIP file and unzip it, or

    • Clone this repository

  • Start Dev Proxy by running devproxy

Features

This preset includes configuration for simulating 3 different throttling scenarios:

  • exceeded tokens per minute Dev Proxy simulating throttling of the OpenAI API when exceeded the number of tokens per minute
  • exceeded number of requests per minute Dev Proxy simulating throttling of the OpenAI API when exceeded the number of requests per minute
  • service overload, which includes dynamic simulation of handling retry-after Dev Proxy simulating throttling of the OpenAI API when the server is overloaded

Proxy will simulate throttling the API using one of these modes at random.

Help

We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.

You can try looking at issues related to this sample to see if anybody else is having the same issues.

If you encounter any issues using this sample, create a new issue.

Finally, if you have an idea for improvement, make a suggestion.

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.