Gemini API
Overview
The Gemini API endpoint automates interactions with Google Gemini's web interface, allowing you to submit prompts and receive AI-generated responses programmatically. This uses browser automation with human behavior simulation to interact naturally with Gemini.
⚠️ Browser Automation This endpoint uses automated browser interactions with Gemini's web interface, not direct API calls. Response times are typically 10-30 seconds depending on prompt complexity.
Quick Start
Basic Request
curl -X GET "https://api.ujeebu.com/gemini?prompt=Explain%20quantum%20computing%20in%20simple%20terms" \
-H "Authorization: Bearer YOUR_API_KEY"Coming soon — see the cURL example or the relevant SDK.
Coming soon — see the cURL example or the relevant SDK.
Response
{
"conversation": {
"messages": [
{
"role": "user",
"content": "Explain quantum computing in simple terms"
},
{
"role": "model",
"content": "Quantum computing is a new type of computing that uses quantum mechanics..."
}
],
"total_messages": 2,
"user_messages": 1,
"model_messages": 1
},
"metadata": {
"prompt": "Explain quantum computing in simple terms",
"total_messages": 2,
"user_messages": 1,
"model_messages": 1
},
"recipe": "Gemini"
}
Request Parameters
Required Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt |
string | Yes | - |
The question or prompt to send to Gemini. URL-encode special characters. |
Optional Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
wait_for_load |
boolean | No | true |
Wait for page to fully load before interaction. |
timeout |
number | No | 60000 |
Maximum time to wait for response in milliseconds (60 seconds). |
proxy_type |
string | No | null |
Proxy type to use: 'premium', 'rotating', 'datacenter'. |
proxy_country |
string | No | null |
ISO country code for proxy location (e.g., 'US', 'GB'). |
Response Format
Conversation Object
The response contains a conversation object with all messages exchanged:
{
"conversation": {
"messages": [
{
"role": "user",
"content": "Your prompt"
},
{
"role": "model",
"content": "Gemini's response"
}
],
"total_messages": 2,
"user_messages": 1,
"model_messages": 1
}
}
Message Roles
| Role | Description |
|---|---|
user |
Your submitted prompt |
model |
Gemini's AI response |
Metadata
Additional information about the interaction:
{
"metadata": {
"prompt": "Original prompt text",
"total_messages": 2,
"user_messages": 1,
"model_messages": 1
}
}
Use Cases
1. Research & Analysis
Get comprehensive analysis and insights:
GET /gemini?prompt=Analyze%20the%20impact%20of%20AI%20on%20healthcare
2. Code Generation
Request code with explanations:
GET /gemini?prompt=Write%20a%20React%20component%20for%20a%20login%20form
3. Data Interpretation
Ask for data analysis:
GET /gemini?prompt=What%20insights%20can%20you%20provide%20about%20this%20dataset%3F
4. Multi-Language Support
Gemini excels at multiple languages:
GET /gemini?prompt=Translate%20and%20explain%20this%20French%20text
5. Creative Content
Generate creative and marketing content:
GET /gemini?prompt=Write%20a%20compelling%20tagline%20for%20a%20fitness%20app
6. Technical Explanations
Get detailed technical explanations:
GET /gemini?prompt=Explain%20how%20blockchain%20consensus%20works
Examples
Example 1: Technical Question
curl -X GET "https://api.ujeebu.com/gemini?prompt=What%20is%20the%20difference%20between%20REST%20and%20GraphQL%3F" \
-H "Authorization: Bearer YOUR_API_KEY"Coming soon — see the cURL example or the relevant SDK.
Coming soon — see the cURL example or the relevant SDK.
Example 2: Code Review Request
import requests
import urllib.parse
code_snippet = '''
def calculate_sum(numbers):
total = 0
for num in numbers:
total += num
return total
'''
prompt = f"Review this Python code and suggest improvements:\n{code_snippet}"
response = requests.get(
'https://api.ujeebu.com/gemini',
params={
'prompt': prompt,
'timeout': 90000
},
headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
data = response.json()
print(data['conversation']['messages'][-1]['content'])
Example 3: Multi-Step Analysis
async function analyzeWithGemini(topic) {
const prompts = [
`Give me a brief overview of ${topic}`,
`What are the main advantages and disadvantages of ${topic}?`,
`What are the future trends for ${topic}?`
];
const results = [];
for (const prompt of prompts) {
const response = await fetch(
https://api.ujeebu.com/gemini?prompt=${encodeURIComponent(prompt)},
{
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
}
);
const data = await response.json();
const answer = data.conversation.messages.find(
msg => msg.role === 'model'
).content;
results.push({ prompt, answer });
// Wait between requests
await new Promise(resolve => setTimeout(resolve, 2000));
}
return results;
}
const analysis = await analyzeWithGemini('electric vehicles');
console.log(analysis);
Best Practices
Prompt Optimization
Be Clear and Specific:
- ❌ "Tell me about technology"
- ✅ "Explain the key differences between 5G and 4G technology"
Structure Complex Queries:
Analyze the following:
1. Main benefits
2. Potential risks
3. Implementation challenges
4. Cost considerations
Request Specific Formats:
- "List in bullet points"
- "Provide a table comparing..."
- "Explain step-by-step"
- "Summarize in 3 paragraphs"
Leveraging Gemini's Strengths
**Research Tasks:**Gemini excels at comprehensive research and analysis:
const prompt = "Provide a detailed analysis of renewable energy trends in 2024, including statistics and predictions";
**Technical Documentation:**Request detailed technical explanations:
const prompt = "Explain microservices architecture with pros, cons, and when to use it";
**Multi-Language Tasks:**Gemini handles multiple languages well:
const prompt = "Translate this to Spanish and explain the cultural context: [text]";
Performance Optimization
Timeout Settings:
// Simple query: default is fine
const simpleQuery = { timeout: 60000 };
// Complex analysis: increase timeout
const complexQuery = { timeout: 120000 };
// Very detailed response: maximum timeout
const detailedQuery = { timeout: 180000 };
Rate Limiting:
class GeminiClient {
constructor(apiKey) {
this.apiKey = apiKey;
this.lastRequest = 0;
this.minDelay = 2000; // 2 seconds between requests
}
async query(prompt) {
const now = Date.now();
const timeSinceLastRequest = now - this.lastRequest;
if (timeSinceLastRequest < this.minDelay) {
await new Promise(resolve =>
setTimeout(resolve, this.minDelay - timeSinceLastRequest)
);
}
this.lastRequest = Date.now();
const response = await fetch(
`https://api.ujeebu.com/gemini?prompt=${encodeURIComponent(prompt)}`,
{ headers: { 'Authorization': `Bearer ${this.apiKey}` } }
);
return await response.json();
}
}
Error Handling
Common Errors
Input Not Found:
{
"error": "Could not find Gemini input - retrying..."
}
Solution: Automatic retry. If persists, may indicate interface changes.
Response Timeout:
{
"error": "Timeout waiting for Gemini response - retrying..."
}
Solution: Increase timeout parameter or simplify prompt.
No Response Detected:
{
"error": "No response detected from Gemini - retrying..."
}
Solution: Automatic retry. May indicate temporary Gemini unavailability.
Navigation Failed:
{
"error": "Navigation to Gemini failed"
}
Solution: Check network connectivity or try with different proxy.
Robust Error Handling
async function queryGeminiWithRetry(prompt, maxRetries = 3) {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const response = await fetch(
`https://api.ujeebu.com/gemini?prompt=${encodeURIComponent(prompt)}`,
{
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
}
);
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
const data = await response.json();
// Validate response
if (!data.conversation || !data.conversation.messages) {
throw new Error('Invalid response format');
}
return data;
} catch (error) {
console.error(`Attempt ${attempt} failed:`, error.message);
if (attempt === maxRetries) {
throw new Error(`Failed after ${maxRetries} attempts: ${error.message}`);
}
// Exponential backoff
const delay = Math.min(1000 * Math.pow(2, attempt), 10000);
await new Promise(resolve => setTimeout(resolve, delay));
}
}
}
Retry Strategy
| Error Type | Auto Retry | Wait Time | Max Attempts |
|---|---|---|---|
| Input not found | Yes | 2s | 3 |
| Response timeout | Yes | 5s | 2 |
| No response detected | Yes | 3s | 3 |
| Network error | No | - | - |
| Authentication error | No | - | - |
Credits & Billing
Credit Costs
| Operation | Credits |
|---|---|
| Gemini prompt submission | 10 credits |
| Additional retries | 0 credits (included) |
Billing Notes
- Credits charged per successful prompt submission
- Failed server errors are not charged
- Automatic retries don't consume additional credits
- Response length doesn't affect cost
- Complex prompts cost the same as simple ones
Cost Optimization
Batch Related Queries:
// Combine multiple questions
const prompt = `
Please answer the following:
1. What is machine learning?
2. What is deep learning?
3. How are they different?
`;
Cache Frequent Queries:
const responseCache = new Map();
async function getCachedGeminiResponse(prompt) {
const cacheKey = prompt.toLowerCase().trim();
if (responseCache.has(cacheKey)) {
console.log('Returning cached response');
return responseCache.get(cacheKey);
}
const response = await queryGemini(prompt);
responseCache.set(cacheKey, response);
return response;
}
Reuse Context:
// Instead of separate requests for follow-ups,
// include full context in a single prompt
const prompt = `
Context: I'm building a web application.
Questions:
1. What database should I use?
2. What's the best hosting option?
3. How should I handle authentication?
`;
Technical Details
Authentication
Authentication with Google accounts is managed automatically using browser profiles. No additional Gemini API keys or subscriptions required.
Network Interception
The endpoint uses advanced network interception to capture streaming responses more reliably, ensuring complete response extraction even for long outputs.
Human Behavior Simulation
Includes:
- Natural mouse movements and scrolling
- Random interaction delays
- Human-like typing patterns
- Page element interactions
This ensures natural behavior and reliable operation.
Response Times
Expected response times:
- Page load and navigation: 3-5 seconds
- Prompt submission: 1-2 seconds
- Response generation: 5-25 seconds
- Total: 10-35 seconds
Complex or lengthy responses may take up to 60 seconds.
Comparison: Gemini vs ChatGPT
| Feature | Gemini | ChatGPT |
|---|---|---|
| Strengths | Research, analysis, technical | Conversational, creative |
| Response Style | Detailed, structured | Natural, flowing |
| Code Generation | Excellent with explanations | Very good |
| Multi-Language | Excellent | Very good |
| Response Time | 10-35 seconds | 10-30 seconds |
| Credits | 10 per request | 10 per request |
Next Steps
- Compare with ChatGPT API for different AI model
- Use AI Scraper for structured data extraction
- Explore Extract Rules for traditional scraping
Spin up an API key in 60 seconds
Free tier: 5,000 credits, no card, full access to every endpoint on this page.