Official Python SDK for the HumanTone API. Humanize AI-generated text and check AI likelihood.
Project description
humantone-sdk
Official Python SDK for HumanTone. Humanize AI-generated text and check AI likelihood from your Python code. One API key, same credits you already use in the HumanTone web app.
Install
pip install humantone-sdk
For the async client (uses httpx):
pip install "humantone-sdk[async]"
Requires Python 3.10 or later.
Quickstart
import os
from humantone import HumanTone
client = HumanTone(api_key=os.environ["HUMANTONE_API_KEY"])
result = client.humanize(
text="Your AI-generated draft goes here. Must be at least 30 words for the API to accept it.",
)
print(result.text)
print(f"Credits used: {result.credits_used}")
The client also picks up HUMANTONE_API_KEY from the environment automatically:
client = HumanTone()
API
client.humanize(text, *, level, output_format, custom_instructions)
Rewrites AI-generated text to sound more natural.
| Argument | Type | Default | Notes |
|---|---|---|---|
text |
str |
required | Min 30 words. Max depends on plan (Basic 750, Standard 1000, Pro 1500). |
level |
HumanizationLevel or "standard" | "advanced" | "extreme" |
"standard" |
advanced and extreme are English-only. |
output_format |
OutputFormat or "text" | "html" | "markdown" |
"text" |
SDK default is "text" even though the API default is "html". |
custom_instructions |
str | None |
None |
Free-form rewrite guidance. Max 1000 chars. |
Returns HumanizeResult with text: str, output_format: OutputFormat, credits_used: int, request_id: str | None.
client.detect(text)
Returns AI likelihood score 0-100. Free, but limited to 30 calls per day per account (shared between the web app and the API).
score = client.detect(text="...")
print(score.ai_score) # 0-100
client.account.get()
Returns plan, credit balance, and subscription status.
info = client.account.get()
print(info.plan.name)
print(info.credits.total)
print(info.plan.max_words)
print(info.subscription.active)
print(info.subscription.expires_at) # datetime | None
Configuration
client = HumanTone(
api_key="ht_...", # or HUMANTONE_API_KEY env
base_url="https://api.humantone.io", # or HUMANTONE_BASE_URL env, default is api.humantone.io
timeout=120.0, # seconds
max_retries=2,
retry_on_post=False, # POST endpoints retry only when explicit
user_agent="my-app/1.0", # appended to default UA after a single space
)
You can inject any requests.Session-compatible HTTP client:
import requests
from humantone import HumanTone
session = requests.Session()
session.proxies = {"https": "http://proxy.internal:8080"}
client = HumanTone(api_key="ht_...", http_client=session)
Error handling
All errors raised by the SDK extend HumanToneError.
from humantone import (
HumanTone,
HumanToneError,
InsufficientCreditsError,
DailyLimitExceededError,
InvalidRequestError,
AuthenticationError,
RateLimitError,
)
client = HumanTone()
try:
result = client.humanize(text="...")
except InsufficientCreditsError:
print("Buy more credits at https://app.humantone.io/settings/credits")
except RateLimitError as e:
print(f"Rate limited. Retry in {e.retry_after_seconds}s.")
except InvalidRequestError as e:
print(f"Bad input: {e}")
except AuthenticationError:
print("Check your API key.")
except HumanToneError as e:
print(f"HumanTone API error ({e.error_code}): {e}")
if e.request_id:
print(f"Request ID: {e.request_id}")
Every error exposes:
e.message: str(usestr(e))e.status_code: int | Nonee.request_id: str | Nonee.error_code: str | Nonee.details: dict | Nonee.retryable: bool
Specific exceptions add typed accessors: RateLimitError.retry_after_seconds: int, DailyLimitExceededError.time_to_next_renew: int | None, InsufficientCreditsError.required_credits: int | None and available_credits: int | None.
Python's stdlib has a builtin
TimeoutError. The SDK'shumantone.TimeoutErrorshadows it inside thehumantonenamespace. Usefrom humantone import TimeoutError as HumanToneTimeoutErrorif you need to disambiguate.
Retry behavior
The SDK retries account.get() on network errors, 5xx, and 429 (up to 2 retries). POST methods (humanize, detect) do not retry on network or 5xx by default. Humanize debits credits, so a retried request risks double-billing. Pass retry_on_post=True to opt in. 429 always retries on every method.
Retry-After headers are honored in both numeric (seconds) and HTTP-date formats.
Async usage
import asyncio
from humantone import AsyncHumanTone
async def main():
async with AsyncHumanTone() as client:
result = await client.humanize(text="...")
print(result.text)
asyncio.run(main())
The async client uses httpx and is exposed via pip install "humantone-sdk[async]".
Limits to remember
- Per-request word limit. Basic 750, Standard 1000, Pro 1500. Inputs must be at least 30 words.
- Credits. Humanize consumes 1 credit per 100 words. Account checks and AI likelihood checks do not consume credits.
- AI likelihood quota. 30 checks per day per account, shared between the HumanTone web app and any API or SDK usage. Resets at midnight UTC.
- API access. Included on all paid plans. Free trial accounts cannot use the API.
Get an API key
Sign up at humantone.io. The HumanTone API is paid only.
License
MIT
Links
- API docs: https://humantone.io/docs/api/
- MCP server: https://humantone.io/docs/mcp/
- Issues: https://github.com/humantone/humantone-python/issues
- Support: help@humantone.io
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file humantone_sdk-0.0.1.post1.tar.gz.
File metadata
- Download URL: humantone_sdk-0.0.1.post1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
180b0687ba5f76e211b2f85dea17db372eeed2686ada33c9483f8a42e6b2c97b
|
|
| MD5 |
01524a7e93d77f1696624fd0df07d034
|
|
| BLAKE2b-256 |
5e8ec9f5a5d8bb8101d0b496c7125b65d8e784e8a19c3083bc323e78bd89a434
|
Provenance
The following attestation bundles were made for humantone_sdk-0.0.1.post1.tar.gz:
Publisher:
release.yml on HumanTone/humantone-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
humantone_sdk-0.0.1.post1.tar.gz -
Subject digest:
180b0687ba5f76e211b2f85dea17db372eeed2686ada33c9483f8a42e6b2c97b - Sigstore transparency entry: 1436565673
- Sigstore integration time:
-
Permalink:
HumanTone/humantone-python@6c4eb4654b163e35483a584354cf8ee9d79c3348 -
Branch / Tag:
refs/tags/0.0.1.post1 - Owner: https://github.com/HumanTone
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6c4eb4654b163e35483a584354cf8ee9d79c3348 -
Trigger Event:
push
-
Statement type:
File details
Details for the file humantone_sdk-0.0.1.post1-py3-none-any.whl.
File metadata
- Download URL: humantone_sdk-0.0.1.post1-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a9ca97ca21d2327315a65cde2627b53fd0bc03a42193b11ff5761335d32f41e
|
|
| MD5 |
b09615103f4d427b4c57891267d0dbdd
|
|
| BLAKE2b-256 |
cb500e68676646a829e425ba023729e308e8f1d04ff71cddbd512330ab03dd4b
|
Provenance
The following attestation bundles were made for humantone_sdk-0.0.1.post1-py3-none-any.whl:
Publisher:
release.yml on HumanTone/humantone-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
humantone_sdk-0.0.1.post1-py3-none-any.whl -
Subject digest:
9a9ca97ca21d2327315a65cde2627b53fd0bc03a42193b11ff5761335d32f41e - Sigstore transparency entry: 1436565711
- Sigstore integration time:
-
Permalink:
HumanTone/humantone-python@6c4eb4654b163e35483a584354cf8ee9d79c3348 -
Branch / Tag:
refs/tags/0.0.1.post1 - Owner: https://github.com/HumanTone
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6c4eb4654b163e35483a584354cf8ee9d79c3348 -
Trigger Event:
push
-
Statement type: