I keep getting this error whenever I try to upload a file to the file store:
503 - “{\n \“error\”: {\n \“code\”: 503,\n \“message\”: \“Failed to count tokens.\”,\n \“status\”: \“UNAVAILABLE\”\n }\n}\n”
I keep getting this error whenever I try to upload a file to the file store:
503 - “{\n \“error\”: {\n \“code\”: 503,\n \“message\”: \“Failed to count tokens.\”,\n \“status\”: \“UNAVAILABLE\”\n }\n}\n”
Hi @Hiba_Ghrab
The 503 status code generally indicates a temporary server issue. Can you confirm if this error is still occurring?
Also, I was able to successfully run the doc code example here: [https://ai.google.dev/gemini-api/docs/file-search#upload]. Please let me know if the issue persists.
Yes, it’s still happening with specific PDFs
same here! It’s happening to me for around 2weeks now
I have the same error when try to upload a markdown file with 300ko size
with small .md it upload …
can t understand , i try to import alternatly from ai.file upload and then creat document but always the same 503 errors ![]()
The 503 - "Failed to count tokens" error in the Gemini API File Search tool is caused by large or complex files exceeding tokenization limits or by temporary service-side issues. The most reliable fix is to split your file into smaller chunks (under ~256 KB each) before uploading, or simplify the content to reduce token count. This is what i suggests hope so it will help.
Hello,
Welcome to Forum!!
I tried to reproduce this on my end but didn’t get the error.
Could you please share which specific model, PDF, and Are you using the free tier or a paid plan? what prompt you used? That would help me reproduce it.