{"openapi":"3.1.0","info":{"title":"AISwapLab Developer API","version":"1.2.0","description":"Credit-based video, image and non-streaming chat. Images/videos use asynchronous jobs. Chat returns a completion when confirmed, or a durable job if uncertain. Not a drop-in OpenAI SDK replacement. Check GET /models first."},"servers":[{"url":"https://aiswaplab.com/api/v1"}],"security":[{"bearerAuth":[]}],"paths":{"/models":{"get":{"summary":"List model aliases and current availability","responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","enum":["minimax-h3","gpt-image-2","gpt-image-2.5","gpt-image-2.6","nano-banana-2.1","deepseek-v4.1-flash"]},"upstream_model":{"type":["string","null"]},"available":{"type":"boolean"},"reason":{"type":["string","null"]},"sizes":{"type":"array","items":{"type":"string"}}}}}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Invalid, expired or revoked key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Model not allowed or monthly cap exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Owned resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency conflict, credit limit or result not ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request, file or storage limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate, concurrency or daily budget limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Model, generation or storage is not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/quotes":{"post":{"summary":"Preview maximum credits without generating","requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"type":"object","additionalProperties":false,"required":["model","prompt","seconds","max_credits"],"properties":{"model":{"const":"minimax-h3"},"prompt":{"type":"string","minLength":1,"maxLength":4000},"seconds":{"type":"integer","minimum":4,"maximum":15},"size":{"type":"string","enum":["480x864","768x1376","1088x1920","864x480","1376x768","1920x1088","640x640","1024x1024","1440x1440","544x800","832x1248","1184x1760","800x544","1248x832","1760x1184","576x736","896x1184","1248x1664","736x576","1184x896","1664x1248","992x416","1568x672","2208x960","2K"],"default":"864x480"},"input_image_id":{"type":"string","format":"uuid"},"reference_video_id":{"type":"string","format":"uuid"},"max_credits":{"type":"number","minimum":0.01,"maximum":5000000,"multipleOf":0.01}}},{"type":"object","additionalProperties":false,"required":["model","prompt","max_credits"],"properties":{"model":{"type":"string","enum":["gpt-image-2","gpt-image-2.5","gpt-image-2.6","nano-banana-2.1"]},"prompt":{"type":"string","minLength":1,"maxLength":4000},"size":{"type":"string","enum":["1024x1024","1536x1024","1024x1536","2048x2048","4096x4096","1K","2K","4K"],"default":"1024x1024"},"quality":{"type":"string","enum":["low","medium","high"],"default":"medium"},"n":{"type":"integer","const":1},"max_credits":{"type":"number","minimum":0.01,"maximum":5000000,"multipleOf":0.01}}},{"type":"object","additionalProperties":false,"required":["model","messages","max_credits"],"properties":{"model":{"const":"deepseek-v4.1-flash"},"messages":{"type":"array","minItems":1,"maxItems":32,"items":{"type":"object","additionalProperties":false,"required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant"]},"content":{"type":"string","minLength":1}}}},"max_tokens":{"type":"integer","minimum":1,"maximum":4096,"default":256},"temperature":{"type":"number","minimum":0,"maximum":2},"stream":{"const":false},"max_credits":{"type":"number","minimum":0.01,"maximum":5000000,"multipleOf":0.01}}}]}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"model":{"type":"string","enum":["minimax-h3","gpt-image-2","gpt-image-2.5","gpt-image-2.6","nano-banana-2.1","deepseek-v4.1-flash"]},"credit_version":{"const":"v4"},"credits":{"type":"number"},"balance":{"type":"number"},"price_usd":{"type":"number","description":"USD list price before bulk-pack discount; text is a maximum reservation."},"usd_list_credit_value":{"type":"number"},"currency":{"const":"credits"}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Invalid, expired or revoked key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Model not allowed or monthly cap exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Owned resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency conflict, credit limit or result not ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request, file or storage limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate, concurrency or daily budget limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Model, generation or storage is not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/videos":{"post":{"summary":"Submit one asynchronous generation","parameters":[{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string","minLength":8,"maxLength":128}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["model","prompt","seconds","max_credits"],"properties":{"model":{"const":"minimax-h3"},"prompt":{"type":"string","minLength":1,"maxLength":4000},"seconds":{"type":"integer","minimum":4,"maximum":15},"size":{"type":"string","enum":["480x864","768x1376","1088x1920","864x480","1376x768","1920x1088","640x640","1024x1024","1440x1440","544x800","832x1248","1184x1760","800x544","1248x832","1760x1184","576x736","896x1184","1248x1664","736x576","1184x896","1664x1248","992x416","1568x672","2208x960","2K"],"default":"864x480"},"input_image_id":{"type":"string","format":"uuid"},"reference_video_id":{"type":"string","format":"uuid"},"max_credits":{"type":"number","minimum":0.01,"maximum":5000000,"multipleOf":0.01}}}}}},"responses":{"200":{"description":"Idempotent replay.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"202":{"description":"Accepted; poll the returned job URL.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Invalid, expired or revoked key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Model not allowed or monthly cap exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Owned resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency conflict, credit limit or result not ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request, file or storage limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate, concurrency or daily budget limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Model, generation or storage is not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/images/generations":{"post":{"summary":"Submit one asynchronous generation","parameters":[{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string","minLength":8,"maxLength":128}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["model","prompt","max_credits"],"properties":{"model":{"type":"string","enum":["gpt-image-2","gpt-image-2.5","gpt-image-2.6","nano-banana-2.1"]},"prompt":{"type":"string","minLength":1,"maxLength":4000},"size":{"type":"string","enum":["1024x1024","1536x1024","1024x1536","2048x2048","4096x4096","1K","2K","4K"],"default":"1024x1024"},"quality":{"type":"string","enum":["low","medium","high"],"default":"medium"},"n":{"type":"integer","const":1},"max_credits":{"type":"number","minimum":0.01,"maximum":5000000,"multipleOf":0.01}}}}}},"responses":{"200":{"description":"Idempotent replay.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"202":{"description":"Accepted; poll the returned job URL.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Invalid, expired or revoked key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Model not allowed or monthly cap exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Owned resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency conflict, credit limit or result not ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request, file or storage limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate, concurrency or daily budget limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Model, generation or storage is not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/chat/completions":{"post":{"summary":"Non-streaming text chat; reserve a ceiling, then settle measured token usage","parameters":[{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string","minLength":8,"maxLength":128}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["model","messages","max_credits"],"properties":{"model":{"const":"deepseek-v4.1-flash"},"messages":{"type":"array","minItems":1,"maxItems":32,"items":{"type":"object","additionalProperties":false,"required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant"]},"content":{"type":"string","minLength":1}}}},"max_tokens":{"type":"integer","minimum":1,"maximum":4096,"default":256},"temperature":{"type":"number","minimum":0,"maximum":2},"stream":{"const":false},"max_credits":{"type":"number","minimum":0.01,"maximum":5000000,"multipleOf":0.01}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"chat.completion"},"model":{"type":"string","enum":["minimax-h3","gpt-image-2","gpt-image-2.5","gpt-image-2.6","nano-banana-2.1","deepseek-v4.1-flash"]},"choices":{"type":"array","items":{"type":"object"}},"usage":{"type":"object"},"aiswaplab":{"type":"object"}}}}}},"202":{"description":"Outcome not yet confirmed; retain the job and do not submit a new paid task.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Invalid, expired or revoked key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Model not allowed or monthly cap exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Owned resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency conflict, credit limit or result not ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request, file or storage limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate, concurrency or daily budget limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Model, generation or storage is not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/files":{"post":{"summary":"Upload an owned reference: 8 MB image or 20 MB MP4 (4-15 seconds)","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file","kind"],"properties":{"file":{"type":"string","format":"binary"},"kind":{"type":"string","enum":["photo","reference"]}}}}}},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"seconds":{"type":["number","null"]}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Invalid, expired or revoked key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Model not allowed or monthly cap exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Owned resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency conflict, credit limit or result not ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request, file or storage limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate, concurrency or daily budget limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Model, generation or storage is not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/jobs/{id}":{"get":{"summary":"Poll an owned job; never resubmits generation","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Invalid, expired or revoked key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Model not allowed or monthly cap exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Owned resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency conflict, credit limit or result not ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request, file or storage limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate, concurrency or daily budget limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Model, generation or storage is not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/jobs/{id}/content":{"get":{"summary":"Download a completed image, MP4 or chat JSON privately","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}},{"in":"header","name":"Range","schema":{"type":"string","example":"bytes=0-1023"}}],"responses":{"200":{"description":"Private media or JSON attachment","content":{"image/png":{"schema":{"type":"string","format":"binary"}},"video/mp4":{"schema":{"type":"string","format":"binary"}},"image/jpeg":{"schema":{"type":"string","format":"binary"}},"image/webp":{"schema":{"type":"string","format":"binary"}},"application/json":{"schema":{"type":"object"}}}},"206":{"description":"Partial content"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Invalid, expired or revoked key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Model not allowed or monthly cap exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Owned resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency conflict, credit limit or result not ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request, file or storage limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"416":{"description":"Invalid byte range"},"429":{"description":"Rate, concurrency or daily budget limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Model, generation or storage is not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/usage":{"get":{"summary":"Credit balance, this key’s UTC calendar-month allowance and recent jobs","responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"balance":{"type":"number","multipleOf":0.000001},"monthly_limit":{"type":"integer"},"monthly_used":{"type":"number","multipleOf":0.000001},"jobs":{"type":"array","items":{"$ref":"#/components/schemas/Job"}}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Invalid, expired or revoked key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Model not allowed or monthly cap exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Owned resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency conflict, credit limit or result not ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request, file or storage limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate, concurrency or daily budget limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Model, generation or storage is not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"asl_…"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}}}},"Job":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"generation"},"model":{"type":"string","enum":["minimax-h3","gpt-image-2","gpt-image-2.5","gpt-image-2.6","nano-banana-2.1","deepseek-v4.1-flash"]},"status":{"type":"string","enum":["queued","submitting","running","unknown","saving","completed","failed"]},"credits":{"type":"number","multipleOf":0.000001},"reserved_credits":{"type":"number","multipleOf":0.000001},"kind":{"type":"string","enum":["image","video","text"]},"usage":{"type":["object","null"]},"error":{"type":["string","null"]},"poll_url":{"type":"string"},"content_url":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}}}}}}