How to Set Billing Limits and Restrict Model Usage for a Project via OpenAI API

I’m looking for guidance on how to manage billing limits and restrict model access for specific projects using the OpenAI API.

  1. Billing Limits: Is there a way to set a maximum billing cap or token usage limit for a project (e.g., 35,000 tokens/month) to prevent overages? If not directly through the API, are there any recommended approaches or best practices for achieving this?
  2. Restricting Model Usage: How can I allow only specific models (e.g., gpt-4o-mini, gpt-4o-mini-2024-07-18, text-embedding-3-small) and block access to all others? I’ve attempted setting rate limits for certain models, but I’m unsure how to effectively block the rest.

Any help or examples would be greatly appreciated!

Thankss

1 Like

You can set a dollar limit for a project. and limit models. In your platform.openai.com select the project you want to limit and then under settings (top right) scroll all the way down to the Project section and select Limits. You can set the project limit in $ and you can remove models from the avaiable list there as well.

1 Like

Thank you, but what I am looking for is to do exactly that but through an API so that it allows me to automate that action in various projects. I would need to somehow be able to limit the spending (either for the use of tokens or dollars) of the projects through API.

You can check the API Reference and answer for yourself that there is no admin API method for creating or modifying projects with a budget or model restriction.

Project API keys have endpoints to be allowed, but there is no admin API method for this either.

So the “guidance” is “sorry”: that an organization owner must use the web UI - or replicate its bot-checked Oauth2 and session token retrieval (where you provide your own “support”).

You cannot do that - you CAN check spending now in the API
https://platform.openai.com/docs/api-reference/usage/completions

So you COULD use that to programmatically ‘cut off’ a project.
You can also create projects throught the API (And add and delete users) but at this point you cannot set the limit of a project through the API.

3 Likes

Or just track a client usage itself with your own customer system.

1 Like