agentleFS
aicontentdropaicontentdrop/claude-plugin/skills/api-error-handling/SKILL.md

api-error-handling

Skill0 starsChanged 2 months agoMITView on GitHub

Read AI Content Drop API failures correctly and decide whether to retry, change the request, or stop. Covers the error envelope and its 21 codes, rate limits and Retry-After, idempotency conflicts, and the two response shapes the generation endpoints can return. Use when a call to aicontentdrop.com fails, returns 4xx or 5xx, is rate limited, or when writing a retry loop against the API.

  • Reads credentials

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. charanjit-singh/lovable-skills★ 10same name
    2. nanami7777777/chinese-fullstack-skills★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository4 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every failure on the public surface carries a machine-readable code:

    line 19
  2. Very specific:

    Read error.code. Never branch on the message — it is written for a human and will change.

    line 31
  3. Distinctive:

    Every response carries the counters, not just the 429:

    line 92
  4. Very specific:

    When you are refused, a 429 carries Retry-After in seconds and retry_after_seconds in the body.

    line 107
  5. Distinctive:

    Never tell a user they were charged for a failed generation.

    line 120
  6. Distinctive:

    Never write code that asks for a refund or a credit adjustment.

    line 121
  7. Distinctive:

    If you are unsure a request is well formed, run it through the sandbox first.

    line 129
  8. Very specific:

    Put an Idempotency-Key on every generation request.

    line 151

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Failing well against the AI Content Drop API

The point of this skill is to stop you doing the two things that waste a user's money and time: retrying something that will never succeed, and giving up on something that would have worked in thirty seconds.

The envelope

Every failure on the public surface carries a machine-readable code:

{
  "error": {
    "code": "insufficient_credits",
    "message": "Balance below the model cost.",
    "documentation": "https://aicontentdrop.com/docs/errors"
  }
}

Read error.code. Never branch on the message — it is written for a human and will change.

One exception you must handle. POST /v1/generate/video and /v1/generate/image are path aliases onto the handlers the website itself calls, so a validation failure from those two can still arrive in the older shape, { "error": "some message" } — a string, not an object. Write the read once and forget it:

const code = typeof body.error === "object" ? body.error.code : undefined;
const message = typeof body.error === "string" ? body.error : body.error?.message;

What each code means for your next move

Do not retry — fix the request:

CodeStatusWhat to do
invalid_request400The message names the field. Correct it.
invalid_json400Send a complete object with Content-Type: application/json.
safety_rejected400The prompt was refused. Rewrite it. Nothing was charged.
unsupported_operation400Not available inside a batch. Call the endpoint directly.
unknown_model404Re-read /v1/models. Check id normalisation (below).
unknown_endpoint404GET /v1 lists the whole surface.
method_not_allowed405The message names the verbs that work.
forbidden403The object is not yours. Retrying cannot change that.
payload_too_large413Split the work. See POST /v1/batch.
query_too_large413GraphQL query over 8,000 characters. Split it.

Do not retry — the user has to act:

CodeStatusWhat to do
unauthorized401No key, or a revoked or malformed one. Read WWW-Authenticate.
unauthenticated401A session surface reached without a session. Most of /v1 needs no credential.
invalid_client401Re-register at /agent/auth/register.
insufficient_credits402Tell the user the balance and the cost. Offer a cheaper model.
idempotency_conflict409Same Idempotency-Key, different body. Use a new key.

Retry is correct:

CodeStatusWhat to do
rate_limited429Wait Retry-After seconds exactly. Nothing was charged.
provider_error502The upstream model failed. Retry is reasonable. Nothing was charged.
internal_error500Our bug. Retry once, then report it.

not_found (404) and operation_failed (400, one item inside a batch) are context-dependent: re-read the catalogue, or read that item's own error.

Rate limits

SurfaceLimit per minute
/v1/* REST120
POST /graphql120
POST /mcp, POST /mcp/docs600
POST /ask60

Every response carries the counters, not just the 429:

RateLimit-Limit: 120
RateLimit-Remaining: 118
RateLimit-Reset: 47

Self-throttle on RateLimit-Remaining instead of waiting to be refused. You can watch them with no credential at all:

curl -sD - https://aicontentdrop.com/v1 -o /dev/null | grep -i ratelimit

When you are refused, a 429 carries Retry-After in seconds and retry_after_seconds in the body. Wait that long. Retrying sooner extends the window rather than shortening it, so an impatient loop is strictly slower than a patient one.

The rule that makes failure cheap here

Credits are charged only when a generation succeeds. A safety block, a provider failure, a validation error and a timeout all cost nothing. A failed generation has no refund path because there is nothing to refund.

Two consequences for your error handling:

  1. Never tell a user they were charged for a failed generation. They were not.
  2. Never write code that asks for a refund or a credit adjustment. No such endpoint exists, by design.

A generation that fails after it started shows status: "failed" with credits_used: 0 and an error_message you can read.

Rehearse instead of guessing

If you are unsure a request is well formed, run it through the sandbox first. It applies the full validation path, needs no API key, and charges nothing:

curl -sX POST https://aicontentdrop.com/v1/generate/video \
  -H "Content-Type: application/json" \
  -H "X-Sandbox: true" \
  -d '{"prompt":"a red balloon over a city","model":"kling_3_0"}'

A 202 means the request shape is right. A 400 names what is wrong, before anyone's credits are involved.

Model id normalisation

Ids use underscores (kling_3_0, veo_3_fast). Dashes are accepted and normalised, so kling-3-0 works. If a model still comes back unknown_model, re-read /v1/models rather than guessing a variant — the catalogue is the source of truth and needs no credential.

Retrying without double-spending

Put an Idempotency-Key on every generation request. Retention is 24 hours: the same key with the same body returns the original result instead of starting a second generation; the same key with a different body is a 409 idempotency_conflict.

curl -sX POST https://aicontentdrop.com/v1/generate/video \
  -H "Authorization: Bearer $ACD_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"prompt":"…","model":"kling_3_0"}'

This is what makes a network timeout safe to retry. Without it, a retry after a timeout can start a second paid generation.

Full reference: https://aicontentdrop.com/docs/errors

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.