{"openapi":"3.1.0","info":{"title":"Darkfield API","version":"1.0.0","description":"Drive Darkfield from your own code: price a request, make images, video and voice, read the results, check credits. Every call is made as the person who created the key, with the studio's own prices, credit holds and checks. Limits per key: 60 calls a minute, 1000 an hour, 60 paid calls an hour."},"servers":[{"url":"/api/v1"}],"security":[{"bearer":[]}],"tags":[{"name":"catalog"},{"name":"generations"},{"name":"uploads"},{"name":"account"},{"name":"films"},{"name":"briefs"},{"name":"recipes"},{"name":"ideas"}],"paths":{"/tools":{"get":{"tags":["catalog"],"operationId":"listTools","summary":"Every tool and whether it is live","x-hemera-scope":"read","responses":{"200":{"description":"Tools","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"object"}}}}}}},"401":{"$ref":"#/components/responses/E401"},"429":{"$ref":"#/components/responses/E429"}}}},"/models":{"get":{"tags":["catalog"],"operationId":"listModels","summary":"The models that can run a tool, with an example price","x-hemera-scope":"read","parameters":[{"name":"tool","in":"query","schema":{"type":"string"},"description":"A tool slug from /tools."},{"name":"kind","in":"query","schema":{"type":"string","enum":["image","video","voice"]},"description":"Used when tool is absent."}],"responses":{"200":{"description":"Models","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"object"}}}}}}},"401":{"$ref":"#/components/responses/E401"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/quote":{"post":{"tags":["generations"],"operationId":"quote","summary":"The exact price of a request. Free; nothing is held.","x-hemera-scope":"read","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["request"],"properties":{"request":{"$ref":"#/components/schemas/StudioRequest"}}}}}},"responses":{"200":{"description":"The price","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Quote"}}}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/generations":{"post":{"tags":["generations"],"operationId":"createGeneration","summary":"Make something, at a price you accept","description":"Holds the price and starts the work. maxCredits is required: a price above it is refused (409) and nothing is held. clientRequestId (or the Idempotency-Key header) makes retries safe: the same id answers the first generation, with no second hold. 201 for a new generation, 200 for a replay.","x-hemera-scope":"generate","parameters":[{"name":"Idempotency-Key","in":"header","schema":{"type":"string","minLength":8,"maxLength":100,"pattern":"^[A-Za-z0-9_-]+$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["request","maxCredits"],"properties":{"request":{"$ref":"#/components/schemas/StudioRequest"},"maxCredits":{"type":"integer","minimum":0},"clientRequestId":{"type":"string","minLength":8,"maxLength":100,"pattern":"^[A-Za-z0-9_-]+$"}}}}}},"responses":{"200":{"description":"A replay of a known clientRequestId","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Generation"}}}}}},"201":{"description":"Started","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Generation"}}}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"402":{"$ref":"#/components/responses/E402"},"403":{"$ref":"#/components/responses/E403"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"},"503":{"$ref":"#/components/responses/E503"}}},"get":{"tags":["generations"],"operationId":"listGenerations","summary":"The person's results, newest first","x-hemera-scope":"read","parameters":[{"name":"kind","in":"query","schema":{"type":"string","enum":["image","video","voice"]}},{"name":"tool","in":"query","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":60}},{"name":"cursor","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"A page","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Generation"}},"nextCursor":{"type":["string","null"]}}}}}}}},"401":{"$ref":"#/components/responses/E401"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/generations/{id}":{"get":{"tags":["generations"],"operationId":"getGeneration","summary":"Status and, when succeeded, the files","x-hemera-scope":"read","parameters":[{"name":"id","in":"path","required":true,"description":"The generation","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The generation","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Generation"}}}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"429":{"$ref":"#/components/responses/E429"}}}},"/assets":{"get":{"tags":["generations"],"operationId":"listAssets","summary":"The person's finished files, one entry per output","x-hemera-scope":"read","parameters":[{"name":"kind","in":"query","schema":{"type":"string","enum":["image","video","voice"]}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":60}},{"name":"cursor","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"A page","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Asset"}},"nextCursor":{"type":["string","null"]}}}}}}}},"401":{"$ref":"#/components/responses/E401"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/uploads":{"post":{"tags":["uploads"],"operationId":"createUpload","summary":"Step 1 of 3: a short-lived URL to PUT a file to","description":"Then PUT the file's bytes to uploadUrl with its Content-Type, then POST /uploads/{id}/confirm.","x-hemera-scope":"upload","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["mime"],"properties":{"mime":{"type":"string","examples":["image/png","video/mp4","audio/mpeg"]},"kind":{"type":"string","enum":["image","video","audio","mask"]}}}}}},"responses":{"201":{"description":"Where to PUT the file","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","properties":{"assetId":{"type":"string"},"uploadUrl":{"type":"string"},"method":{"const":"PUT"}}}}}}}},"401":{"$ref":"#/components/responses/E401"},"403":{"$ref":"#/components/responses/E403"},"413":{"$ref":"#/components/responses/E413"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/uploads/{id}/confirm":{"post":{"tags":["uploads"],"operationId":"confirmUpload","summary":"Step 3 of 3: check the file","description":"status is ready, blocked (with blockedFor) or needs_declaration (a person is visible: declare who on Darkfield before using it).","x-hemera-scope":"upload","parameters":[{"name":"id","in":"path","required":true,"description":"The asset from step 1","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The file's state","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"401":{"$ref":"#/components/responses/E401"},"403":{"$ref":"#/components/responses/E403"},"404":{"$ref":"#/components/responses/E404"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/balance":{"get":{"tags":["account"],"operationId":"getBalance","summary":"Credits: balance, held, available","x-hemera-scope":"read","responses":{"200":{"description":"The balance","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Balance"}}}}}},"401":{"$ref":"#/components/responses/E401"},"429":{"$ref":"#/components/responses/E429"}}}},"/films":{"post":{"tags":["films"],"operationId":"startFilm","summary":"Start a film from a script (free; the making is priced and approved on Darkfield)","x-hemera-scope":"generate","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["script"],"properties":{"script":{"type":"string"},"briefId":{"type":"string","description":"Optional: the creative brief the film is for (POST /briefs)."}}}}}},"responses":{"201":{"description":"The film, reading","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"403":{"$ref":"#/components/responses/E403"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"},"503":{"$ref":"#/components/responses/E503"}}}},"/films/{id}":{"get":{"tags":["films"],"operationId":"getFilm","summary":"A film's state and shots","x-hemera-scope":"read","parameters":[{"name":"id","in":"path","required":true,"description":"The film","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The film","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"429":{"$ref":"#/components/responses/E429"}}}},"/briefs":{"post":{"tags":["briefs"],"operationId":"createBrief","summary":"Write a creative brief for any medium (free)","description":"Stores brief as version 1 (source api). brief follows the creative brief schema: schemaVersion 1, medium, objective.kind and language are required; references carry a rights class. Nothing is made or charged.","x-hemera-scope":"generate","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["brief"],"properties":{"brief":{"type":"object"}}}}}},"responses":{"201":{"description":"The brief's version 1","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"403":{"$ref":"#/components/responses/E403"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/briefs/{id}":{"get":{"tags":["briefs"],"operationId":"getBrief","summary":"A creative brief's current version","x-hemera-scope":"read","parameters":[{"name":"id","in":"path","required":true,"description":"The brief","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The brief","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"429":{"$ref":"#/components/responses/E429"}}}},"/recipes":{"get":{"tags":["recipes"],"operationId":"listRecipes","summary":"Gallery recipes and the person's own","x-hemera-scope":"read","responses":{"200":{"description":"Recipes","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"object"}}}}}}},"401":{"$ref":"#/components/responses/E401"},"429":{"$ref":"#/components/responses/E429"}}}},"/recipes/{id}/quote":{"post":{"tags":["recipes"],"operationId":"quoteRecipe","summary":"Each step's price and the total. Free.","x-hemera-scope":"read","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"A gallery recipe id or the person's own recipe's uuid"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"inputs":{"type":"object"},"lang":{"type":"string","enum":["en","ka"]}}}}}},"responses":{"200":{"description":"The quote","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/recipes/{id}/runs":{"post":{"tags":["recipes"],"operationId":"runRecipe","summary":"Run a recipe at a total you accept","x-hemera-scope":"generate","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["maxCredits"],"properties":{"inputs":{"type":"object"},"maxCredits":{"type":"integer","minimum":0},"lang":{"type":"string","enum":["en","ka"]}}}}}},"responses":{"201":{"description":"The run","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"402":{"$ref":"#/components/responses/E402"},"403":{"$ref":"#/components/responses/E403"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"},"503":{"$ref":"#/components/responses/E503"}}}},"/ideas":{"get":{"tags":["ideas"],"operationId":"listIdeas","summary":"Ready ideas (presets, recipes, workflows) as machine-readable descriptors","description":"Filters: medium, goal, kind (preset | recipe | workflow), subject, have (comma-separated input kinds you can give: prompt, text, image, video, audio, voice), runnable (true | false), text, limit (1-100), offset. Each item: the descriptor, runnable, and the reason when it cannot start.","x-hemera-scope":"read","parameters":[{"name":"medium","in":"query","required":false,"schema":{"type":"string"}},{"name":"goal","in":"query","required":false,"schema":{"type":"string"}},{"name":"kind","in":"query","required":false,"schema":{"type":"string"}},{"name":"subject","in":"query","required":false,"schema":{"type":"string"}},{"name":"have","in":"query","required":false,"schema":{"type":"string"}},{"name":"runnable","in":"query","required":false,"schema":{"type":"string"}},{"name":"text","in":"query","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"string"}},{"name":"offset","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Ideas","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object"}},"total":{"type":"integer"}}}}}}}},"401":{"$ref":"#/components/responses/E401"},"403":{"$ref":"#/components/responses/E403"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/ideas/{id}":{"get":{"tags":["ideas"],"operationId":"getIdea","summary":"One idea: inputs, capabilities, price model, preview, knowledge, whether it can start now","x-hemera-scope":"read","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"An idea id (a slug)"}],"responses":{"200":{"description":"The idea","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"401":{"$ref":"#/components/responses/E401"},"403":{"$ref":"#/components/responses/E403"},"404":{"$ref":"#/components/responses/E404"},"429":{"$ref":"#/components/responses/E429"}}}},"/ideas/{id}/quote":{"post":{"tags":["ideas"],"operationId":"quoteIdea","summary":"The price of starting an idea with these inputs. Free.","x-hemera-scope":"read","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"inputs":{"type":"object"},"lang":{"type":"string","enum":["en","ka"]}}}}}},"responses":{"200":{"description":"The quote","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"403":{"$ref":"#/components/responses/E403"},"404":{"$ref":"#/components/responses/E404"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/ideas/{id}/start":{"post":{"tags":["ideas"],"operationId":"startIdea","summary":"Start an idea at a total you accept","description":"A preset idea writes a creative brief version and starts an engine plan at the price (quoted again; a higher price is 409, nothing held). A recipe idea runs the recipe.","x-hemera-scope":"generate","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["maxCredits"],"properties":{"inputs":{"type":"object"},"maxCredits":{"type":"integer","minimum":0},"briefId":{"type":"string"},"lang":{"type":"string","enum":["en","ka"]}}}}}},"responses":{"201":{"description":"The started run","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"402":{"$ref":"#/components/responses/E402"},"403":{"$ref":"#/components/responses/E403"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"},"503":{"$ref":"#/components/responses/E503"}}}},"/idea-runs/{id}":{"get":{"tags":["ideas"],"operationId":"getIdeaRun","summary":"A started idea's plan: state, generations, files","x-hemera-scope":"read","parameters":[{"name":"id","in":"path","required":true,"description":"The run (plan)","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The run","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"429":{"$ref":"#/components/responses/E429"}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"A key from your account page: Authorization: Bearer hk_live_…"}},"responses":{"E400":{"description":"The body is not JSON, or a field is malformed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E401":{"description":"No key, an unknown key, a revoked key, or the key's account is closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E402":{"description":"Not enough credits: requiredCredits and availableCredits are set.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E403":{"description":"The key lacks the scope (details: [\"scope:generate\"]), or the account has not confirmed its age.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E404":{"description":"No such resource for this key's person. Another person's id answers the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E409":{"description":"The price rose above maxCredits (nothing held), or the resource moved on.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E413":{"description":"The body is larger than 64 KB, or the person's storage is full.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E422":{"description":"The request is understood but refused: validation (details name the fields) or moderation (blocked, category).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E429":{"description":"A rate limit, the key's daily credit ceiling, a spend ceiling or a full queue. Retry-After is set when known.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E500":{"description":"Our fault. Nothing was charged.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E503":{"description":"Generations are stopped by an admin, or a needed service is unavailable. Nothing was held.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","examples":["unauthenticated","forbidden","not_found","validation","insufficient_credits","conflict","rate_limited","blocked","spend_limit_reached","queue_full","internal"]},"message":{"type":"string"},"details":{"type":"array","items":{"type":"string"}},"requiredCredits":{"type":"integer"},"availableCredits":{"type":"integer"},"retryAfterSeconds":{"type":"integer"},"category":{"type":"string"}}}}},"StudioRequest":{"type":"object","required":["tool"],"properties":{"tool":{"type":"string","description":"A slug from /tools","examples":["image","video","voice"]},"modelId":{"type":"string","default":"auto"},"inputs":{"type":"object","properties":{"prompt":{"type":"string"},"text":{"type":"string"},"image":{"type":"string","format":"uuid"},"images":{"type":"array","items":{"type":"string","format":"uuid"}},"video":{"type":"string","format":"uuid"},"audio":{"type":"string","format":"uuid"},"voice":{"type":"string"}}},"settings":{"type":"object","properties":{"aspect":{"type":"string","examples":["1:1","9:16","16:9","4:5"]},"count":{"type":"integer"},"durationS":{"type":"integer"},"resolution":{"type":"string"},"sound":{"type":"boolean"}}}}},"Quote":{"type":"object","properties":{"credits":{"type":"integer"},"usdCents":{"type":"integer"},"model":{"type":"object"}}},"Balance":{"type":"object","properties":{"balance":{"type":"integer"},"held":{"type":"integer"},"available":{"type":"integer"}}},"Generation":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tool":{"type":"string"},"kind":{"type":"string"},"status":{"type":"string","enum":["queued","running","succeeded","failed","blocked"]},"priceCredits":{"type":"integer"},"modelName":{"type":"string"},"outputs":{"type":"array","items":{"type":"object","properties":{"assetId":{"type":"string"},"url":{"type":"string"},"mime":{"type":"string"}}}},"errorCode":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"}}},"Asset":{"type":"object","properties":{"assetId":{"type":"string"},"generationId":{"type":"string"},"kind":{"type":"string"},"url":{"type":"string","description":"A short-lived signed link"},"mime":{"type":"string"},"width":{"type":["integer","null"]},"height":{"type":["integer","null"]},"durationMs":{"type":["integer","null"]}}}}}}