{"id":6662,"library":"h2ogpte","title":"H2O GPTe Python Client","description":"h2ogpte is the Python client library for H2O.ai's Enterprise h2oGPTe, a Retrieval-Augmented Generation (RAG) based platform designed to help organizations leverage generative AI. It focuses on contextualizing chat with private data, offering scalable backend and frontend, multi-user support, and multi-modal capabilities for text, images, and audio. The current version is 1.7.0, and major releases appear to occur every few months, introducing new features and improvements.","status":"active","version":"1.7.0","language":"en","source_language":"en","source_url":"https://github.com/h2oai/h2ogpte","tags":["AI","LLM","RAG","Generative AI","H2O.ai","Client Library","Enterprise AI"],"install":[{"cmd":"pip install h2ogpte","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"H2OGPTE","correct":"from h2ogpte import H2OGPTE"}],"quickstart":{"code":"import os\nfrom h2ogpte import H2OGPTE\n\n# Replace with your h2oGPTe instance address and API key\n# It's recommended to use environment variables for sensitive information\nH2OGPTE_ADDRESS = os.environ.get('H2OGPTE_ADDRESS', 'https://your-h2ogpte-instance.h2o.ai')\nH2OGPTE_API_KEY = os.environ.get('H2OGPTE_API_KEY', 'sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')\n\nclient = H2OGPTE(address=H2OGPTE_ADDRESS, api_key=H2OGPTE_API_KEY)\n\ntry:\n    # Create a new collection\n    collection_id = client.create_collection(\n        name='My Contracts',\n        description='Paper clip supply contracts and related documents',\n    )\n    print(f\"Collection created with ID: {collection_id}\")\n\n    # Example: Upload a dummy document (in a real scenario, this would be a file)\n    dummy_content = \"There were 55 paper clips shipped, 22 to Scranton and 33 to Filmer.\"\n    with open('paper_clips_report.txt', 'w') as f:\n        f.write(dummy_content)\n\n    client.sync_folder(collection_id=collection_id, folder_path='.')\n    print(\"Dummy document uploaded and synchronized.\")\n\n    # Create a chat session with the collection\n    chat_session_id = client.create_chat_session(collection_id=collection_id)\n    print(f\"Chat session created with ID: {chat_session_id}\")\n\n    # Query the collection\n    with client.connect(chat_session_id) as session:\n        response = session.query(\n            'How many paper clips were shipped to Scranton?',\n            timeout=60,\n        )\n        print(f\"Response: {response.content}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    # Clean up (optional) - delete the dummy file and collection\n    if 'paper_clips_report.txt' in os.listdir('.'):\n        os.remove('paper_clips_report.txt')\n    # In a real application, you might also delete the collection and chat session\n    # client.delete_collection(collection_id=collection_id)\n    # client.delete_chat_session(chat_session_id=chat_session_id)","lang":"python","description":"This quickstart demonstrates how to connect to an h2oGPTe instance, create a collection, upload a document, create a chat session, and query the collection using the Python client. Ensure you have your h2oGPTe instance address and a valid API key set as environment variables or replaced in the code."},"warnings":[{"fix":"Always consult the documentation for other H2O.ai tools and integrations to ensure you are using a compatible version of the `h2ogpte` client library.","message":"Specific versions of other h2oGPTe ecosystem components (e.g., h2oGPTe GitHub Action) may have strict compatibility requirements with particular client library versions. For instance, h2oGPTe Action v0.2.2-beta requires h2oGPTe versions 1.6.31 through 1.6.47.","severity":"breaking","affected_versions":"<1.6.31 and >1.6.47 for h2oGPTe Action v0.2.2-beta (example)"},{"fix":"Always use the principle of least privilege. Generate and use collection-specific API keys for integrations that only need access to a particular collection. Only use global API keys for applications requiring full administrative access.","message":"There are two types of API keys: Global API keys and Collection-specific API keys. Global API keys grant full user impersonation and system-wide access, allowing creation, deletion, and interaction with all collections, documents, and chats. Collection-specific keys are restricted to chatting with the specified collection only. Misusing a global API key when only collection-level access is intended can pose a significant security risk.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Double-check the `H2OGPTE_ADDRESS` and `H2OGPTE_API_KEY` values. Ensure your environment has network access to the h2oGPTe instance and no firewalls are blocking the connection. Consult h2oGPTe server documentation for deployment-specific troubleshooting.","message":"The `H2OGPTE` client requires a valid `address` (URL of your h2oGPTe instance) and `api_key` for connection. Incorrect values, network issues, or firewall restrictions preventing access to the h2oGPTe server are common sources of connection errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Understand the capabilities and configurations of the LLMs deployed on your h2oGPTe instance. Consult the h2oGPTe server documentation or an administrator regarding LLM-specific parameter control and any hardcoded defaults.","message":"When interacting with underlying Large Language Models (LLMs) through h2oGPTe, some LLM-specific parameters (e.g., `system_prompt`, `temperature`, `max_tokens`) might not behave as expected or might have fixed defaults if the underlying LLM backend (like oLLaMa in h2oGPT OSS) does not support runtime parameter changes. This can lead to unexpected model responses if the user assumes full control over all LLM hyperparameters via the client.","severity":"gotcha","affected_versions":"All versions, depending on the h2oGPTe server's LLM configuration"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}