{
  "openapi": "3.1.0",
  "info": {
    "title": "ai-repeater OpenAI-compatible API",
    "version": "1.0.0",
    "description": "Supported subset: models list/retrieve, Chat Completions and stateless Responses, JSON and SSE. Not the complete OpenAI API. Read /docs.do for examples, stream errors, billing extensions and limitations."
  },
  "servers": [
    {
      "url": "/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/models": {
      "get": {
        "operationId": "listModels",
        "summary": "List enabled and priced public models",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "object",
                    "data"
                  ],
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Model"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "OpenAI-shaped error; HTTP 402 is an ai-repeater billing extension",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/models/{model}": {
      "get": {
        "operationId": "retrieveModel",
        "summary": "Retrieve one available public model",
        "parameters": [
          {
            "name": "model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Model"
                }
              }
            }
          },
          "default": {
            "description": "OpenAI-shaped error; HTTP 402 is an ai-repeater billing extension",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "summary": "createChatCompletion",
        "description": "Set stream=true for SSE. Generation requests are not automatically retried. Responses is stateless only; store=true/background=true/conversation/previous_response_id are unsupported. Other capabilities depend on the chosen channel model.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletion"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "example": "data: {...}\n\n"
              }
            }
          },
          "default": {
            "description": "OpenAI-shaped error; HTTP 402 is an ai-repeater billing extension",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/responses": {
      "post": {
        "operationId": "createResponse",
        "summary": "createResponse",
        "description": "Set stream=true for SSE. Generation requests are not automatically retried. Responses is stateless only; store=true/background=true/conversation/previous_response_id are unsupported. Other capabilities depend on the chosen channel model.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponsesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Response"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "example": "data: {...}\n\n"
              }
            }
          },
          "default": {
            "description": "OpenAI-shaped error; HTTP 402 is an ai-repeater billing extension",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Model": {
        "type": "object",
        "required": [
          "id",
          "object",
          "created",
          "owned_by"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "model"
          },
          "created": {
            "type": "integer"
          },
          "owned_by": {
            "type": "string"
          },
          "shutdown_date": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "message",
              "type",
              "code",
              "param"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "code": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "param": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      },
      "ChatRequest": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string"
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "role"
              ],
              "properties": {
                "role": {
                  "type": "string"
                },
                "content": {}
              }
            }
          },
          "stream": {
            "type": [
              "boolean",
              "null"
            ],
            "default": false
          },
          "stream_options": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "include_usage": {
                "type": "boolean"
              },
              "include_obfuscation": {
                "type": "boolean"
              }
            }
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "tool_choice": {},
          "response_format": {
            "type": "object"
          }
        },
        "additionalProperties": true
      },
      "ResponsesRequest": {
        "type": "object",
        "required": [
          "model"
        ],
        "properties": {
          "model": {
            "type": "string"
          },
          "input": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            ]
          },
          "instructions": {
            "type": [
              "string",
              "null"
            ]
          },
          "stream": {
            "type": [
              "boolean",
              "null"
            ],
            "default": false
          },
          "store": {
            "type": [
              "boolean",
              "null"
            ],
            "enum": [
              false,
              null
            ],
            "default": false
          },
          "background": {
            "type": [
              "boolean",
              "null"
            ],
            "enum": [
              false,
              null
            ]
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "text": {
            "type": "object"
          },
          "previous_response_id": {
            "type": "null"
          },
          "conversation": {
            "type": "null"
          }
        },
        "additionalProperties": true
      },
      "ChatCompletion": {
        "type": "object",
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "chat.completion"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "usage": {
            "type": [
              "object",
              "null"
            ]
          }
        },
        "additionalProperties": true
      },
      "Response": {
        "type": "object",
        "required": [
          "id",
          "object",
          "created_at",
          "status",
          "model",
          "output"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "response"
          },
          "created_at": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "output": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "usage": {
            "type": [
              "object",
              "null"
            ]
          }
        },
        "additionalProperties": true
      }
    }
  }
}
