Skip to main content

Configuration

The DhivehiGPT client accepts the following options:

OptionTypeRequiredDefaultDescription
apiKeystringNoprocess.env.DHIVEHIGPT_API_KEYYour DhivehiGPT API key. Falls back to the DHIVEHIGPT_API_KEY environment variable; throws if neither is set.
baseUrlstringNohttps://api.dhivehigpt.comOverride the API base URL, e.g. for testing against a staging environment.
apiVersionstringNov1Override the API version path segment, e.g. v2.
timeoutMsnumberNoNo timeoutAborts a request if it takes longer than this many milliseconds.
headersRecord<string, string>No{}Additional headers sent with every request.
fetchtypeof fetchNoThe global fetchA custom fetch implementation, e.g. for older runtimes or for testing.
import { DhivehiGPT } from '@javaabu/dhivehigpt-sdk';

const client = new DhivehiGPT({
apiKey: process.env.DHIVEHIGPT_API_KEY, // optional; read from the same env var automatically
apiVersion: 'v1', // optional, this is the default
timeoutMs: 10_000,
headers: {
'X-Request-Source': 'my-app',
},
});

API key resolution

apiKey is optional. When omitted, the client reads it from the DHIVEHIGPT_API_KEY environment variable:

// DHIVEHIGPT_API_KEY=sk_... in the environment
const client = new DhivehiGPT();

An explicitly passed apiKey always takes priority over the environment variable. If neither is available, the constructor throws.

You can generate an API key from the API Keys page of your team account. You need a DhivehiGPT team account with an active subscription, and only team owners and admins can generate API keys.

Rate limits

All DhivehiGPT API routes are limited to 60 requests per minute per API key. Exceeding this limit causes the SDK to throw a RateLimitError.