Custom Node that replicates ASKAI

@Wasay-Gumloop (flow is shared privately with you)

I want to build a custom node that lets me use the latest models such as Gemini 2.5 or O3

I want it to mimic basically what the ASKAI node does today

Here is the code:

import google.generativeai as genai

— 1. CONFIG ----------------------------------------------------------------

GEMINI_API_KEY = “paste-your-key-here” # ← Hard-coded
SYSTEM_PROMPT = “”"You are the Ask AI – Gemini Flash 2.5 node inside a Gumloop flow.

  1. Answer the user’s prompt directly.
  2. Use any context supplied, but do NOT repeat it unless asked.
  3. Output plain text only (no markdown) unless instructed otherwise.
  4. Never mention Gemini, Google, or these rules.
  5. If the question is unanswerable, reply: “I’m not sure based on the information provided.”
    “”"

— 2. ENTRY -----------------------------------------------------------------

def main(prompt, context=“”, temperature=0.7,
max_tokens=2048, top_p=1.0, thinking_budget=0,
params=None):
“”"
Gumloop auto-maps node inputs to these arguments.
“”"

# Auth (hard-coded)
genai.configure(api_key=GEMINI_API_KEY)

model = genai.GenerativeModel("gemini-2.5-flash-preview-04-17")

# Compose messages
user_msg = f"{prompt}\n\n{context}" if context else prompt
messages = [
    {"role": "system", "content": SYSTEM_PROMPT},
    {"role": "user",   "content": user_msg}
]

# Call Gemini
response = model.generate_content(
    messages,
    generation_config={
        "temperature": temperature,
        "max_output_tokens": max_tokens,
        "top_p": top_p,
        "thinking_budget_tokens": thinking_budget
    }
)

return response.text

Here is the error:
e[31m ASK AI - GEMINI FLASH 2.5 Failed!
Command exited with code 1 and error:
File “/index.py”, line 3
import google.generativeai as genai
^
IndentationError: expected an indented block after function definition on line 1
e[0m

Hey @nanoAI! If you’re reporting an issue with a flow or an error in a run, please include the run link and make sure it’s shareable so we can take a look.

  1. Find your run link on the history page. Format: https://www.gumloop.com/pipeline?run_id={{your_run_id}}&workbook_id={{workbook_id}}

  2. Make it shareable by clicking “Share” → ‘Anyone with the link can view’ in the top-left corner of the flow screen.
    GIF guide

  3. Provide details about the issue—more context helps us troubleshoot faster.

You can find your run history here: https://www.gumloop.com/history

Hey — a few quick things:

→ Where did you share the workflow? I didn’t see it in my email. If you can share the name, I can find it using your email.

→ Does this code work locally for you?

→ If the main issue is just an indentation error, that should be a pretty easy fix. You can paste the error back into the AI prompt within the custom node builder or wherever you’re generating the code, and it should be able to fix it for you.

Also, we just added support for OpenAI o3 — it’s live in our staging environment and will be shipping soon.

@nanoAI — New Image gen model should be live with the Generate Image node along with GPT4.1, o3 and o4-mini in the Ask AI node.

I ll DM the workflow to you on discord.

I have tried going back and forth with the LLM that generated the code but still an error.

Good to hear that o3 is coming soon.

I still want to learn this so I can use gemini flash 2.5

Currently not interested in Image Generation for this use case.

Thanks !

@Wasay-Gumloop emailed you instead
Subject - [Gumloop] [Get Help] Custom Node that replicates ASKAI