Skip to main content
Version: v1.6.1 🚧

Python Client Library

Overview

Users can interact with the h2oGPTe API through its Python Client Library. This library simplifies making API requests and handling responses, allowing you to focus on integrating the API's functionality into your Python applications.

Software requirements

Before you begin, ensure you meet the following requirements:

  • Operating system: Linux, macOS, Windows
  • Python: 3.7, 3.8, 3.9, 3.10, 3.11 or 3.12

Getting started

Installation

You can install the library using pip:

pip install h2ogpte==1.6.0
note

It is recommended that you install the Python Client Library version that matches the Enterprise h2oGPT software (UI) version where you created your API key.

API key setup

Obtaining an API key

Sign up at Enterprise h2oGPTe and create one of the two types of keys:

  1. On Enterprise h2oGPTe, click Account Circle.
  2. Select Using the API.
  3. Click + New API Key.
  4. (Optional) In the Key name box, enter a name for the API key.
  5. (Optional) In the Restrict to collection list, select a Collection.
    note

    Specifying a Collection enables you to create a Collection-specific API key by indicating the Collection you want to link it with. For more information, see Types of API keys.

  6. Click Generate new key.
    caution

    Do not share your API key with others or expose it within the browser or other client-side code.

Setting the API key

You can set your API key in your code as follows:

from h2ogpte import H2OGPTE

# Instantiate an h2oGPTe client by providing:
# - address (address): Specifies the URL where Enterprise h2oGPTe is hosted. The address should be where the API key was created.
# - global/collection-specific API key (api_key)
client = H2OGPTE(
address="https://h2ogpte.genai.h2o.ai",
api_key='sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
)

Feedback