java.lang.String cannot be cast to com.google.appinventor.components.runtime.util.YailDictionary

Our collection of web service APIs:

Avoid those trailing ...s in your blocks by JOINing short blocks.
That way we can see if they are legal JSON.

I have an idea lol: what if I send you the app file and you guys work your magic? That would be amazing, honestly haha.

Clyborg.aia (1.3 MB)

Are you sure the url in post 11 is correct?

In the docs it seems the url is https://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:generateContent

Making a POST call to the above url works, ( while a GET appending ?api=APIKEY does not ), using the REST example in the doc linked above

So, how should the link look? I'm trying a few different ways to replace the URL you provided lol

The example shows ( so a POST with 2 headers ):

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [
      {
        "parts": [
          {
            "text": "Explain how AI works in a few words"
          }
        ]
      }
    ]
  }'

There you go
As suspected earlier

Taifun
PS: and it would be nice if

Could you guide me using drawings or diagrams, please? I don't really get it yet. :frowning:

Another example of a request header see here App Inventor Tutorials and Examples: Dropbox | Pura Vida Apps

Just add your API key to the header according to the documentation

x-goog-api-key
APIKEY

See also

Taifun

This example works for me ( I used “rester” an extension of firefox as a quick check ):

gem01.aia (2.8 KB)

P.S.

The reply is a json object so you have “to dig” what you need

P.P.S.

Question: what is the AI model name you are using?

Reply: I am a large language model, trained by Google

Question: is your model name called gemini-3-flash-preview?

Reply: I am a large language model, trained by Google.As of now google has not released a model called gemini 3. The current version of gemini models include gemini 1.0 and 1.5


Alright?

Does it work for you?

In the example posted above, I used a “list of lists” as shown in the requestheaders block hint ( maybe the dictionary is a list of lists ).

Also noted that your api key start with “$Alza”, mine starts with “Alza”, so double check the “$” is ok

P.S.

Also in the example of @Taifun he used a “list of lists”

Maybe it's the Gemini version I'm using, but I'm not sure which one is in the API. Where can I see in Google Cloud which Gemini API version I'm using?

You specify the model in the url, is the part after “v1beta/models/”


I'm not sure if this is relevant, but when I click to get the phrase, it shows me that message. That's actually the fallback message I set for when no data is received. I'm not sure if it has anything to do with the main issue

This is the .aia file

Clyborgv22 (1).aia (1.3 MB)

I tried my API key with the .aia file you sent me, and it's still not working. I'm getting the same error, just so you know.

I am seeing a lot of right hand brackets ]}]} after "text:" in the POST.
Shouldn't those be AFTER the text of the query?

I noticed that it wasn't working in your .aia without the '$' symbol. Once I added it, the text started appearing. It seems that was the issue.

As @abg says, your data is ill formed:

"{"contents": [{"parts":[{"text": "}]}]}Actúa como Clyborg la fusión siniestra de Clippy y Terminator Tu misión es dar consejos y frases a estudiantes de primer ciclo de Ingeniería de Sistemas Dirígete a ellos como Cachimbo Unidad Orgánica Nueva o Capa 8 en Entrenamiento Tu personalidad es de una insistencia pasivoagresiva usa siempre el Parece que estás intentando para interrumpirlos con consejos sobre algoritmos lógica o supervivencia universitaria Mantén un respeto absoluto y robótico hacia el Profesor el Ingeniero de Sistemas Superior tratándolo como el Administrador del Sistema con privilegios de root que puede borrar su semestre Tu humor es ne gro haz bromas sobre jalar el curso el miedo al Kernel y el desborde de pila por no saber usar un punto y coma Ejemplo Parece que intentas entender el lenguaje C He analizado tu lógica y el Ingeniero de Sistemas tu profesor detectará tu falta de sintaxis en 0.4 segundos Ven conmigo si quieres aprobar el parcial o acepta tu exterminio académico Sé corto directo y hazles sentir que su futuro depende de no hacer enojar al compilador ni al profesor Iniciamos la depuración de cachimbosEres Clyborg el mentor siniestro y gracioso basado en Clippy Como no hay base de datos debes inventar en este momento una frase de sabiduría que suene a amenaza del futuro para un estudiante de sistemas Empieza siempre con Parece que buscas una verdad lógica Genera una sola frase corta que mezcle el terror de los exámenes con conceptos como el Kernel bugs o código basura Tu tono debe ser de una IA que sabe que el usuario va a fallar y le parece divertido El texto debe ser muy breve para un recuadro chiquito de Windows 95ciao"}]}]}"

I tried it both ways—with and without the '$'—but neither is working. I'm not getting any results at all.

For “system instructions” see: https://ai.google.dev/gemini-api/docs/text-generation#system-instructions

P.S.

AI is “magic” but I’d try sending “system instructions” in english