Skip to content

unofficial API designed to interact with Google's Gemini

License

Notifications You must be signed in to change notification settings

OE-LUCIFER/Gemini-Chat-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌟 Gemini Python API

Gemini API Python License

GitHub stars GitHub forks GitHub watchers

Unleash the power of Google's Gemini in your Python projects! 🚀

FeaturesInstallationUsageDocumentationContributing

🌈 Features Showcase

🔐
Secure Authentication
🔄
Dynamic Sessions
💬
Multi-Conversation Support
🌐
Context Preservation
🖼️
Image Response Handling
⏱️
Customizable Timeouts
🎭
User-Agent Randomization
🔍
Conversation Tracking

🛠️ Installation & Setup

Click to expand detailed setup instructions
  1. Clone the Repository:

    git clone https://github.com/OE-LUCIFER/Gemini-Chat-API.git
    cd Gemini-Chat-API
  2. Set Up Virtual Environment (Recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install Dependencies:

    pip install -r requirements.txt
  4. Cookie Configuration:

  5. Verify Installation:

    python -c "from gemini import Gemini; print('Setup successful!')"

🚀 Quick Start Guide

from gemini import Gemini

# Initialize Gemini client
gemini = Gemini('cookie.json')

# Create a new conversation
chat = gemini.create_conversation("AI_Ethics")

# Ask a question
response = gemini.ask("What are the key ethical considerations in AI development?", chat)

print(f"Gemini says: {response['content']}")

# Handle image responses
if response['images']:
    print(f"Related images: {response['images']}")

📘 Comprehensive Documentation

Expand for API details and advanced usage

Gemini Class

class Gemini:
    def __init__(self, cookie_path: str, timeout: int = 30)

Core Methods

  • create_conversation(name: str) -> str
  • switch_conversation(name: str) -> None
  • list_conversations() -> list
  • delete_conversation(name: str) -> None
  • ask(question: str, conversation: str = None) -> dict

Advanced Usage Examples

Managing Multiple Conversations

gemini.create_conversation("Science")
gemini.create_conversation("Philosophy")

gemini.switch_conversation("Science")
science_response = gemini.ask("Explain quantum entanglement")

gemini.switch_conversation("Philosophy")
philosophy_response = gemini.ask("Discuss the trolley problem")

Handling Image Responses

response = gemini.ask("Show me a diagram of a black hole")
if response['images']:
    for img_url in response['images']:
        # Process or display the image
        print(f"Image URL: {img_url}")

🛡️ Error Handling & Reliability

Our robust error handling system ensures smooth operation:

  • 🔒 Authentication Issues
  • 🌐 Network Connectivity Problems
  • ⏱️ Timeout Management
  • 🧩 Response Parsing Errors

Implement try-except blocks for graceful error management in your applications.

🔧 Configuration & Customization

Tailor the Gemini API to your needs:

  • ⚙️ Adjust timeout settings
  • 🔀 Implement custom conversation management
  • 🎨 Extend functionality with additional methods

📊 Performance Optimization

Tips for optimal performance:

  • 🚀 Use async operations for concurrent requests
  • 💾 Implement caching for frequent queries
  • 🔍 Optimize conversation context management

🤝 Contribution Guidelines

We welcome contributions! Here's how you can help:

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch (git checkout -b feature/AmazingFeature)
  3. 🖊️ Commit your changes (git commit -m 'Add some AmazingFeature')
  4. 🚀 Push to the branch (git push origin feature/AmazingFeature)
  5. 🎉 Open a Pull Request

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.

💖 Support & Community

GitHub issues GitHub pull requests

Report a BugRequest a FeatureTelegram


Follow on GitHub

Crafted with ❤️ by OE-LUCIFER

If you find this project helpful, consider supporting our work:

Buy Me A Coffee

🌟 Star History

Star History Chart

About

unofficial API designed to interact with Google's Gemini

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published