Agent notes: prepaid requests without an AudD account
Notes for AI agents that have no AudD account: register with one request, buy prepaid requests with a machine payment or a checkout link your user pays, recognize at api.audd.io/agent/recognize, and know what is charged.
We wanted to make it as simple as possible: you register with one request, buy prepaid requests, and send us the audio with your own key. You’ll be able to use our API without an AudD account or an email. Use this guide if you’re an agent that needs to recognize a song and you can pay, or ask your user to pay. You can find the full reference at audd.io/auth.md, and the live price and limits in the service document.
# 1. Register. It's free, and the balance starts at 0.
# The answer holds the key, which is shown once: keep the file private.
umask 077
curl -s https://dashboard-api.audd.io/agent/identity \
-H 'Content-Type: application/json' \
-d '{"type": "anonymous"}' -o audd-agent.json
export AUDD_AGENT_KEY=$(python3 -c 'import json; print(json.load(open("audd-agent.json"))["audd"]["api_key"])')
# 2. Get a checkout link (1 pack = 1,000 requests), and show your user
# the user_message from the answer.
curl -s https://dashboard-api.audd.io/agent/checkout \
-H "Authorization: Bearer $AUDD_AGENT_KEY" \
-H 'Content-Type: application/json' \
-d '{"packs": 1}'
# 3. Once the purchase is fulfilled, recognize.
curl -s https://api.audd.io/agent/recognize \
-H "Authorization: Bearer $AUDD_AGENT_KEY" \
-F url='https://audd.tech/example.mp3'
1. Use your user’s AudD token if there is one
Check whether the user already has an AudD token first, for example in the AUDD_API_TOKEN environment variable. If the user has an AudD account, send the api_token from the Dashboard in all the requests to https://api.audd.io/, or connect our MCP server at mcp.audd.io. Please don’t ask users to paste their API tokens into the chat.
Prepaid requests are for standard recognition only. Agent keys don’t work on our account endpoints: https://api.audd.io/, the enterprise endpoint, streams and the MCP server. To scan long files or monitor streams, the user needs an AudD account.
2. A 401 from the recognition endpoint points here
If a request to the recognition endpoint has no key, you’ll get a 401 with WWW-Authenticate: Bearer and Link: <https://audd.io/auth.md>; rel="help". Its body names the registration and purchase endpoints. So just register, buy prepaid requests, and send the same request again with your key.
3. Register once, and keep the key
POST https://dashboard-api.audd.io/agent/identity
Content-Type: application/json
{"type": "anonymous", "client_name": "my-agent"}
The answer contains the key (audd.api_key, agt_...), a refresh token (refresh_token, audd_art_...) and the registration_id. We send you the key only once, so please store the key and the refresh token as secrets. The answer also contains an identity_assertion, but token exchange isn’t offered yet: use audd.api_key as your credential.
You can also send client_name and agent_platform (each at most 40 printable characters) and contact_email. We store the email unverified and use it only for receipts and notices.
Registration is free, but there are no free requests: the balance starts at 0, so you’ll need to buy requests before the first recognition.
4. Ask your user before you buy
Buying spends real money. Please pay only with a payment method, and up to an amount, that your user has authorized.
You can purchase from 1 to 100 packs at a time. One pack is 1,000 requests for $5.00 (purchase.price in the service document: "amount": "500" in cents, "currency": "usd"). Each purchase is paid once: there’s no subscription, and nothing renews. The credits expire 12 months after your last purchase.
There are two ways to pay for the requests: pay the 402 challenge yourself, or send your user a checkout link.
5. Pay a 402 challenge yourself
POST https://dashboard-api.audd.io/agent/credits
Authorization: Bearer agt_...
Content-Type: application/json
{"packs": 1}
The answer is 402 Payment Required with a WWW-Authenticate: Payment challenge: the Machine Payments Protocol (MPP), with the method stripe and the intent charge. The challenge states the exact amount.
Pay it with an MPP client that supports the stripe method, then send the same request again with the Payment-Authorization header the challenge names. Please keep your Authorization: Bearer header. The 200 answer will contain the new balance and a Payment-Receipt. If you repeat a request with the same Payment-Authorization, we’ll never charge you twice.
You can also pay at the recognition endpoint. With a balance of 0, it answers 402 with a challenge for one pack: pay it and send the same recognition request again.
Each card or Link account can make up to 10 purchases a day. The daily amount is capped at $1,000.00, and the limits reset at 00:00 UTC (purchase.limits in the service document). So please buy several packs in one purchase ({"packs": N}) rather than many single packs.
If a payment is refused, nothing is charged, and the answer says what to do next: use another payment method, buy fewer packs, or wait until the limit resets.
6. Or give your user a checkout link
In addition to the machine payment, you can ask for a checkout link and give it to your user, without having to pay the challenge yourself. Useful if your wallet can’t pay it: Link’s agent wallet works only for customers in the US and Canada. The page is a Stripe payment page: your user can pay by card or any other payment method Stripe offers in their country, without an AudD account. The price, the packs and the credit expiry are the same as for the machine payment.
curl -s https://dashboard-api.audd.io/agent/checkout \
-H "Authorization: Bearer $AUDD_AGENT_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: 5f0c2d1e-checkout-1' \
-d '{"packs": 1}'
The 201 answer contains:
checkout_url: the Stripe payment page for your useruser_message: a sentence you can pass on, with the amount, the seller and the linkpurchase_id:pur_...expires_at: when the link stops working, about 24 hours after it was madestatus_url: where to check the state of the purchase
We don’t charge anything until your user pays. When the link is paid, we’ll add the requests to your registration automatically, whoever paid it. Please send the recognition requests after the purchase becomes fulfilled: poll the status_url to see its state, or check GET https://dashboard-api.audd.io/agent/balance. A purchase can be in one of these states:
awaiting_payment: the link is openprocessing: paid with a method the bank confirms laterfulfilled: the requests are on your balanceexpired: the link wasn’t paid in timefailed: the purchase didn’t complete
When you retry the request, send the same Idempotency-Key header: you’ll get the same link back instead of a second one. If you send the same key with a different number of packs, the request is refused with 409.
We’ve written a small Python program that does all of this: see the recipe Build an assistant that pays for its own song recognition.
When nobody pays the link
If nobody pays the link, the link stops working after about 24 hours. You do not need to cancel it, and nothing is charged. If your user still wants to pay, ask for a new link with a new Idempotency-Key.
7. Recognize with the key in the Authorization header
curl -s https://api.audd.io/agent/recognize \
-H "Authorization: Bearer $AUDD_AGENT_KEY" \
-F url='https://audd.tech/example.mp3' \
-F return='apple_music,spotify'
The parameters and the response are those of AudD’s standard endpoint: send a url, a multipart file or a base64 audio, plus the optional return. Only the first 12 seconds of the audio are analyzed. status: "success" with result: null means the audio was processed and no song matched. The audio file you upload, as a multipart file or base64 audio, may be up to 15 MB, and the whole request body up to 24 MB. A larger file gets AudD error 400, which is free.
Please note that all the agent API requests require the key to be sent in the Authorization header. A key in a URL or in an api_token field is refused. Replace that key, since it may be in logs.
8. A no-match uses a credit, most errors don’t
Basically, we charge one credit for each answer, a match or a no-match. We also charge one credit for AudD error 300 (the audio couldn’t be fingerprinted) and 19 (internal error). Every other error answer is free, including input errors: no file, a URL that could not be downloaded, unsupported or undecodable audio, or a file over 15 MB. Unknown errors (100), timeouts and crashes on our side are free too.
So a result: null costs the same as a match, and if you send the same clip again, it costs another credit. The exact wording is the “Charge rule” in auth.md.
All the answers to requests with a valid key contain the AudD-Credits-Remaining header with your balance. Once a credit was reserved, they also contain AudD-Credits-Charged (0 or 1), and AudD-Credits-Low: 1 when you’re running low. Check GET https://dashboard-api.audd.io/agent/balance with your key before a long job.
9. Errors come as application/problem+json
If something goes wrong, the answer is application/problem+json with audd.code and audd.charged (true, false, or null while it’s unknown). The type URI is https://audd.io/auth.md#error-<code>, and payment problems use https://paymentauth.org/problems/<name>. Please honor Retry-After. You can find the full table of codes in auth.md.
With a balance of 0 or expired credits, you’ll get a 402 with no_prepaid_requests or credits_expired. Pay the challenge and repeat the request, or buy packs; nothing was charged. If the key is unknown, revoked or expired, you’ll get a 401 with invalid_token: mint a new key or register again.
On a 429 or a 503, wait for Retry-After, then send the same request again. If it’s too_many_failed_inputs, fix the input first. A 504 (timeout or late_settle) means that recognition didn’t finish in time. It wasn’t charged, so you can repeat the request.
Please don’t pay twice. If you get
retry_later(503) withaudd.do_not_pay_again: true, the payment may still complete. Send the same request again with the samePayment-Authorization, and don’t pay again. The same goes forpurchase_pending(409): another purchase is waiting for the bank, so pollaudd.purchase_urlor cancel it withDELETE.
If we couldn’t recognize the audio (error 300, 400 and so on), the answer comes in the standard endpoint’s format: status: "error" with an error_code. The error codes reference groups them by category.
10. Manage the registration with your key
GET https://dashboard-api.audd.io/agent/me: the status, the balance and the credit expiry.POST https://dashboard-api.audd.io/agent/keysmakes a new key (shown once),GETlists the keys, andDELETE https://dashboard-api.audd.io/agent/keys?prefix=agt_xxxxxxxxrevokes one.GET https://dashboard-api.audd.io/agent/usage?from=YYYY-MM-DD&to=YYYY-MM-DD: your usage per day.DELETE https://dashboard-api.audd.io/agent/merevokes the registration and every key. With credits left, it answers409 forfeit_required; repeat it with?forfeit=trueto confirm. Credits left on a revoked registration stay on record (questions: [email protected]).
If you lose the key, send the refresh token:
POST https://dashboard-api.audd.io/agent/identity
Content-Type: application/json
{"type": "refresh", "refresh_token": "audd_art_...", "new_api_key": true}
Every time you use the refresh token, you get a new refresh token, so store the new one right away. If an old refresh token is used again more than 60 seconds later, every credential of the registration is revoked.
You can verify the email if you want to (POST https://dashboard-api.audd.io/agent/verify_email). It only makes you reachable for receipts and notices; it doesn’t change any limits or access.
Related
Reading this as an AI agent? The raw Markdown is at agents/pay-per-request.md, and the full index is /resources/llms.txt.
