How to Use the Gemini Deep Research API in Production —…
    Neura MarketNeura Market/DeepSeek
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityTrending
    DeepSeekBlogHow to Use the Gemini Deep Research API in Production
    Back to Blog
    How to Use the Gemini Deep Research API in Production
    googlecloudrun

    How to Use the Gemini Deep Research API in Production

    Karl Weinmeister March 4, 2026
    0 views

    How many of us have gone down the research rabbit hole? Way too many tabs, links, and notes in the...


    title: How to Use the Gemini Deep Research API in Production published: true date: 2026-03-04 16:08:05 UTC tags: googlecloudrun,deepresearch,pubsub,asynchronousprogramming canonical_url: https://medium.com/google-cloud/how-to-use-the-gemini-deep-research-api-in-production-978055873a39

    Cover image

    How many of us have gone down the research rabbit hole? Way too many tabs, links, and notes in the pursuit of knowledge? It’s all useful stuff, but time-consuming and distracting.

    Since I discovered the Gemini Deep Research Agent, I haven’t turned back. And best of all, it has a powerful and straightforward API to kick off research programmatically. Let’s explore how to use it, and the patterns for including this in a production architecture.

    Async changes everything

    A single research task can trigger dozens of search queries and take several minutes to complete. The asynchronous Interactions API provides a polling-based interface with a required background=True parameter to check on progress.

    If you’ve ever worked with a Pub/Sub pipeline or job queue, this will feel familiar.

    Meet the Interactions API

    The Interactions API is a newer, unified interface for working with Gemini models and agents. It replaces the older generateContent pattern for scenarios that need state management, tool orchestration, or background execution.

    You create an interaction, point it at the deep research agent, and tell it to run in the background:

    from google import genai
    
    client = genai.Client(api_key=GEMINI_API_KEY)
    
    # Launch the research agent in the background
    interaction = client.interactions.create(
        input="Research the history and future of Solid State Batteries.",
        agent='deep-research-pro-preview-12-2025',
        background=True
    )
    

    That call returns immediately with an interaction ID. The agent is now off doing its thing, autonomously planning search queries, reading pages, and iterating on its analysis. Your application is free to do whatever it needs to do in the meantime.

    Polling for results

    Now you need a way to check whether the agent has finished. The status field tells you everything you need to know:

    while True:
        interaction = client.interactions.get(interaction.id)
    
        if interaction.status == "completed":
            # The full research report is ready
            print(interaction.outputs[-1].text)
            break
        elif interaction.status == "failed":
            print(f"Research failed: {interaction.error}")
            break
    
        # Still working. Check again in 10 seconds.
        time.sleep(10)
    

    Taking it to production with Cloud Run

    In a notebook, a while True loop gets the job done. In production, you want something that scales, recovers from failures, and doesn’t burn compute waiting. Google Cloud offers three Cloud Run compute models that each map to a different integration pattern with the Deep Research agent.

    Cloud Run service: webhook-triggered research

    A Cloud Run service works when you want to trigger research from an HTTP request. The service accepts the request, kicks off the agent, stores the interaction ID, and returns immediately. A separate mechanism (a Cloud Scheduler cron, a Cloud Workflow, or a callback) handles checking the results later.

    from fastapi import FastAPI
    from pydantic import BaseModel
    from google import genai
    
    app = FastAPI()
    client = genai.Client()
    
    class ResearchRequest(BaseModel):
        topic: str
    
    @app.post("/research")
    async def start_research(req: ResearchRequest):
        interaction = client.interactions.create(
            input=req.topic,
            agent="deep-research-pro-preview-12-2025",
            background=True,
        )
    
        # Store the ID for later retrieval (e.g., in Firestore or Cloud SQL)
        save_interaction_id(interaction.id, req.topic)
    
        return {"interaction_id": interaction.id, "status": "started"}
    

    Cloud Run job: batch research tasks

    A Cloud Run job is a natural fit for one-shot or scheduled research. Jobs execute code and stop, which maps cleanly to “launch, poll, write, exit.” If you have a batch of research topics, you can fan them out as parallel job tasks.

    from google import genai
    from google.cloud import storage
    
    client = genai.Client()
    
    def run_research_job():
        topic = os.environ.get("RESEARCH_TOPIC", "Default research topic")
    
        interaction = client.interactions.create(
            input=topic,
            agent="deep-research-pro-preview-12-2025",
            background=True,
        )
    
        # Poll until done
        while True:
            result = client.interactions.get(interaction.id)
            if result.status == "completed":
                # Write the report to Cloud Storage and exit
                bucket = storage.Client().bucket("my-research-reports")
                bucket.blob(f"{interaction.id}.md").upload_from_string(
                    result.outputs[-1].text
                )
                return
            elif result.status == "failed":
                raise RuntimeError(f"Research failed: {result.error}")
            time.sleep(10)
    
    run_research_job()
    

    Cloud Run worker pool: continuous research dispatcher

    The most interesting option for a production pipeline is a Cloud Run worker pool. Worker pools are designed for continuous, non-HTTP, pull-based background processing. They don’t need a public endpoint, they don’t autoscale by default (you bring your own logic), and they cost up to 40% less than instance-billed services.

    If you’re building a system that continuously pulls research requests from a Pub/Sub subscription, dispatches them to the agent, and writes completed reports to storage, a worker pool is purpose-built for that pattern.

    from google import genai
    from google.cloud import pubsub_v1, storage
    
    client = genai.Client()
    subscriber = pubsub_v1.SubscriberClient()
    subscription_path = "projects/my-project/subscriptions/research-requests"
    
    def handle_message(message):
        topic = message.data.decode("utf-8")
    
        interaction = client.interactions.create(
            input=topic,
            agent="deep-research-pro-preview-12-2025",
            background=True,
        )
    
        # Poll until done, then write results
        while True:
            result = client.interactions.get(interaction.id)
            if result.status == "completed":
                bucket = storage.Client().bucket("my-research-reports")
                bucket.blob(f"{interaction.id}.md").upload_from_string(
                    result.outputs[-1].text
                )
                message.ack()
                return
            elif result.status == "failed":
                message.nack() # Retry later
                return
            time.sleep(10)
    
    # Pull messages continuously (worker pool stays alive)
    streaming_pull = subscriber.subscribe(subscription_path, callback=handle_message)
    streaming_pull.result()
    

    Grounding with your own data

    Web research is powerful, but sometimes you need the agent to work with private data or internal documents. The Deep Research agent supports a file search tool for exactly this. Think of it as RAG, but orchestrated automatically by the agent rather than wired up manually.

    interaction = client.interactions.create(
        input="Compare our 2025 fiscal year report against current public web news.",
        agent='deep-research-pro-preview-12-2025',
        background=True,
        tools=[{
            "type": "file_search",
            "file_search_store_names": [FILE_SEARCH_STORE_NAME]
        }]
    )
    

    This is where the architecture gets interesting for enterprise use cases. The agent can combine internet research with grounded analysis of your internal documents, all within a single research task.

    Stateful follow-ups

    After a research task completes, you can ask follow-up questions that reference the original research context without re-running the entire workflow:

    follow_up = client.interactions.create(
        input="Can you elaborate on the key findings?",
        model="gemini-3.1-pro-preview",
        previous_interaction_id=interaction.id
    )
    
    print(follow_up.outputs[-1].text)
    

    Getting started

    This Deep Research notebook walks you through the entire flow, from setting up the client to launching research tasks. For pricing details, check the Gemini API pricing page.

    Ready to stop Googling and start delegating? Grab the notebook and run your first deep research task. I’d love to hear what you build with it. Come find me on LinkedIn, X, or Bluesky and share what research tasks you’re automating.


    Tags

    googlecloudrundeepresearchpubsubasynchronousprogramming

    Comments

    More Blog

    View all
    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught megemma

    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught me

    I ported the whole Gemma-4 family — E2B, E4B, 12B, 31B, and the 26B-A4B MoE — to run on...

    X
    xbill
    Hey DEV, I'm Tobore. Let's actually connect.community

    Hey DEV, I'm Tobore. Let's actually connect.

    Hey DEV, I'm Tobore. Let's actually connect. I've been on here for a while now, mostly writing and...

    L
    Laurina Ayarah
    I burned through thousands of AI tokens. Then a friend did it for freeai

    I burned through thousands of AI tokens. Then a friend did it for free

    (yep, kinda clickbait, just for the funsies 😊) At the beginning of the year, I relaunched my...

    P
    Paulo Henrique
    Claude might be saturating your machineai

    Claude might be saturating your machine

    My laptop was sitting idle with the fan at full tilt. Nothing was running that I knew of. The culprit...

    S
    Sidhant Panda
    Automated GitHub Code Reviews Using Google Geminigithubactions

    Automated GitHub Code Reviews Using Google Gemini

    I Built a Thing! TL;DR — Google Gemini-based Pull Request reviews and Issue Triaging for...

    D
    Darren "Dazbo" Lester
    What is an "agentic harness," actually?ai

    What is an "agentic harness," actually?

    I've been hearing the word "harness" thrown around a lot lately. I assumed it just meant "the IDE" or...

    T
    Tilde A. Thurium

    Stay up to date

    Get the latest DeepSeek prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for DeepSeek and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions for your business.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this DeepSeek resource

    • WordPress Content Automation Machine with HUMAN-IN-THE-LOOP & DEEP RESEARCHn8n · $24.99 · Related topic
    • Comprehensive Research Report Generator with Gemini AI, Web Search, & PDF Deliveryn8n · $24.99 · Related topic
    • Automate Meeting Notes Summaries with Gemini AI & Slack Notificationsn8n · $14.99 · Related topic
    • Deep Research Assistant with Perplexity AI and Telegram Citationsn8n · $14.99 · Related topic
    Browse all workflows