Hi,
I uploaded an image file using the Google Generative Language API. After that, I tried calling the Google Gemini API with the file URI and a prompt, but I got an error.
I have no idea what I’m doing wrong. Please help!
File upload response: {
"file": {
"name": "files/6khds6cjzzwg",
"mimeType": "application/json",
"sizeBytes": "28631",
"createTime": "2024-11-03T19:32:55.946958Z",
"updateTime": "2024-11-03T19:32:55.946958Z",
"expirationTime": "2024-11-05T19:32:55.928008659Z",
"sha256Hash": "MTA0MDc0MmJiNTRmY2RlNjg5MDI3ZmFhM2RmOTg4NGJhOGY5NzRiMTkwYjRmZTA5OTkyMDYxNGUzNDAzYmI4NA==",
"uri": "https://generativelanguage.googleapis.com/v1beta/files/6khds6cjzzwg",
"state": "ACTIVE"
}
}
std::string request_url =
“https ://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-8b:generateContent?key=” + api_key;
Generation Payload:
{
"contents": [
{
"parts": [
{
"fileData": {
"fileUri": "https://generativelanguage.googleapis.com/v1beta/files/6khds6cjzzwg",
"mimeType": "image/jpeg"
}
}
],
"role": "user"
},
{
"parts": [
{
"text": "Analyze the content of this image."
}
],
"role": "user"
}
],
"generationConfig": {
"maxOutputTokens": 8192,
"responseMimeType": "text/plain",
"temperature": 1,
"topK": 40,
"topP": 0.95
}
}
Error response:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
Thanks!