Skip to main content

Installation & Setup

Installation

Install the package from PyPI:

pip install dhivehigpt-sdk

Configuring the client

Create a client instance with DhivehiGPT. Only an API key is required; see Authentication for how to generate one.

from dhivehigpt_sdk import DhivehiGPT

client = DhivehiGPT(api_key="your-api-key")

Loading the API key from the environment

If you don't pass api_key explicitly, the client reads it from the DHIVEHIGPT_API_KEY environment variable:

export DHIVEHIGPT_API_KEY="your-api-key"
from dhivehigpt_sdk import DhivehiGPT

client = DhivehiGPT()

If neither an explicit api_key nor the DHIVEHIGPT_API_KEY environment variable is set, the client raises a ValueError when instantiated.

Optional configuration

base_url and api_version are optional keyword arguments. They default to the production API server and the v1 API version, so you generally don't need to set them:

client = DhivehiGPT(
api_key="your-api-key",
base_url="https://api.dhivehigpt.com", # default
api_version="v1", # default
timeout=30, # request timeout in seconds, default 30
)

You might override base_url to point at a proxy or a mock server in tests, or api_version if a new API version is released.