Metadata-Version: 2.2
Name: h2ogpte_rest_client
Version: 1.6.14.dev2
Summary: The Python client for H2OGPTe REST API
Home-page: https://github.com/h2oai/h2ogpte
Author: H2O.ai, Inc.
Author-email: support@h2o.ai
Keywords: OpenAPI,OpenAPI-Generator,H2OGPTe REST API
Description-Content-Type: text/markdown
Requires-Dist: urllib3<3.0.0,>=1.25.3
Requires-Dist: python-dateutil>=2.8.2
Requires-Dist: pydantic>=2
Requires-Dist: typing-extensions>=4.7.1
Dynamic: author
Dynamic: author-email
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: requires-dist
Dynamic: summary

# H2OGPTe REST Client

This package represents a generated Python client for [H2OGPTe REST API](https://h2ogpte.genai.h2o.ai/swagger-ui/).
The client was generated with the [openapi-generator-cli](https://openapi-generator.tech/docs/installation/) 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:

```sh
pip install h2ogte_rest_client
```

Then import the package:
```python
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](https://genai.h2o.ai/appstore) 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:

```sh
export BEARER_TOKEN="sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
```

## Getting Started

```python

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)

```
