Superagent LogoSuperagent

Google Gemini SDK Integration

Integrate Superagent with Google Gemini SDK by simply updating your base URL

Superagent provides seamless integration with the Google Gemini SDK. Simply replace your base URL to add AI firewall protection to your existing Gemini applications.

Python SDK

Python SDK Setup
from google import genai

client = genai.Client(
    api_key="your-gemini-api-key",
    http_options={'base_url': 'YOUR_SUPERAGENT_PROXY_URL'}  # Replace with your Superagent proxy
)

# Use the client as usual - no other changes needed

TypeScript/JavaScript SDK

TypeScript/JavaScript SDK Setup
import { GoogleGenAI } from '@google/genai';

const genai = new GoogleGenAI({
  apiKey: 'your-gemini-api-key',
  baseUrl: 'YOUR_SUPERAGENT_PROXY_URL', // Replace with your Superagent proxy
});

// Use the client as usual - no other changes needed

Alternative: OpenAI SDK Compatible

Python with OpenAI SDK
from openai import OpenAI

client = OpenAI(
    base_url="YOUR_SUPERAGENT_PROXY_URL",  # Replace with your Superagent proxy
    api_key="your-gemini-api-key"
)

# Many Gemini endpoints are OpenAI compatible
TypeScript with OpenAI SDK
import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: 'YOUR_SUPERAGENT_PROXY_URL', // Replace with your Superagent proxy
  apiKey: 'your-gemini-api-key',
});

// Many Gemini endpoints are OpenAI compatible

Migration Notes

  • No Code Changes Required: Your existing Gemini SDK code works unchanged
  • Same API Surface: All Gemini SDK methods and parameters remain identical
  • Added Protection: Requests are now protected by Superagent's AI firewall
  • Complete Compatibility: Full compatibility with all Gemini models and features
  • OpenAI Compatibility: Many Gemini endpoints support OpenAI-compatible format

Simply update your base URL configuration to your Superagent proxy URL and you're protected!