Skip to main content

DhivehiGPT SDK for Python

Latest Version on PyPI Test Status Code Coverage Badge Total Downloads

A lightweight, zero-dependency Python SDK for the DhivehiGPT API.

Requirements

  • Python 3.8 or higher
  • No runtime dependencies — the SDK only uses the Python standard library.

Installation

pip install dhivehigpt-sdk

Getting an API key

API keys are generated from your DhivehiGPT team's API Keys page. You'll need:

  • A DhivehiGPT team account with an active subscription.
  • To be a team owner or team admin — only owners and admins can generate API keys.

Quick start

The client reads the API key from the DHIVEHIGPT_API_KEY environment variable by default:

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

client = DhivehiGPT()

# or pass the API key explicitly
client = DhivehiGPT(api_key="your-api-key")

base_url and api_version are optional and default to https://api.dhivehigpt.com and v1:

client = DhivehiGPT(
    api_key="your-api-key",
    base_url="https://api.dhivehigpt.com",
    api_version="v1",
)

Usage

Voices

voices = client.voices.list(gender="female", is_premium=False)
voice = client.voices.get("hajja")

Text-to-Speech (TTS)

audio = client.tts.generate(text="ދިވެހިޖީޕީޓީއަށް މަރުޙަބާ", voice="hajja")

audios = client.tts.list(voice="hajja", per_page=20)
one = client.tts.get(audio["data"]["uuid"])
client.tts.update(audio["data"]["uuid"], title="Welcome message")
client.tts.delete(audio["data"]["uuid"])

Balance

balance = client.balance.get()
print(balance["billing_period"]["balance"])

Tasks

tasks = client.tasks.list(platform="tts")
task = client.tasks.get("audio_generation")
cost = client.tasks.calculate(task="audio_generation", units=1000)

Error handling

All errors raised by the SDK inherit from dhivehigpt_sdk.DhivehiGPTError:

from dhivehigpt_sdk import DhivehiGPT, DhivehiGPTError, NotFoundError

client = DhivehiGPT()

try:
    client.voices.get("does-not-exist")
except NotFoundError as e:
    print(e.status_code, e.message)
except DhivehiGPTError as e:
    print("Something else went wrong:", e)
Exception Cause
AuthenticationError Missing, invalid, or revoked API key (401)
PermissionDeniedError Not enough credits, etc. (403)
NotFoundError Resource does not exist (404)
ValidationError Invalid request data (422); see error.errors
RateLimitError Exceeded 60 requests/minute per API key (429)
ServerError Upstream error (5xx)
APIConnectionError Could not reach the API

Documentation

Full documentation is available at https://docs.javaabu.com/docs/dhivehigpt-sdk-python.

The full DhivehiGPT API reference is available at https://dhivehigpt.com/docs.

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.

If you've found a bug regarding security please mail info@javaabu.com instead of using the issue tracker.

Testing

pip install -e ".[test]"
pytest

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email info@javaabu.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Download files

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

Source Distribution

dhivehigpt_sdk-1.1.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

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

dhivehigpt_sdk-1.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file dhivehigpt_sdk-1.1.0.tar.gz.

File metadata

  • Download URL: dhivehigpt_sdk-1.1.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for dhivehigpt_sdk-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f8164ebc2db04df786ffbe25692b125b16e363e45976488fad60939eb152d302
MD5 a51a7d02fd370ad59fa49b2032dbbc72
BLAKE2b-256 f563f84f87d170359c4f016c5c6910373498f984414a644215ff9a36beae6467

See more details on using hashes here.

File details

Details for the file dhivehigpt_sdk-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: dhivehigpt_sdk-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for dhivehigpt_sdk-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b25d3c1019306489e6e790ca686710749209b2ff70df0c303364c91ecd56e76
MD5 ec4128dfa03586d48521de76bb590810
BLAKE2b-256 983ebd2f0030608aecc0061cc22099963349827a85001cedaae1cc894b5441d1

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.0

2 files

Supported by

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