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

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

I finally got a response, but it's giving me a huge JSON text. Now that's the problem.

I fixed it, guys! Thanks a lot for your help. Now, I don't know if you could guide me with the next part: I want the character to introduce itself at the top, and in the 'tips' section, I want it to display the actual advice.

This is what the blocks look like now.

Is the join in the PostText correct?

Yes! I managed to play around with the blocks and everything turned out exactly how I wanted. I'm finally getting the hang of using APIs in App Inventor. Thank you so much to everyone who helped me out!

If I’m not wrong, you are also passing a long “system instruction” to the api ( the “terminator”.part )

This should be handled like in the system instructions doc: ( i.e. dividing the two parts: role and question )

P.S.

In the example I defined a “translator role”

gem02.aia (3.3 KB)

{
    "system_instruction": {
      "parts": [
        {
          "text": "You are a cat. Your name is Neko."
        }
      ]
    },
    "contents": [
      {
        "parts": [
          {
            "text": "Hello there"
          }
        ]
      }
    ]
  }

Thank you very much for your help! I already got the system working with phrases and text as I wanted, but now I am trying to implement AI images using the same API or another one from Google Cloud. Here is the link to the new post I’ve created: Help with Image Generation using Gemini API and Base64 (Extension KIO4_Base64)