Develop a Multi-Tool AI Agent with Secure Python Execution using Riza and Gemini

In this tutorial, we’ll harness Riza’s secure Python execution as the cornerstone of a powerful, tool-augmented AI agent in Google Colab. Beginning with seamless API key management, through Colab secrets, environment variables, or hidden prompts, we’ll configure your Riza credentials to enable sandboxed, audit-ready code execution. We’ll integrate Riza’s ExecPython tool into a LangChain agent […] The post Develop a Multi-Tool AI Agent with Secure Python Execution using Riza and Gemini appeared first on MarkTechPost.

Jun 11, 2025 - 23:00
 0
Develop a Multi-Tool AI Agent with Secure Python Execution using Riza and Gemini

In this tutorial, we’ll harness Riza’s secure Python execution as the cornerstone of a powerful, tool-augmented AI agent in Google Colab. Beginning with seamless API key management, through Colab secrets, environment variables, or hidden prompts, we’ll configure your Riza credentials to enable sandboxed, audit-ready code execution. We’ll integrate Riza’s ExecPython tool into a LangChain agent alongside Google’s Gemini generative model, define an AdvancedCallbackHandler that captures both tool invocations and Riza execution logs, and build custom utilities for complex math and in-depth text analysis.

%pip install --upgrade --quiet langchain-community langchain-google-genai rizaio python-dotenv


import os
from typing import Dict, Any, List
from datetime import datetime
import json
import getpass
from google.colab import userdata

We will install and upgrade the core libraries, LangChain Community extensions, Google Gemini integration, Riza’s secure execution package, and dotenv support, quietly in Colab. We then import standard utilities (e.g., os, datetime, json), typing annotations, secure input via getpass, and Colab’s user data API to manage environment variables and user secrets seamlessly.

def setup_api_keys():
    """Set up API keys using multiple secure methods."""
   
    try:
        os.environ['GOOGLE_API_KEY'] = userdata.get('GOOGLE_API_KEY')
        os.environ['RIZA_API_KEY'] = userdata.get('RIZA_API_KEY')
        print("✅ API keys loaded from Colab secrets")
        return True
    except:
        pass
   
    if os.getenv('GOOGLE_API_KEY') and os.getenv('RIZA_API_KEY'):
        print("✅ API keys found in environment")
        return True
   
    try:
        if not os.getenv('GOOGLE_API_KEY'):
            google_key = getpass.getpass("                        </div>
                                            <div class=
                            
                                Read More