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, the
Node SDK, or the Python SDK, nothing here requires installing a package.
Base URL: https://api.dhanu.ai, with every public endpoint under
/api/pub/v1.
1. Create a project, get a key
Open Developers → Projects in the Dhanu app and create a project. A project groups the keys for one app or environment, and creating one mints its first secret key. Start here: the API keys page stays empty until a project exists, because every key belongs to at least one project.
Keys look like dhanu_sk_test_… and are shown once, store it somewhere safe
immediately. If you lose one, delete it and create a new key.
Each key carries two scopes, both chosen when you create it:
- Projects: which projects the key acts on, and which project each generation is metered against.
- API scope: how much of the API it may call: the whole app, selected packages, or selected APIs.
See API keys for both in full.
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"import { Dhanu } from "dhanu";
const dhanu = new Dhanu(process.env.DHANU_API_KEY!);
const me = await dhanu.me();
console.log(me.projects, me.scope);import os
from dhanu import Dhanu
dhanu = Dhanu(os.environ["DHANU_API_KEY"])
me = dhanu.me()
print(me.projects, me.scope) {
"app": { "id": "…", "name": "Website" },
"projects": [{ "id": "…", "name": "Website" }],
"key": { "name": "production" },
"scope": {
"level": "app",
"packages": ["text", "images"],
"operations": ["text.generate", "images.generate"]
}
}
projects lists everything the key can reach. app is the single scoped project,
or null when the key is scoped to more than one. scope shows which packages and
APIs the key may call; GET /reference expands that into the full catalogue.
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"}'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",
});import os
from dhanu import Dhanu
dhanu = Dhanu(os.environ["DHANU_API_KEY"])
reply = dhanu.text.generate(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.
If your key covers more than one project, name the one to meter against with
projectId. Without it the call fails with project_id_required (422):
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", "projectId": "…"}'
A single-project key can omit it, GET /me tells you which case you are in.
4. Or use an SDK
Both SDKs are thin wrappers over the endpoints above, with no dependencies.
// 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",
});# pip install dhanu
import os
from dhanu import Dhanu
dhanu = Dhanu(os.environ["DHANU_API_KEY"])
reply = dhanu.text.generate(prompt="Write a haiku about Kathmandu") See Node SDK and Python SDK for the full surface.
5. Discover the rest
GET /reference returns every package and API, flagged with what your key is
allowed to call, the whole catalogue over plain HTTP, no package needed:
curl https://api.dhanu.ai/api/pub/v1/reference \
-H "Authorization: Bearer $DHANU_API_KEY"
Developers → Usage in the app shows what you have spent.
What to read next
- API keysproject and API scopes, revoking
- Generate an image
- Generate text
- List the API catalogue
- Errorsand Rate limits