- PHP 7.4+ with cURL extension
- File upload enabled
- Writable directories: temp_files, logs, output
/
├── gemini-api.php # Main API endpoint
├── simple-client.php # PowerShell client
├── get-client.php # Client proxy
├── status.php # Health check
├── index.php # Entry point
├── client/
│ └── gemini-bridge.ps1 # Full PowerShell client
├── temp_files/ # Upload directory
├── logs/ # Log directory
└── .htaccess # Security rules
Edit gemini-api.php:
define('GOOGLE_API_KEY', 'your-api-key-here');chmod 755 temp_files logs output
chmod 644 *.phpcurl -X POST https://yourdomain.com/gemini-api.php -d "test=true"# Protect sensitive files
<Files "*.log">
Require all denied
</Files>
# Enable PowerShell script headers
<Files "*.ps1">
Header set Content-Type "text/plain"
</Files>- Set appropriate upload limits
- Enable error logging
- Disable dangerous functions if needed
<Files "*.log"> Require all denied
<Files "*.ps1"> Header set Content-Type "text/plain; charset=utf-8" Header set Content-Disposition "inline"
## 🚀 Remote Usage Patterns
### 1. One-Time Setup
```powershell
# Download and run setup script
irm https://yourdomain.com/setup.ps1 | iex -ApiKey "YOUR_API_KEY"
# Test connection
irm https://yourdomain.com/client/gemini-client.ps1 | iex -ApiUrl "https://yourdomain.com/api.php" -Test
# Process text directly
irm https://yourdomain.com/client/gemini-client.ps1 | iex -ApiUrl "https://yourdomain.com/api.php" -InputText "Generate a simple HTML page"
# Process a local file
irm https://yourdomain.com/client/gemini-client.ps1 | iex -ApiUrl "https://yourdomain.com/api.php" -InputFile "myfile.txt"Use a URL shortener for easier execution:
# Instead of the long URL, use:
irm bit.ly/gemini-setup | iex -ApiKey "YOUR_KEY"
irm bit.ly/gemini-client | iex -ApiUrl "https://yourdomain.com/api.php" -TestCreate a browser bookmark with this JavaScript:
javascript:(function(){
var text = window.getSelection().toString() || prompt('Enter text to process:');
if(text) {
var ps1 = 'irm https://yourdomain.com/client/gemini-client.ps1 | iex -ApiUrl "https://yourdomain.com/api.php" -InputText "' + text.replace(/"/g, '\\"') + '"';
navigator.clipboard.writeText(ps1).then(function() {
alert('PowerShell command copied to clipboard!');
});
}
})();irm https://yourdomain.com/client/gemini-client.ps1 | iex -ApiUrl "https://yourdomain.com/api.php" -InputText "Hello"pwsh -c "irm https://yourdomain.com/client/gemini-client.ps1 | iex -ApiUrl 'https://yourdomain.com/api.php' -InputText 'Hello'"# Direct API call
curl -X POST https://yourdomain.com/api.php \
-F "textFile=@myfile.txt"
# With text content
curl -X POST https://yourdomain.com/api.php \
-H "Content-Type: text/plain" \
-d "Generate a simple HTML page"import requests
# Test connection
response = requests.post('https://yourdomain.com/api.php', data={'test': 'true'})
print(response.json())
# Send text
response = requests.post('https://yourdomain.com/api.php', data='Your text here')
print(response.json())- HTTPS Only: Always use SSL/TLS encryption
- API Key Protection: Never expose your API key in client-side code
- Rate Limiting: Implement server-side rate limiting
- Input Validation: Validate all uploads and inputs
- File Cleanup: Regularly clean temporary files
- Access Logs: Monitor for abuse
Header always set X-Content-Type-Options nosniff
Header always set X-Frame-Options DENY
Header always set X-XSS-Protection "1; mode=block"
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"Add to your api.php:
// Log usage (add to existing logging)
$usage_log = [
'timestamp' => date('c'),
'ip' => $_SERVER['REMOTE_ADDR'] ?? 'unknown',
'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? 'unknown',
'input_length' => strlen($inputText)
];
file_put_contents('logs/usage.json', json_encode($usage_log) . "\n", FILE_APPEND | LOCK_EX);name: Process with Gemini AI
on: [push]
jobs:
process:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Process files
shell: pwsh
run: |
irm https://yourdomain.com/client/gemini-client.ps1 | iex -ApiUrl "https://yourdomain.com/api.php" -InputFile "README.md"// WordPress shortcode
function gemini_ai_shortcode($atts) {
$atts = shortcode_atts(['text' => ''], $atts);
if (empty($atts['text'])) return '';
$response = wp_remote_post('https://yourdomain.com/api.php', [
'body' => $atts['text']
]);
if (is_wp_error($response)) return 'Error processing request';
$body = wp_remote_retrieve_body($response);
$data = json_decode($body, true);
return $data['candidates'][0]['content']['parts'][0]['text'] ?? 'No response';
}
add_shortcode('gemini_ai', 'gemini_ai_shortcode');// Add to api.php for response caching
$cache_key = md5($inputText);
$cache_file = "cache/{$cache_key}.json";
if (file_exists($cache_file) && (time() - filemtime($cache_file)) < 3600) {
// Return cached response
echo file_get_contents($cache_file);
exit;
}
// After API call, cache the response
file_put_contents($cache_file, $response);- Host static files (PS1 scripts, setup) on a CDN
- Use CDN URLs in your documentation
- Implement proper cache headers
- PowerShell Execution Policy:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - CORS Issues: Add appropriate CORS headers to API responses
- File Upload Limits: Check PHP upload limits and server configuration
- SSL Certificate Issues: Ensure valid SSL certificates
Add ?debug=1 to API calls for verbose output during testing.
This deployment guide enables flexible, remote usage of your Gemini AI Integration while maintaining security and performance.