Skip to main content

The Python client for H2OGPTe REST API

Project description

H2OGPTe REST Client

This package represents a generated Python client for H2OGPTe REST API. The client was generated with the openapi-generator-cli tool and modified with custom changes for streamed chat completions.

Installation & Usage

If the python package is hosted on a repository, you can install directly using:

pip install h2ogte_rest_client

Then import the package:

import h2ogpte_rest_client

Authorization: Getting an API key

Sign up/in at Enterprise h2oGPTe and generate one of the following two types of API keys:

  • Global API key: If a Collection is not specified when creating a new API Key, that key is considered to be a global API Key. Use global API Keys to grant full user impersonation and system-wide access to all of your work. Anyone with access to one of your global API Keys can create, delete, or interact with any of your past, current, and future Collections, Documents, Chats, and settings.

  • Collection-specific API key: Use Collection-specific API Keys to grant external access to only Chat with a specified Collection and make related API calls to it. Collection-specific API keys do not allow other API calls, such as creation, deletion, or access to other Collections or Chats.

Access Enterprise h2oGPTe through your H2O Generative AI app store account, available with a freemium tier.

Authorization: Using an API key

All h2oGPTe REST API requests must include an API Key. For later usage, store the key to an environment variable:

export BEARER_TOKEN="sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Getting Started

import os
import h2ogpte_rest_client
from h2ogpte_rest_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = h2ogpte_rest_client.Configuration(
    host = "https://h2ogpte.genai.h2o.ai/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: bearerAuth
configuration = h2ogpte_rest_client.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)


# Enter a context with an instance of the API client
with h2ogpte_rest_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = h2ogpte_rest_client.ChatApi(api_client)
    collection_id = 'collection_id_example' # str | Id of collection (optional)

    try:
        # Creates chat session.
        api_response = api_instance.create_chat_session(collection_id=collection_id)
        print("The response of ChatApi->create_chat_session:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling ChatApi->create_chat_session: %s\n" % e)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

h2ogpte_rest_client-1.6.14.dev2-py3-none-any.whl (188.1 kB view details)

Uploaded Python 3

File details

Details for the file h2ogpte_rest_client-1.6.14.dev2-py3-none-any.whl.

File metadata

File hashes

Hashes for h2ogpte_rest_client-1.6.14.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 83891ad30a81fe63d26625513493b586d36ac20b7657f9da142b2b5ff4ac6cfd
MD5 4f2c37933b739b52c86451a109799981
BLAKE2b-256 f3f58fd1090d809ca11b0d5684fb0f4fec37a1d0066fe379457219f85a6d69f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page