Facing error while using a Video as an input to gemini android sdk

Getting error:

com.google.ai.client.generativeai.type.ServerException: An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting
                                                                                                    	at com.google.ai.client.generativeai.type.GoogleGenerativeAIException$Companion.from(Exceptions.kt:43)
                                                                                                    	at com.google.ai.client.generativeai.GenerativeModel.generateContent(GenerativeModel.kt:115)
                                                                                                    	at com.google.ai.client.generativeai.GenerativeModel$generateContent$1.invokeSuspend(Unknown Source:15)
                                                                                                    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                    	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
                                                                                                    	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
                                                                                                    	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
                                                                                                    	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@3e71807, Dispatchers.IO]

Here is my configuration:

    private val config by lazy {
        generationConfig {
            temperature = 0.7f
        }
    }
    private val generativeModel by lazy {
        GenerativeModel(
            modelName = "gemini-1.5-pro-latest",
            apiKey = "",
            generationConfig = config
        )
    }

val input = content {
            blob(
                mimeType,
                file.readBytes())
            text(message)
        }
        val resp =generativeModel.generateContent(input)

mimeType is video/mp4
video link: drive

I have the same issue
image

Welcome to the forums!

For videos, you need to use the File API to upload the video first for processing before you can generate content based on that video.

1 Like

Allen is spot on. It would be helpful if someone in Google would address this issue (also reported here Video content supplied *inline* causes server fault)