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
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
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
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
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!