Post

Setting OpenAI API Key Limits by Project

Quick steps to apply OpenAI API limits by project.

Setting OpenAI API Key Limits by Project

Set precise usage restrictions on OpenAI API keys by project to control budgets and model access:

1. Create a Project

  • Sign in at platform.openai.com
  • Navigate: Settings → Organization → Projects
  • Click Create project, assign name (e.g., MyAppProject)

2. Generate Scoped API Key

  • Open project dashboard, select API keys
  • Click Create new secret key, assign identifier (e.g., ProjectXKey)
  • Optional: Add IP allowlist for security
  • Immediately copy generated key (one-time view only)

3. Configure Budget Limits

  • Open Settings → Billing → Usage limits
  • Set Hard limit (absolute cap) and Soft limit (warning threshold)

4. Restrict Model Usage

  • Under project settings, go to Rate limits
  • Allow specific models (e.g., gpt-4o-mini) with high limits
  • Set zero limits for unwanted models, effectively disabling them

Additional Tips

  • Regularly monitor usage via OpenAI’s dashboard
  • Rotate keys periodically to maintain security
  • Check API response headers for rate limit statuses (e.g., x-ratelimit-remaining-requests)

For advanced per-key controls, consider third-party or Azure OpenAI solutions.

This post is licensed under CC BY 4.0 by the author.