Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Error when prompting gemini API with links directly instead of file manager API

GoogleGenerativeAIFetchError: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent: [400 Bad Request] Invalid or unsupported file uri: https://canto-wp-media.s3.amazonaws.com/app/uploads/2019/08/19194138/image-url-3.jpg

```javascript
const result = await model.generateContent({
contents: [
{ role: 'user',
parts: [
{ text: prompt },
{ text: 'input: '},
{
fileData: {
fileUri: "https://canto-wp-media.s3.amazonaws.com/app/uploads/2019/08/19194138/image-url-3.jpg"
}
}
]
}
],
generationConfig,
safetySettings,
});

```

Solved Solved
0 3 2,390
1 ACCEPTED SOLUTION

It’s what the message says: URI external to Google are not supported. The URI you get from the File API works. 

View solution in original post

3 REPLIES 3

I have the same error, how do I find the solution ? 

⨯ V [Error]: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent: [400 Bad Request]

It’s what the message says: URI external to Google are not supported. The URI you get from the File API works. 

Yes i confused it with vertex API which supports other types of uris.