# Gemini API Error Codes

{% embed url="<https://ai.google.dev/gemini-api/docs/troubleshooting>" %}

<table><thead><tr><th width="130.06669108072919" valign="top">Error Codes</th><th width="275.199951171875" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><strong>400</strong></td><td valign="top"><strong>INVALID_ARGUMENT</strong><br>The request body is malformed.</td><td valign="top">Check the <a href="https://ai.google.dev/api">API reference</a> for request format, examples, and supported versions. Using features from a newer API version with an older endpoint can cause errors.</td></tr><tr><td valign="top"><strong>400</strong></td><td valign="top"><strong>FAILED_PRECONDITION</strong><br>Gemini API free tier is not available in your country. Please enable billing on your project in Google AI Studio.</td><td valign="top">To use the Gemini API, you will need to setup a paid plan using <a href="https://aistudio.google.com/app/apikey">Google AI Studio</a>.</td></tr><tr><td valign="top"><strong>403</strong></td><td valign="top"><strong>PERMISSION_DENIED</strong><br>Your API key doesn't have the required permissions.</td><td valign="top">Check that your API key is set and has the right access. And make sure to go through proper authentication to use tuned models.</td></tr><tr><td valign="top"><strong>404</strong></td><td valign="top"><strong>NOT_FOUND</strong><br>The requested resource wasn't found.</td><td valign="top">Check if all <a href="https://ai.google.dev/docs/troubleshooting#check-api">parameters in your request are valid</a> for your API version.</td></tr><tr><td valign="top"><strong>429</strong></td><td valign="top"><strong>RESOURCE_EXHAUSTED</strong><br>You've exceeded the rate limit.</td><td valign="top">Verify that you're within the model's <a href="https://ai.google.dev/gemini-api/docs/rate-limits">rate limit</a>. <a href="https://ai.google.dev/gemini-api/docs/rate-limits#request-rate-limit-increase">Request a quota increase</a> if needed.</td></tr><tr><td valign="top"><strong>500</strong></td><td valign="top"><strong>INTERNAL</strong><br>An unexpected error occurred on Google's side.</td><td valign="top">Reduce your input context or temporarily switch to another model (e.g. from Gemini 1.5 Pro to Gemini 1.5 Flash) and see if it works. Or wait a bit and retry your request. If the issue persists after retrying, please report it using the Send feedback button in Google AI Studio.</td></tr><tr><td valign="top"><strong>503</strong></td><td valign="top"><strong>UNAVAILABLE</strong><br>The service may be temporarily overloaded or down.</td><td valign="top">Temporarily switch to another model (e.g. from Gemini 1.5 Pro to Gemini 1.5 Flash) and see if it works. Or wait a bit and retry your request. If the issue persists after retrying, please report it using the Send feedback button in Google AI Studio.</td></tr><tr><td valign="top"><strong>504</strong></td><td valign="top"><strong>DEADLINE_EXCEEDED</strong><br>The service is unable to finish processing within the deadline.</td><td valign="top">Set a larger 'timeout' in your client request to avoid this error.</td></tr></tbody></table>
