Skip to main content
Version: v1.1.x

Python client download and overview

This page provides an overview of the H2O eScorer Python client.

Download the Python client​

To download the H2O eScorer Python client wheel, click the Python client tab in the H2O eScorer downloads page. You can then install the downloaded Python client wheel.

The h2o_escorer Python package​

The Python package h2o_escorer provides the Python driver for H2O eScorer. It's a lightweight package with a single class, Client, that provides a simple API with asynchronous functions. These can be used to authenticate and make predictions using models deployed on the H2O AI Cloud.

Authentication and Initialization​

  • Authenticating h2o_escorer with H2O AI Cloud (HAIC) requires an HAIC platform token. You can get an HAIC platform token from the HAIC UI by clicking CLI & API Access and then clicking the generate token link in the Connect to the platform section. For more information, see Get the platform token.

  • This Python code authenticates with H2O AI Cloud using a platform token and sets up a client to interact with the H2O eScorer service. It uses the TokenProvider to securely manage the token and initializes the Client class for sending asynchronous scoring requests.

from h2o_authn import TokenProvider
import getpass

print(f"Visit https://internal.dedicated.h2o.ai/auth/get-platform-token to get your platform token")
token_provider = TokenProvider(
refresh_token=getpass.getpass('Enter your platform token: '),
client_id="hac-platform-public",
token_endpoint_url="https://auth.internal.dedicated.h2o.ai/auth/realms/hac/protocol/openid-connect/token"
)

from h2o_escorer import Client

# Option 1: Provide the escorer_url directly
client = Client(
escorer_url="https://rest-scorer.internal.dedicated.h2o.ai",
token_provider=token_provider
)

Service discovery with H2O Cloud URL​

When using the h2o_cloud_url parameter, the client automatically discovers:

  • eScorer service URL
  • Authentication configuration

This simplifies client initialization by requiring only the H2O Cloud URL and authentication credentials:

# Option 2: Use service discovery with token provider
client = Client(
h2o_cloud_url="https://<platform>.dedicated.h2o.ai/",
token_provider=token_provider
)

# You can also initialize with username and password
client = Client(
h2o_cloud_url="https://<platform>.dedicated.h2o.ai/",
oidc_username="<username>",
oidc_password="<password>"
)
note

Replace <platform> with your H2O Cloud platform identifier.


Feedback