{"openapi":"3.1.0","info":{"title":"PatentFig AI API","version":"1.0.0","description":"Generate patent-office-style figures from text, and convert existing images: vectorize to SVG/DXF/PDF, AI-upscale, and export filing-ready raster formats. All endpoints are synchronous and consume credits from your PatentFig AI account. Create API keys at https://patentfig.ai/settings/api-keys.","contact":{"email":"contact@patentfig.ai"}},"servers":[{"url":"https://patentfig.ai/api/v1"}],"security":[{"bearerAuth":[]}],"paths":{"/figures":{"post":{"operationId":"generateFigure","summary":"Generate a patent figure from a prompt","description":"Generates a patent-oriented technical figure. `output: \"png\"` produces a raster figure via the image-model pipeline; `output: \"svg\"` produces stroke-based line-art SVG. Optional reference images guide the structure.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["prompt"],"properties":{"prompt":{"type":"string","maxLength":10000,"description":"What to draw. Views, diagram type, and composition are all controlled through the prompt."},"output":{"type":"string","enum":["png","svg"],"default":"png"},"labeled":{"type":"boolean","default":false,"description":"Add patent-style numeric reference callouts (100, 102, …)."},"referenceImageUrls":{"type":"array","items":{"type":"string","format":"uri"},"maxItems":4,"description":"Optional reference images (sketches, photos, or prior figures) used as the structural baseline."}}}}}},"responses":{"200":{"description":"Generated figure","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"format":{"type":"string","enum":["png","svg"]},"svg":{"type":"string","description":"SVG source. Present only when output is \"svg\"."},"creditsConsumed":{"type":"integer"}}}}}}}},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Processing failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/vectorize":{"post":{"operationId":"vectorizeImage","summary":"Convert a raster image to vector (SVG / DXF / PDF)","description":"`engine: \"lineart\"` (default) redraws the image as clean single-stroke patent line art — best for patent figures and CAD. `engine: \"trace\"` traces the input pixels faithfully, preserving fills.","requestBody":{"required":true,"description":"Image input: send JSON with an `imageUrl` field, or multipart/form-data with a `file` field (PNG, JPEG, WebP, or TIFF, max 10 MB).","content":{"application/json":{"schema":{"type":"object","required":["imageUrl"],"properties":{"imageUrl":{"type":"string","format":"uri","description":"Publicly reachable image URL."},"format":{"type":"string","enum":["svg","dxf","pdf"],"default":"svg"},"engine":{"type":"string","enum":["lineart","trace"],"default":"lineart"}}}},"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary"},"format":{"type":"string","enum":["svg","dxf","pdf"],"default":"svg"},"engine":{"type":"string","enum":["lineart","trace"],"default":"lineart"}}}}}},"responses":{"200":{"description":"Vectorized file","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"format":{"type":"string"},"engine":{"type":"string"},"creditsConsumed":{"type":"integer"}}}}}}}},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"imageUrl could not be fetched","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Processing failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/enhance":{"post":{"operationId":"enhanceImage","summary":"AI super-resolution upscaling","description":"`scale` (2 or 4) controls output pixel dimensions. `dpi` (300 or 600) stamps the density metadata only. Output is PNG.","requestBody":{"required":true,"description":"Image input: send JSON with an `imageUrl` field, or multipart/form-data with a `file` field (PNG, JPEG, WebP, or TIFF, max 10 MB).","content":{"application/json":{"schema":{"type":"object","required":["imageUrl"],"properties":{"imageUrl":{"type":"string","format":"uri","description":"Publicly reachable image URL."},"scale":{"type":"integer","enum":[2,4],"default":2},"dpi":{"type":"integer","enum":[300,600],"default":300}}}},"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary"},"scale":{"type":"integer","enum":[2,4],"default":2},"dpi":{"type":"integer","enum":[300,600],"default":300}}}}}},"responses":{"200":{"description":"Enhanced image","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"scale":{"type":"integer"},"dpi":{"type":"integer"},"width":{"type":"integer"},"height":{"type":"integer"},"creditsConsumed":{"type":"integer"}}}}}}}},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"imageUrl could not be fetched","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Processing failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/convert":{"post":{"operationId":"convertImage","summary":"Convert to filing-ready raster formats (PNG / TIFF / PDF)","description":"Exports flattened, filing-oriented raster files. `dpi: 300` targets the 2K preset, `dpi: 600` the 4K preset. For vector output use /vectorize.","requestBody":{"required":true,"description":"Image input: send JSON with an `imageUrl` field, or multipart/form-data with a `file` field (PNG, JPEG, WebP, or TIFF, max 10 MB).","content":{"application/json":{"schema":{"type":"object","required":["imageUrl"],"properties":{"imageUrl":{"type":"string","format":"uri","description":"Publicly reachable image URL."},"format":{"type":"string","enum":["png","tiff","pdf"],"default":"png"},"dpi":{"type":"integer","enum":[300,600],"default":300}}}},"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary"},"format":{"type":"string","enum":["png","tiff","pdf"],"default":"png"},"dpi":{"type":"integer","enum":[300,600],"default":300}}}}}},"responses":{"200":{"description":"Converted file","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"previewUrl":{"type":"string","format":"uri","description":"PNG preview. Present for TIFF and PDF outputs."},"format":{"type":"string"},"dpi":{"type":"integer"},"creditsConsumed":{"type":"integer"}}}}}}}},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"imageUrl could not be fetched","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Processing failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/credits":{"get":{"operationId":"getCredits","summary":"Get the current credit balance","responses":{"200":{"description":"Credit balance","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"balance":{"type":"integer"}}}}}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"API key from https://patentfig.ai/settings/api-keys, e.g. \"Authorization: Bearer pfig_xxx\". The x-api-key header is also accepted."}},"schemas":{"ErrorResponse":{"type":"object","properties":{"success":{"type":"boolean","const":false},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}}}}}}}