"The document has no pages." Vercel AI SDK ^5.0.101,
Unanswered
Shayokh posted this in #help-forum
ShayokhOP
Hello. I have trying to upload a pdf file to Gemini-2.5-flash from my server action. I am repeadedly getting the "The document has no pages." error. The pdf has 1 page. I can't seem to find anything related to this issue in the docs. Please help.
Getting this -
"use server";
import { google } from "@ai-sdk/google";
import { generateObject } from "ai";
import z from "zod";
export async function scanPdfUsingAI({
base64String,
}: {
base64String: string;
}) {
// Convert the base64 string to a file buffer
const fileBuffer = Buffer.from(base64String, "base64");
console.log("File buffer", fileBuffer);
const { object } = await generateObject({
model: google("gemini-2.5-flash"),
schema: z.object({
response: z.string(),
score: z.number(),
}),
system: prepareSystemPrompt(),
messages: [
{
role: "user",
content: [
{
type: "text",
text: "Review the CV.",
},
{
type: "file",
data: fileBuffer,
mediaType: "application/pdf",
},
],
},
],
});
return object;
}
function prepareSystemPrompt() {
...
}Getting this -
⨯ Error [AI_APICallError]: The document has no pages.
at async scanPdfUsingAI (app/actions/scan-pdf-using-ai.ts:15:22)
13 | console.log("File buffer", fileBuffer);
14 |
> 15 | const { object } = await generateObject({
| ^
16 | model: google("gemini-2.5-flash"),
17 |
18 | schema: z.object({ {
cause: undefined,
url: 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent',
requestBodyValues: [Object],
statusCode: 400,
responseHeaders: [Object],
responseBody: '{\n' +
' "error": {\n' +
' "code": 400,\n' +
' "message": "The document has no pages.",\n' +
' "status": "INVALID_ARGUMENT"\n' +
' }\n' +
'}\n',
isRetryable: false,
data: [Object],
d