{
  "openapi": "3.1.0",
  "info": {
    "title": "RentPrompts API",
    "version": "1.0.0",
    "summary": "One API key for every text, image, video and audio model on RentPrompts.",
    "description": "OpenAI-compatible endpoints. Pay per successful generation in Joules from your RentPrompts wallet. Docs: https://rentprompts.com/apidocs · Changelog: https://rentprompts.com/apidocs/changelog",
    "contact": {
      "name": "RentPrompts",
      "url": "https://rentprompts.com/contact-us"
    }
  },
  "servers": [
    {
      "url": "https://payload.rentprompts.com/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Generation"
    },
    {
      "name": "Jobs"
    },
    {
      "name": "Models"
    },
    {
      "name": "Account"
    }
  ],
  "paths": {
    "/chat/completions": {
      "post": {
        "tags": [
          "Generation"
        ],
        "operationId": "createChatCompletion",
        "summary": "Chat completion (text models; images as image_url parts)",
        "description": "OpenAI chat.completions format. With stream: true the response is text/event-stream of chat.completion.chunk objects ending with data: [DONE]. Live token streaming, tools and json_schema output need the model's capabilities flags.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Completion, or an SSE stream when stream is true.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/RequestId"
              },
              "x-rp-cost-joules": {
                "$ref": "#/components/headers/CostJoules"
              },
              "x-rp-balance-joules": {
                "$ref": "#/components/headers/BalanceJoules"
              },
              "x-ratelimit-limit-requests": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "x-ratelimit-remaining-requests": {
                "$ref": "#/components/headers/RateLimitRemaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletion"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "data: {chat.completion.chunk}\\n\\n … data: [DONE]"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "413": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/images/generations": {
      "post": {
        "tags": [
          "Generation"
        ],
        "operationId": "createImage",
        "summary": "Generate images",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageGenerationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Images (synchronous models).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImagesResponse"
                }
              }
            }
          },
          "202": {
            "description": "Job queued (asynchronous models).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueuedJob"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "413": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/run": {
      "post": {
        "tags": [
          "Generation"
        ],
        "operationId": "runModel",
        "summary": "Run any model (required for video and other async models)",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of a synchronous model.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunResult"
                }
              }
            }
          },
          "202": {
            "description": "Job queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueuedRun"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "413": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/jobs/{id}": {
      "get": {
        "tags": [
          "Jobs"
        ],
        "operationId": "getJob",
        "summary": "Status and output of an async job",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "job_… id or the bare job_id."
          }
        ],
        "responses": {
          "200": {
            "description": "Job.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/models": {
      "get": {
        "tags": [
          "Models"
        ],
        "operationId": "listModels",
        "summary": "List models (public, no auth)",
        "security": [],
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "text",
                "image",
                "video",
                "audio"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalog.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelList"
                }
              }
            }
          }
        }
      }
    },
    "/models/{id}": {
      "get": {
        "tags": [
          "Models"
        ],
        "operationId": "getModel",
        "summary": "One model (public, no auth)",
        "security": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Model.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Model"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/balance": {
      "get": {
        "tags": [
          "Account"
        ],
        "operationId": "getBalance",
        "summary": "Wallet balance",
        "responses": {
          "200": {
            "description": "Balance.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "balance_joules": {
                      "type": "number"
                    },
                    "currency": {
                      "const": "joules"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/usage": {
      "get": {
        "tags": [
          "Account"
        ],
        "operationId": "getUsage",
        "summary": "Usage summary for the calling key",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 30,
              "enum": [
                7,
                30,
                90
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Usage report.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "webhooks": {
    "jobFinished": {
      "post": {
        "summary": "An async job finished (sent to the `webhook` URL of the request)",
        "description": "Signed with Standard Webhooks: webhook-signature = v1,base64(HMAC-SHA256(secret, `${webhook-id}.${webhook-timestamp}.${body}`)). The secret is the key's webhook signing secret (whsec_…). Retries: 5 s, 1 min, 5 min, 30 min, 2 h, 8 h, 24 h with the same webhook-id.",
        "parameters": [
          {
            "name": "webhook-id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "webhook-timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "webhook-signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx acknowledges the event."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "rp_live_… key from /dashboard/api-keys"
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "maxLength": 128
        },
        "description": "Retry safely: the same key within 24 hours is never charged twice."
      }
    },
    "headers": {
      "RequestId": {
        "description": "Unique id of the request.",
        "schema": {
          "type": "string"
        }
      },
      "CostJoules": {
        "description": "What this request cost (JSON responses).",
        "schema": {
          "type": "string"
        }
      },
      "BalanceJoules": {
        "description": "Wallet balance after the request (JSON responses).",
        "schema": {
          "type": "string"
        }
      },
      "RateLimitLimit": {
        "description": "Requests allowed per minute for this key.",
        "schema": {
          "type": "string"
        }
      },
      "RateLimitRemaining": {
        "description": "Requests left in the current minute.",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error envelope.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "type",
              "code",
              "message"
            ],
            "properties": {
              "type": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "param": {
                "type": "string"
              }
            }
          }
        }
      },
      "Message": {
        "type": "object",
        "required": [
          "role"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "developer",
              "user",
              "assistant",
              "tool"
            ]
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              },
              {
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "type",
                        "text"
                      ],
                      "properties": {
                        "type": {
                          "const": "text"
                        },
                        "text": {
                          "type": "string"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "type",
                        "image_url"
                      ],
                      "properties": {
                        "type": {
                          "const": "image_url"
                        },
                        "image_url": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string"
                            },
                            "detail": {
                              "enum": [
                                "auto",
                                "low",
                                "high"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            ]
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ToolCall"
            }
          },
          "tool_call_id": {
            "type": "string"
          }
        }
      },
      "Tool": {
        "type": "object",
        "required": [
          "type",
          "function"
        ],
        "properties": {
          "type": {
            "const": "function"
          },
          "function": {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string",
                "pattern": "^[a-zA-Z0-9_-]{1,64}$"
              },
              "description": {
                "type": "string"
              },
              "parameters": {
                "type": "object"
              },
              "strict": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "ToolCall": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "const": "function"
          },
          "function": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "arguments": {
                "type": "string"
              }
            }
          }
        }
      },
      "ChatCompletionRequest": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "Model id from GET /v1/models.",
            "examples": [
              "minimax-m27"
            ]
          },
          "messages": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "items": {
              "$ref": "#/components/schemas/Message"
            }
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "stream_options": {
            "type": "object",
            "properties": {
              "include_usage": {
                "type": "boolean"
              }
            }
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1,
            "maximum": 8192,
            "default": 1024
          },
          "max_completion_tokens": {
            "type": "integer",
            "minimum": 1,
            "maximum": 8192
          },
          "temperature": {
            "type": "number"
          },
          "top_p": {
            "type": "number"
          },
          "presence_penalty": {
            "type": "number"
          },
          "frequency_penalty": {
            "type": "number"
          },
          "seed": {
            "type": "integer"
          },
          "stop": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "maxItems": 4
              }
            ]
          },
          "tools": {
            "type": "array",
            "maxItems": 128,
            "items": {
              "$ref": "#/components/schemas/Tool"
            }
          },
          "tool_choice": {
            "oneOf": [
              {
                "enum": [
                  "none",
                  "auto",
                  "required"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "const": "function"
                  },
                  "function": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            ]
          },
          "parallel_tool_calls": {
            "type": "boolean"
          },
          "response_format": {
            "type": "object",
            "properties": {
              "type": {
                "enum": [
                  "text",
                  "json_object",
                  "json_schema"
                ]
              },
              "json_schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "schema": {
                    "type": "object"
                  },
                  "strict": {
                    "type": "boolean"
                  }
                }
              }
            }
          },
          "reasoning_effort": {
            "enum": [
              "minimal",
              "low",
              "medium",
              "high"
            ]
          },
          "settings": {
            "type": "object",
            "description": "Model-specific settings listed in GET /v1/models/{id}."
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "prompt_tokens": {
            "type": "integer"
          },
          "completion_tokens": {
            "type": "integer"
          },
          "total_tokens": {
            "type": "integer"
          }
        }
      },
      "RentpromptsMeta": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string"
          },
          "cost_joules": {
            "type": "number"
          },
          "balance_joules": {
            "type": "number"
          }
        }
      },
      "ChatCompletion": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "chat.completion"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "message": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "const": "assistant"
                    },
                    "content": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "tool_calls": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ToolCall"
                      }
                    }
                  }
                },
                "finish_reason": {
                  "enum": [
                    "stop",
                    "length",
                    "tool_calls",
                    "content_filter"
                  ]
                }
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "rentprompts": {
            "$ref": "#/components/schemas/RentpromptsMeta"
          }
        }
      },
      "ImageGenerationRequest": {
        "type": "object",
        "required": [
          "model",
          "prompt"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "Model id from GET /v1/models.",
            "examples": [
              "kling-image-v3"
            ]
          },
          "prompt": {
            "type": "string"
          },
          "n": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10
          },
          "size": {
            "type": "string",
            "examples": [
              "1024x1024"
            ]
          },
          "quality": {
            "type": "string"
          },
          "negative_prompt": {
            "type": "string"
          },
          "image": {
            "type": "string",
            "description": "Input image: public https URL or data URI (≤ 15 MB)."
          },
          "webhook": {
            "type": "string",
            "format": "uri",
            "description": "Async models only: where to POST the signed job event."
          },
          "settings": {
            "type": "object"
          }
        }
      },
      "ImagesResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "integer"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string"
                }
              }
            }
          },
          "rentprompts": {
            "$ref": "#/components/schemas/RentpromptsMeta"
          }
        }
      },
      "RunRequest": {
        "type": "object",
        "required": [
          "model"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "Model id from GET /v1/models.",
            "examples": [
              "minimax-m27"
            ]
          },
          "prompt": {
            "type": "string"
          },
          "system": {
            "type": "string"
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Message"
            }
          },
          "negative_prompt": {
            "type": "string"
          },
          "image": {
            "type": "string"
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 8
          },
          "video": {
            "type": "string"
          },
          "audio": {
            "type": "string"
          },
          "webhook": {
            "type": "string",
            "format": "uri"
          },
          "settings": {
            "type": "object"
          }
        }
      },
      "RunResult": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "data": {},
          "urls": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "usage": {
            "type": "object"
          },
          "request_id": {
            "type": "string"
          },
          "cost_joules": {
            "type": "number"
          },
          "balance_remaining": {
            "type": "number"
          }
        }
      },
      "QueuedJob": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "job"
          },
          "status": {
            "const": "queued"
          },
          "poll_url": {
            "type": "string"
          },
          "webhook": {
            "type": [
              "string",
              "null"
            ]
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "QueuedRun": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "status": {
            "const": "queued"
          },
          "job_id": {
            "type": "string"
          },
          "poll_url": {
            "type": "string"
          },
          "webhook": {
            "type": [
              "string",
              "null"
            ]
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "job"
          },
          "status": {
            "enum": [
              "queued",
              "processing",
              "succeeded",
              "failed"
            ]
          },
          "model": {
            "type": "string"
          },
          "output": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "url": {
                "type": "string"
              },
              "urls": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "cost_joules": {
            "type": [
              "number",
              "null"
            ]
          },
          "error": {
            "type": "string"
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "type": {
            "enum": [
              "job.succeeded",
              "job.failed"
            ]
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/Job"
          }
        }
      },
      "Model": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "model"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "enum": [
              "text",
              "image",
              "video",
              "audio"
            ]
          },
          "endpoint": {
            "type": "string"
          },
          "async": {
            "type": "boolean"
          },
          "capabilities": {
            "type": "object",
            "properties": {
              "streaming": {
                "type": "boolean"
              },
              "tools": {
                "type": "boolean"
              },
              "json_schema": {
                "type": "boolean"
              },
              "webhooks": {
                "type": "boolean"
              }
            }
          },
          "pricing": {
            "type": "object"
          },
          "settings": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "ModelList": {
        "type": "object",
        "properties": {
          "object": {
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Model"
            }
          }
        }
      }
    }
  }
}