OpenRouter SDK Integration
Integrate Superagent with OpenRouter SDK by simply updating your base URL
Superagent provides seamless integration with the OpenRouter SDK. Simply replace your base URL to add AI firewall protection to your existing OpenRouter applications.
Python SDK
from openai import OpenAI
client = OpenAI(
base_url="YOUR_SUPERAGENT_PROXY_URL", # Replace with your Superagent proxy
api_key="your-openrouter-api-key"
)
# Use the client as usual - no other changes needed
TypeScript/JavaScript SDK
import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: 'YOUR_SUPERAGENT_PROXY_URL', // Replace with your Superagent proxy
apiKey: 'your-openrouter-api-key',
});
// Use the client as usual - no other changes needed
cURL Example
curl "YOUR_SUPERAGENT_PROXY_URL/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-openrouter-api-key" \
-d '{
"model": "anthropic/claude-3-sonnet",
"messages": [
{
"role": "user",
"content": "Hello, world!"
}
]
}'
Migration Notes
- No Code Changes Required: Your existing OpenRouter SDK code works unchanged
- Same API Surface: All OpenRouter SDK methods and parameters remain identical
- Added Protection: Requests are now protected by Superagent's AI firewall
- Complete Compatibility: Full compatibility with all OpenRouter models and features
- Model Selection: Continue using OpenRouter's model routing (e.g.,
anthropic/claude-3-sonnet
,openai/gpt-4
)
Simply update your base_url
(Python) or baseURL
(TypeScript) to your Superagent proxy URL and you're protected!