{
  "openapi": "3.1.0",
  "info": {
    "title": "Your Model API",
    "description": "Your Model provides unified API access to GPT, Claude, Grok and selected Chinese AI models through one platform. OpenAI-compatible workflows are supported where applicable. Use GET /v1/models to discover model IDs before sending a request.",
    "version": "1.0.0",
    "contact": {
      "url": "https://y-models.com"
    }
  },
  "servers": [
    {
      "url": "https://y-models.com",
      "description": "Use the /v1 paths below. When configuring an OpenAI-compatible SDK, use https://y-models.com/v1 as its base_url or baseURL."
    }
  ],
  "externalDocs": {
    "description": "Your Model API documentation",
    "url": "https://docs.y-models.com"
  },
  "tags": [
    {
      "name": "Models",
      "description": "Discover the models available to the authenticated account."
    },
    {
      "name": "Text generation",
      "description": "OpenAI-compatible chat and Responses API operations."
    },
    {
      "name": "Video generation",
      "description": "Asynchronous video generation tasks and result retrieval."
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/v1/models": {
      "get": {
        "tags": ["Models"],
        "operationId": "listModels",
        "summary": "List available models",
        "description": "Returns the models currently available to the authenticated account. The default response uses the OpenAI model-list format. Use an ID from this response in subsequent requests; model availability can change.",
        "externalDocs": {
          "url": "https://docs.y-models.com/docs/api/models"
        },
        "responses": {
          "200": {
            "description": "Model list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelsResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "tags": ["Text generation"],
        "operationId": "createChatCompletion",
        "summary": "Create a chat completion",
        "description": "Creates a model response from a conversation. Set stream to true for a Server-Sent Events response when supported by the selected model and route. For a complete response, omit stream or set it to false.",
        "externalDocs": {
          "url": "https://docs.y-models.com/docs/api/chat-completions"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              },
              "example": {
                "model": "YOUR_MODEL_ID",
                "messages": [
                  {
                    "role": "user",
                    "content": "Hello"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat completion response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "502": {
            "$ref": "#/components/responses/BadGateway"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/responses": {
      "post": {
        "tags": ["Text generation"],
        "operationId": "createResponse",
        "summary": "Create a response",
        "description": "Creates a response using the OpenAI Responses API-compatible request format. Availability of fields depends on the selected model and route. Set stream to true only when streaming is supported by the selected route.",
        "externalDocs": {
          "url": "https://docs.y-models.com/docs/api/responses"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponsesRequest"
              },
              "example": {
                "model": "YOUR_MODEL_ID",
                "input": "Hello"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponsesResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "502": {
            "$ref": "#/components/responses/BadGateway"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/v1/video/generations": {
      "post": {
        "tags": ["Video generation"],
        "operationId": "createVideoGeneration",
        "summary": "Create a video generation task",
        "description": "Submits an asynchronous video generation task. Save the returned task_id, poll GET /v1/video/generations/{task_id} until status is completed or failed, then fetch completed content from GET /v1/videos/{task_id}/content.",
        "externalDocs": {
          "url": "https://docs.y-models.com/docs/api/video-generation"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VideoRequest"
              },
              "example": {
                "model": "YOUR_VIDEO_MODEL_ID",
                "prompt": "A paper airplane flying over a city",
                "duration": 5,
                "width": 1280,
                "height": 720
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Video task created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VideoResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/TaskError"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TaskError"
          },
          "500": {
            "$ref": "#/components/responses/TaskError"
          },
          "502": {
            "$ref": "#/components/responses/TaskError"
          },
          "503": {
            "$ref": "#/components/responses/TaskError"
          }
        }
      }
    },
    "/v1/video/generations/{task_id}": {
      "get": {
        "tags": ["Video generation"],
        "operationId": "getVideoGeneration",
        "summary": "Get video generation status",
        "description": "Returns the current status and result metadata for a video generation task. The documented statuses are queued, in_progress, completed, and failed.",
        "externalDocs": {
          "url": "https://docs.y-models.com/docs/api/video-generation"
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/TaskId"
          }
        ],
        "responses": {
          "200": {
            "description": "Video task status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VideoTaskResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/TaskError"
          },
          "500": {
            "$ref": "#/components/responses/TaskError"
          },
          "502": {
            "$ref": "#/components/responses/TaskError"
          },
          "503": {
            "$ref": "#/components/responses/TaskError"
          }
        }
      }
    },
    "/v1/videos/{task_id}/content": {
      "get": {
        "tags": ["Video generation"],
        "operationId": "getVideoContent",
        "summary": "Get completed video content",
        "description": "Returns the video file for a completed video generation task. Call this endpoint only after the status endpoint reports completed.",
        "externalDocs": {
          "url": "https://docs.y-models.com/docs/api/video-generation"
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/TaskId"
          }
        ],
        "responses": {
          "200": {
            "description": "Video file",
            "content": {
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "502": {
            "$ref": "#/components/responses/BadGateway"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key"
      }
    },
    "parameters": {
      "TaskId": {
        "name": "task_id",
        "in": "path",
        "required": true,
        "description": "Video generation task ID",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Request parameters are invalid",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Authentication failed",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Request rate limit exceeded. Limits are configured by deployment, account, token, model, or group and are not represented by a fixed number in this specification. Honor Retry-After when present and retry with bounded exponential backoff.",
        "headers": {
          "Retry-After": {
            "description": "Conservative number of seconds to wait before retrying.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "TaskError": {
        "description": "A video task or relay error. Task endpoints return a code, message, and optional data object.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/TaskErrorResponse"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The authenticated account or token is not allowed to use this resource or model.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "ServerError": {
        "description": "An internal or relay error occurred. Retry only when the operation is safe to repeat and use bounded exponential backoff.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "BadGateway": {
        "description": "An upstream provider or gateway returned an unusable response. This may be transient; retry with bounded exponential backoff when safe.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "ServiceUnavailable": {
        "description": "No usable upstream service is currently available. This may be transient; retry with bounded exponential backoff when safe.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "description": "OpenAI-style error envelope. Error messages may include a request identifier; do not parse message text as a stable error code.",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "required": ["message", "type"],
            "properties": {
              "message": {
                "type": "string",
                "description": "Human-readable error message."
              },
              "type": {
                "type": "string",
                "description": "Error family, such as invalid_request_error or new_api_error."
              },
              "param": {
                "type": ["string", "null"],
                "description": "Request parameter associated with the error, when applicable."
              },
              "code": {
                "description": "Machine-readable provider or gateway code, when supplied. Its type is provider-dependent."
              }
            }
          }
        }
      },
      "TaskErrorResponse": {
        "type": "object",
        "description": "Task endpoint error envelope.",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable task or relay error code."
          },
          "message": {
            "type": "string",
            "description": "Human-readable task error message."
          },
          "data": {
            "description": "Optional error-specific data."
          }
        }
      },
      "Model": {
        "type": "object",
        "required": ["id", "object", "owned_by"],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "model"
          },
          "created": {
            "type": "integer"
          },
          "owned_by": {
            "type": "string"
          }
        }
      },
      "ModelsResponse": {
        "type": "object",
        "required": ["object", "data"],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Model"
            }
          }
        }
      },
      "Message": {
        "type": "object",
        "required": ["role", "content"],
        "properties": {
          "role": {
            "type": "string",
            "enum": ["system", "user", "assistant", "tool", "developer"]
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            ]
          },
          "name": {
            "type": "string"
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "tool_call_id": {
            "type": "string"
          }
        }
      },
      "ChatCompletionRequest": {
        "type": "object",
        "required": ["model", "messages"],
        "properties": {
          "model": {
            "type": "string"
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Message"
            }
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2
          },
          "top_p": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "n": {
            "type": "integer",
            "minimum": 1
          },
          "stream": {
            "type": "boolean"
          },
          "stream_options": {
            "type": "object",
            "properties": {
              "include_usage": {
                "type": "boolean"
              }
            }
          },
          "stop": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "max_completion_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "presence_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2
          },
          "frequency_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2
          },
          "reasoning_effort": {
            "type": "string",
            "enum": ["low", "medium", "high"]
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "tool_choice": {
            "oneOf": [
              {
                "type": "string",
                "enum": ["none", "auto", "required"]
              },
              {
                "type": "object"
              }
            ]
          },
          "response_format": {
            "type": "object"
          },
          "user": {
            "type": "string"
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "prompt_tokens": {
            "type": "integer"
          },
          "completion_tokens": {
            "type": "integer"
          },
          "total_tokens": {
            "type": "integer"
          }
        }
      },
      "ChatCompletionResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        }
      },
      "ResponsesRequest": {
        "type": "object",
        "required": ["model"],
        "properties": {
          "model": {
            "type": "string"
          },
          "input": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            ]
          },
          "instructions": {
            "type": "string"
          },
          "max_output_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "temperature": {
            "type": "number"
          },
          "top_p": {
            "type": "number"
          },
          "stream": {
            "type": "boolean"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "tool_choice": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object"
              }
            ]
          },
          "reasoning": {
            "type": "object",
            "properties": {
              "effort": {
                "type": "string",
                "enum": ["low", "medium", "high"]
              },
              "summary": {
                "type": "string"
              }
            }
          },
          "previous_response_id": {
            "type": "string"
          },
          "truncation": {
            "type": "string",
            "enum": ["auto", "disabled"]
          }
        }
      },
      "ResponsesResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string"
          },
          "created_at": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": ["completed", "failed", "in_progress", "incomplete"]
          },
          "model": {
            "type": "string"
          },
          "output": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        }
      },
      "VideoRequest": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string"
          },
          "prompt": {
            "type": "string"
          },
          "image": {
            "type": "string"
          },
          "duration": {
            "type": "number"
          },
          "width": {
            "type": "integer"
          },
          "height": {
            "type": "integer"
          },
          "fps": {
            "type": "integer"
          },
          "seed": {
            "type": "integer"
          },
          "n": {
            "type": "integer"
          },
          "response_format": {
            "type": "string"
          },
          "user": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "VideoResponse": {
        "type": "object",
        "properties": {
          "task_id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        }
      },
      "VideoTaskResponse": {
        "type": "object",
        "properties": {
          "task_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["queued", "in_progress", "completed", "failed"]
          },
          "url": {
            "type": "string"
          },
          "format": {
            "type": "string"
          },
          "metadata": {
            "type": "object"
          },
          "error": {
            "type": "object"
          }
        }
      }
    }
  }
}
