{
  "openapi": "3.1.0",
  "info": {
    "title": "Apily /v1 gateway",
    "version": "1.0.0",
    "description": "Public AI gateway. Send an Apily API key as a bearer token. Each operation below is a route on this server. The gateway checks only the fields listed as required and forwards every other property to the provider. Account, billing, and admin routes are not part of this document."
  },
  "servers": [
    {
      "url": "https://apily.pro/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Apily API key in the Authorization header: Bearer <key>."
      }
    },
    "schemas": {
      "GatewayJsonBody": {
        "type": "object",
        "description": "JSON body. The gateway requires model and, when present, checks stream and the output-token limits. Every other property is forwarded.",
        "required": ["model"],
        "properties": {
          "model": {
            "type": "string",
            "minLength": 1
          },
          "stream": {
            "type": "boolean"
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1
          },
          "max_completion_tokens": {
            "type": "integer",
            "minimum": 1
          },
          "max_output_tokens": {
            "type": "integer",
            "minimum": 1
          }
        },
        "additionalProperties": true
      },
      "GatewayModelBody": {
        "type": "object",
        "description": "JSON or multipart body. The gateway requires model and forwards every other field, including file parts.",
        "required": ["model"],
        "properties": {
          "model": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": true
      }
    },
    "responses": {
      "GatewaySuccess": {
        "description": "Provider response forwarded by the gateway."
      },
      "MissingApiKey": {
        "description": "Missing or unknown API key."
      }
    },
    "parameters": {
      "VideoId": {
        "name": "videoId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    }
  },
  "paths": {
    "/models": {
      "get": {
        "operationId": "listModels",
        "summary": "List model ids",
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "summary": "Chat completions",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayJsonBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/responses": {
      "post": {
        "operationId": "createResponse",
        "summary": "Responses",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayJsonBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/embeddings": {
      "post": {
        "operationId": "createEmbedding",
        "summary": "Embeddings",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayJsonBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/completions": {
      "post": {
        "operationId": "createCompletion",
        "summary": "Legacy completions",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayJsonBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/rerank": {
      "post": {
        "operationId": "createRerank",
        "summary": "Rerank",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayJsonBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/systemone": {
      "post": {
        "operationId": "createSystemone",
        "summary": "System One",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayJsonBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/images/generations": {
      "post": {
        "operationId": "createImage",
        "summary": "Image generation",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayJsonBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/images/edits": {
      "post": {
        "operationId": "editImage",
        "summary": "Image edits",
        "description": "Accepts JSON or multipart. The gateway requires model and forwards every other field, including file parts.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayModelBody" }
            },
            "multipart/form-data": {
              "schema": { "$ref": "#/components/schemas/GatewayModelBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/audio/speech": {
      "post": {
        "operationId": "createSpeech",
        "summary": "Text to speech",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayJsonBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/audio/transcriptions": {
      "post": {
        "operationId": "createTranscription",
        "summary": "Speech to text",
        "description": "Accepts JSON or multipart. The gateway requires model and forwards every other field, including the file part.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayModelBody" }
            },
            "multipart/form-data": {
              "schema": { "$ref": "#/components/schemas/GatewayModelBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/videos": {
      "post": {
        "operationId": "createVideo",
        "summary": "Video generation",
        "description": "Accepts JSON or multipart. The gateway requires model and forwards every other field, including the file part.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayModelBody" }
            },
            "multipart/form-data": {
              "schema": { "$ref": "#/components/schemas/GatewayModelBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/videos/{videoId}": {
      "get": {
        "operationId": "retrieveVideo",
        "summary": "Video task status",
        "parameters": [
          { "$ref": "#/components/parameters/VideoId" }
        ],
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/videos/{videoId}/content": {
      "get": {
        "operationId": "downloadVideoContent",
        "summary": "Video content",
        "parameters": [
          { "$ref": "#/components/parameters/VideoId" },
          {
            "name": "variant",
            "in": "query",
            "required": false,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    },
    "/messages": {
      "post": {
        "operationId": "createMessage",
        "summary": "Anthropic-compatible messages",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/GatewayJsonBody" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/GatewaySuccess" },
          "401": { "$ref": "#/components/responses/MissingApiKey" }
        }
      }
    }
  }
}
