{
  "openapi": "3.1.0",
  "info": {
    "title": "Artguru Open API",
    "version": "1.0.0",
    "description": "Artguru Open API. Obtain x-api-key via the Authentication section."
  },
  "tags": [
    {
      "name": "Account",
      "description": "Credits and API usage for your API key."
    },
    {
      "name": "Images",
      "description": "Upload source images for generation."
    },
    {
      "name": "Generation",
      "description": "Create generation tasks and poll their status."
    }
  ],
  "paths": {
    "/api/v1/credits": {
      "get": {
        "summary": "Check Your Credits",
        "deprecated": false,
        "description": "This API allows you to retrieve the Token balance of a user account, including total and remaining Tokens",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "totalCredit": {
                          "type": "integer"
                        },
                        "usedCredit": {
                          "type": "integer"
                        },
                        "remainingCredit": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "totalCredit",
                        "usedCredit",
                        "remainingCredit"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "data"
                  ]
                },
                "example": {
                  "code": 0,
                  "message": "success",
                  "data": {
                    "totalCredit": 1000,
                    "usedCredit": 0,
                    "remainingCredit": 1000
                  }
                }
              }
            },
            "headers": {}
          }
        }
      }
    },
    "/api/v1/image/upload": {
      "post": {
        "summary": "Upload Image",
        "deprecated": false,
        "description": "Upload an image for processing",
        "tags": [
          "Images"
        ],
        "parameters": [
          {
            "name": "Content-Type",
            "in": "header",
            "description": "",
            "required": true,
            "example": "multipart/form-data",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "image": {
                    "description": "A binary file.",
                    "type": "string",
                    "format": "binary"
                  }
                },
                "required": [
                  "image"
                ]
              },
              "example": {
                "image": ""
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "status code"
                    },
                    "message": {
                      "type": "string",
                      "description": "reqeust message"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "imageUrl": {
                          "type": "string",
                          "description": "image url"
                        }
                      },
                      "required": [
                        "imageUrl"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "data"
                  ]
                },
                "example": {
                  "code": 0,
                  "message": "success",
                  "data": {
                    "imageUrl": "https://img.artguru.ai/image/aigc/web%26p%262b56c03baf2a79d683eefe3edea15fb2.webp"
                  }
                }
              }
            },
            "headers": {}
          }
        }
      }
    },
    "/api/v1/enhance/generate": {
      "post": {
        "summary": "Photo Enhance",
        "deprecated": false,
        "description": "",
        "tags": [
          "Generation"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "image": {
                    "type": "string",
                    "description": "Only image URLs are accepted (HTTPS preferred); base64 is not allowed.\nSupported formats include JPG, PNG, WEBP and JPEG."
                  }
                },
                "required": [
                  "image"
                ]
              },
              "example": {
                "image": "https://img.artguru.ai/image/aigc/web%26p%262b56c03baf2a76d683eefe3edee15fb6.webp?expires=1755917270"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "parentTaskId": {
                          "type": "string"
                        },
                        "tasks": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string"
                              },
                              "asyncTaskQueueVO": {
                                "type": "object",
                                "properties": {
                                  "rank": {
                                    "type": "integer"
                                  },
                                  "waitTime": {
                                    "type": "integer"
                                  }
                                },
                                "required": [
                                  "rank",
                                  "waitTime"
                                ]
                              }
                            }
                          }
                        },
                        "queueStatus": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "parentTaskId",
                        "tasks",
                        "queueStatus"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "data"
                  ]
                },
                "examples": {
                  "1": {
                    "summary": "Success",
                    "value": {
                      "code": 0,
                      "message": "success",
                      "data": {
                        "parentTaskId": "1884827201313509376",
                        "tasks": [
                          {
                            "taskId": "1884827452166443008",
                            "asyncTaskQueueVO": {
                              "rank": 1,
                              "waitTime": 10000
                            }
                          }
                        ],
                        "queueStatus": "PENDING"
                      }
                    }
                  },
                  "2": {
                    "summary": "UNSUB",
                    "value": {
                      "code": 24403,
                      "message": "not subscribed or out of the subscription period"
                    }
                  }
                }
              }
            },
            "headers": {}
          }
        }
      }
    },
    "/api/v1/image2image/generate": {
      "post": {
        "summary": "Image to Image",
        "deprecated": false,
        "description": "",
        "tags": [
          "Generation"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "image": {
                    "type": "string",
                    "description": "Only image URLs are accepted (HTTPS preferred); base64 is not allowed.\nSupported formats include JPG, PNG, WEBP and JPEG."
                  },
                  "style": {
                    "type": "string",
                    "description": "Used to specify the specific style template for generating the image. Refer to the template table for available options."
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "negativePrompt": {
                    "type": "string"
                  }
                },
                "required": [
                  "image",
                  "style"
                ]
              },
              "example": {
                "image": "https://img.artguru.ai/image/xxx.png",
                "style": "anime",
                "prompt": "a girl",
                "negativePrompt": "a man"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "asyncTaskQueueVO": {
                          "type": "object",
                          "properties": {
                            "rank": {
                              "type": "integer"
                            },
                            "waitTime": {
                              "type": "integer"
                            },
                            "asyncTaskId": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "rank",
                            "waitTime",
                            "asyncTaskId"
                          ]
                        }
                      },
                      "required": [
                        "asyncTaskQueueVO"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "data"
                  ]
                },
                "examples": {
                  "1": {
                    "summary": "Success",
                    "value": {
                      "code": 0,
                      "message": "success",
                      "data": {
                        "asyncTaskQueueVO": {
                          "rank": 1,
                          "waitTime": 9000,
                          "asyncTaskId": 130516270
                        }
                      }
                    }
                  },
                  "2": {
                    "summary": "UNSUB",
                    "value": {
                      "code": 24403,
                      "message": "not subscribed or out of the subscription period"
                    }
                  }
                }
              }
            },
            "headers": {}
          }
        }
      }
    },
    "/api/v1/tasks/{businessType}/{taskId}": {
      "get": {
        "summary": "Get Task Status",
        "deprecated": false,
        "description": "Poll a task created by /api/v1/enhance/generate or /api/v1/image2image/generate until status reaches a terminal value (SUCCESS, FAIL, or ERROR). Path must use parameters, e.g. /api/v1/tasks/ENHANCE/{taskId}. On SUCCESS, read data.generateUrl.",
        "tags": [
          "Generation"
        ],
        "parameters": [
          {
            "name": "businessType",
            "in": "path",
            "required": true,
            "description": "ENHANCE for Photo Enhance; IMAGE_TO_IMAGE for Image to Image.",
            "schema": {
              "type": "string",
              "enum": [
                "ENHANCE",
                "IMAGE_TO_IMAGE",
                "UNBLUR",
                "RESTORE",
                "UPSCALE"
              ]
            },
            "example": "ENHANCE"
          },
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "description": "Task id returned by the create endpoint.",
            "schema": {
              "type": "string"
            },
            "example": "1884827452166443008"
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "taskId": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "REQUESTED",
                            "PENDING",
                            "SUCCESS",
                            "FAIL",
                            "ERROR",
                            "OTHER"
                          ],
                          "description": "REQUESTED = created but not yet processed; PENDING = queued/running; SUCCESS = complete, generateUrl populated; FAIL = failed, safe to retry; ERROR = failed, not retryable; OTHER = unrecognized status."
                        },
                        "creation": {
                          "type": "integer",
                          "description": "A Unix timestamp in milliseconds (13 digits)."
                        },
                        "generateUrl": {
                          "type": "string",
                          "description": "Final result image URL when status is SUCCESS."
                        }
                      },
                      "required": [
                        "taskId",
                        "generateUrl",
                        "status",
                        "creation"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "data"
                  ]
                },
                "example": {
                  "code": 0,
                  "message": "success",
                  "data": {
                    "taskId": "1884827452166443008",
                    "status": "SUCCESS",
                    "creation": 1761887276000,
                    "generateUrl": "https://img.artguru.ai/image/aigc/example.webp"
                  }
                }
              }
            },
            "headers": {}
          }
        }
      }
    },
    "/api/v1/usage": {
      "get": {
        "summary": "Check API Usage",
        "deprecated": false,
        "description": "Returns remaining per-minute and per-hour call quotas for this API key and the global service limits.",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "apiKey": {
                          "type": "string"
                        },
                        "userId": {
                          "type": "string"
                        },
                        "minuteRemaining": {
                          "type": "integer"
                        },
                        "hourRemaining": {
                          "type": "integer"
                        },
                        "globalMinuteRemaining": {
                          "type": "integer"
                        },
                        "globalHourRemaining": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "apiKey",
                        "userId",
                        "minuteRemaining",
                        "hourRemaining",
                        "globalMinuteRemaining",
                        "globalHourRemaining"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "data"
                  ]
                },
                "example": {
                  "code": 0,
                  "message": "success",
                  "data": {
                    "apiKey": "ak-****",
                    "userId": "6412a1f3c9d4e2b1a0f9c8d7",
                    "minuteRemaining": 97,
                    "hourRemaining": 940,
                    "globalMinuteRemaining": 9876,
                    "globalHourRemaining": 48210
                  }
                }
              }
            },
            "headers": {}
          }
        }
      }
    }
  },
  "webhooks": {},
  "components": {
    "schemas": {},
    "responses": {},
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "API key obtained via the Artguru Open API Platform / Authentication docs."
      }
    }
  },
  "servers": [
    {
      "url": "https://api.artguru.ai",
      "description": "Prod Env"
    },
    {
      "url": "https://staging.api.artguru.ai",
      "description": "Testing Env"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ]
}
