Error : No API Found

Hi, I have built a Gemini 2.0 flash based photo editing app with gradio ui. This app is running perfectly fine on my local system, but when I am trying to run it on spaces it is giving me Error : No API Found.

I have used gemini api keys in secrects
Code :
https://huggingface.co/spaces/Saurabh502/Gemini-photo/resolve/main/app.py

Please let me know your thoughts, on how to resolve this. Thanks

1 Like

First of all, it doesn’t seem to be a problem with the code.
It seems that installing google genai causes an error in Starlette and breaks Gradio…
I’m currently looking for a workaround.

Edit:
There seems to be some other condition.

I couldn’t avoid it…

But it’s probably just a bug, so it’ll be fixed eventually…

import gradio as gr
#from google import genai
#from google.genai import types

def generate_image():
    return None

with gr.Blocks(title="Image Generation and Editing App") as app:
    generate_button = gr.Button("Generate")
    generated_output = gr.Image(label="Generated Image")
    #generated_output = gr.Textbox(label="Generated Text") # this works
    generate_button.click(fn=generate_image, inputs=None, outputs=[generated_output])

app.queue().launch(ssr_mode=False)
python-dotenv
google-genai

Is there a workaround for now. Im also getting the same issue
TypeError: argument of type ‘bool’ is not iterable

1 Like

Hmm… This space works…

google-genai==1.5.0
gradio
pydantic==2.10.6
1 Like

It works now. Thanks so much. Updating the requirements.txt file did the trick.

1 Like