Consume quota /skill/consume.json

Call this before submitting a task. It checks and deducts your account's quota for the tool. Pass the returned context through to the task submission request body.

Request

FieldValue
MethodPOST
Hostwapi-skill.vmake.ai
Path/skill/consume.json
Content-Typeapplication/json
AuthSDK-HMAC-SHA256

Request body

{
  "url": "https://<bucket>.oss-<region>.aliyuncs.com/path/to/xxx",
  "urls": ["https://<bucket>.oss-<region>.aliyuncs.com/path/to/xxx"],
  "task": "SKM0006",
  "gid": "sk_xxxxxxxx"
}
FieldRequiredDescription
urlWhen the task has input mediaMedia URL (usually policy.data after the OSS upload). Omit it for generation tasks without reference images
urlsYesAll media URLs in submission order. For a single input, [url]. For a task without input media, []
taskYesThe material_id, matching a key of algorithm.invoke in the /skill/config.json response. This is not the prefixed task path
gidYesGroup ID from /skill/config.json
paramsWhen the tool has params_schemaYour parameter overrides as a JSON object (not a string), the same overrides you merge into the submission. Generation tools use it to bill by options such as duration

Response

{
  "meta": { "code": 0, "msg": "ok" },
  "response": {
    "context": "<opaque_context_string>",
    "notices": []
  }
}
FieldDescription
response.contextWhen returned, put it unchanged in the context field of the task submission body. If a successful response omits it, the submission example uses an empty string
response.noticesOptional notices, such as quota running low

Call order

upload -> consume -> invoke -> (status polling)
  • Always call it before submitting. If the quota API returns a non-zero business code, stop and check meta.msg.
  • If a task fails, the quota deducted for that task is returned to your account.
  • A successful consume has already deducted quota. If the request times out or the connection drops, find out what happened to it first. Once you have a task_id, only query that task. Calling consume again may deduct quota again.

cURL example

Continuing from config in Get config and media_url in Upload media.

This request consumes quota. Check the image URL and tool config, then run it once.

consume_body=$(jq -cn --arg gid "$(jq -er '.response.gid' <<< "$config")" --arg url "$media_url" \
  '{gid:$gid, task:"SKM0006", url:$url, urls:[$url]}')
consume=$(api POST "$platform/skill/consume.json" "$consume_body")
echo "$consume" | jq '.meta'

After meta.code is 0, submit the task with the same image URL and the returned context.

Next steps