Overview
Quickstart
Get a key, verify it, and make your first generation against the Dhanu public API in a few minutes.
The Dhanu public API lets your own server generate images and text, metered
against your workspace’s credit balance. Everything below works with curl or the
official SDK.
Base URL — https://api.dhanu.ai, with every public endpoint under
/api/pub/v1.
1. Get a key
Open Developers in the Dhanu app, create a key, and copy it. Keys look like
dhanu_sk_test_… and are shown once — store it somewhere safe immediately. If
you lose it, rotate it rather than trying to recover it.
A key is scoped to one or more projects in your workspace, and you must pick at least one when creating it. See API keys.
Your secret key is a server-side secret. Never ship it to a browser, a mobile app, or a public repository — anyone holding it can spend your workspace’s credits.
2. Verify it
GET /me is the cheapest way to confirm a key works and see what it can reach.
curl https://api.dhanu.ai/api/pub/v1/me \
-H "Authorization: Bearer $DHANU_API_KEY"
{
"app": { "id": "…", "name": "Website" },
"projects": [{ "id": "…", "name": "Website" }],
"key": { "name": "production" }
}
projects lists everything the key can reach. app is the single scoped project,
or null when the key is scoped to more than one.
3. Generate something
curl -X POST https://api.dhanu.ai/api/pub/v1/text \
-H "Authorization: Bearer $DHANU_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "Write a haiku about Kathmandu"}'
{
"text": "…",
"model": "…",
"usage": { "inputTokens": 12, "outputTokens": 41 },
"cost": { "amount": 28, "currency": "NPR" }
}
cost.amount is in the currency’s minor unit — 28 means NPR 0.28.
4. Or use the SDK
npm i dhanu
import { Dhanu } from "dhanu";
const dhanu = new Dhanu(process.env.DHANU_API_KEY!);
const reply = await dhanu.text.generate({
prompt: "Write a haiku about Kathmandu",
});
See Node SDK for the full surface.
What to read next
- API keys — scopes, rotation, revocation
- Generate an image
- Generate text
- Errors and Rate limits