Gemini API Error Codes
400
INVALID_ARGUMENT The request body is malformed.
Check the API reference for request format, examples, and supported versions. Using features from a newer API version with an older endpoint can cause errors.
400
FAILED_PRECONDITION Gemini API free tier is not available in your country. Please enable billing on your project in Google AI Studio.
To use the Gemini API, you will need to setup a paid plan using Google AI Studio.
403
PERMISSION_DENIED Your API key doesn't have the required permissions.
Check that your API key is set and has the right access. And make sure to go through proper authentication to use tuned models.
404
NOT_FOUND The requested resource wasn't found.
Check if all parameters in your request are valid for your API version.
429
RESOURCE_EXHAUSTED You've exceeded the rate limit.
Verify that you're within the model's rate limit. Request a quota increase if needed.
500
INTERNAL An unexpected error occurred on Google's side.
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.
503
UNAVAILABLE The service may be temporarily overloaded or down.
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.
504
DEADLINE_EXCEEDED The service is unable to finish processing within the deadline.
Set a larger 'timeout' in your client request to avoid this error.