openapi: 3.1.0
info:
  title: "蛋蛋 API"
  version: 1.0.0
  description: "API routes for OpenAI-compatible, Responses, Anthropic Messages, Gemini v1beta, image, video, and Antigravity requests through Portdan."
servers:
  - url: "https://portdan.com"
    description: Root address. Add /v1 or /v1beta only when the client or protocol requires it.
security:
  - bearerAuth: []
paths:
  /v1/models:
    get:
      summary: List models available to the current OpenAI-compatible or Anthropic-compatible group
      responses:
        '200':
          description: Model list
  /v1/chat/completions:
    post:
      summary: Create a chat completion through the OpenAI-compatible route
      responses:
        '200':
          description: Chat completion result
  /v1/responses:
    post:
      summary: Create a Responses API result through the /v1 route
      responses:
        '200':
          description: Responses API result
  /responses:
    post:
      summary: Create a Responses API result through the root Codex-compatible path
      responses:
        '200':
          description: Responses API result
  /backend-api/codex/responses:
    post:
      summary: Codex direct-compatible route
      responses:
        '200':
          description: Responses API result
  /v1/embeddings:
    post:
      summary: Create embeddings on an OpenAI-compatible group
      responses:
        '200':
          description: Embedding result
  /v1/messages:
    post:
      summary: Anthropic Messages-compatible route
      responses:
        '200':
          description: Anthropic-compatible message result
  /v1beta/models:
    get:
      summary: Gemini model list
      security:
        - googleApiKey: []
      responses:
        '200':
          description: Gemini-compatible model list
  /v1beta/models/{model}:generateContent:
    post:
      summary: Gemini generateContent
      security:
        - googleApiKey: []
      parameters:
        - name: model
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Gemini-compatible result
  /v1/images/generations:
    post:
      summary: Generate an image with GPT Image or Seedream
      description: Use an image-enabled OpenAI key group and copy the exact model ID from /v1/models.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGeneration'
      responses:
        '200':
          description: Image result. Read data[].b64_json or data[].url.
  /v1/images/edits:
    post:
      summary: Generate an image using reference images with GPT Image or Seedream
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [model, prompt]
              properties:
                model: {type: string}
                prompt: {type: string}
                image: {type: string, format: binary}
                'image[]':
                  type: array
                  items: {type: string, format: binary}
              anyOf:
                - required: [image]
                - required: ['image[]']
      responses:
        '200':
          description: Image result. Read data[].b64_json or data[].url.
  /v1/images/generations/async:
    post:
      summary: Submit a non-streaming OpenAI-format image generation
      description: Requires image task support. Save task_id from the response. Each POST is a new submission.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGeneration'
      responses:
        '202':
          description: Task accepted. Poll the returned poll_url with the original key.
  /v1/images/edits/async:
    post:
      summary: Submit a non-streaming OpenAI-format reference image request
      description: Use the same multipart form as /v1/images/edits. Each POST is a new submission.
      responses:
        '202':
          description: Task accepted. Poll the returned poll_url with the original key.
  /v1beta/models/{model}:generateContent/async:
    post:
      summary: Submit a non-streaming Gemini image request
      description: Use the native Gemini generateContent JSON. Each POST is a new submission.
      security:
        - googleApiKey: []
      parameters:
        - {name: model, in: path, required: true, schema: {type: string}}
      responses:
        '202':
          description: Task accepted. Read poll_url. Poll with Bearer authentication and the original key.
  /v1/images/tasks/{task_id}:
    get:
      summary: Read an original image task by task ID
      parameters:
        - {name: task_id, in: path, required: true, schema: {type: string}}
      responses:
        '200':
          description: Task snapshot. Check status before using result.
        '404':
          description: Image task not found for this key.
  /v1/images/async/submissions/{submission_id}:
    get:
      summary: Read an image originally submitted with a UUIDv7 submission ID
      description: Applies to the separate UUIDv7 workflow. Authentication uses the original key as Bearer, including Gemini submissions.
      parameters:
        - $ref: '#/components/parameters/SubmissionID'
      responses:
        '200':
          description: Original task with separate status, delivery_status and billing.
        '404':
          description: Original submission not found for this key.
  /v1/videos/models:
    get:
      summary: List available video models, specifications and pricing conditions
      responses:
        '200':
          description: Model list with video_constraints, video_price_conditions and optional reference_video_limits.
  /v1/videos/quote:
    post:
      summary: Get the estimate and maximum reservation for a video request
      description: Quotes are free. Review max_charge and can_afford before submitting the same request to /v1/videos.
      requestBody:
        $ref: '#/components/requestBodies/VideoRequest'
      responses:
        '200':
          description: Quote for the requested model and parameters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  estimated_charge: {type: string}
                  max_charge: {type: string}
                  billing_unit: {type: string}
                  currency_label: {type: string}
                  can_afford: {type: boolean}
  /v1/videos:
    post:
      summary: Submit one video for generation
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
        - name: X-Portdan-Max-Charge
          in: header
          required: true
          schema: {type: string}
          description: Copy max_charge from the quote for this request.
      requestBody:
        $ref: '#/components/requestBodies/VideoRequest'
      responses:
        '200':
          description: Accepted or recovered original task. Check status and delivery_available.
  /v1/videos/{video_id}:
    get:
      summary: Read status, delivery availability and billing for a video
      parameters:
        - $ref: '#/components/parameters/VideoID'
      responses:
        '200':
          description: Original video task.
  /v1/videos/{video_id}/content:
    get:
      summary: Download the existing video with the original key
      parameters:
        - $ref: '#/components/parameters/VideoID'
      responses:
        '200':
          description: Video bytes when delivery is available.
          content:
            video/mp4:
              schema: {type: string, format: binary}
  /v1/videos/submissions/{submission_id}:
    get:
      summary: Look up a video by the original Idempotency-Key
      parameters:
        - $ref: '#/components/parameters/SubmissionID'
      responses:
        '200':
          description: Original video task, including its id when available.
  /v1/videos/inputs:
    post:
      summary: Upload an image, video or audio reference
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [model, file]
              properties:
                model: {type: string}
                file: {type: string, format: binary}
      responses:
        '200':
          description: Upload snapshot. A ready input_id can be referenced as portdan-input:<input_id>.
  /v1/videos/inputs/submissions/{submission_id}:
    get:
      summary: Look up an upload by its original Idempotency-Key
      parameters:
        - $ref: '#/components/parameters/SubmissionID'
      responses:
        '200':
          description: Original upload snapshot.
  /antigravity/v1/models:
    get:
      summary: List models through the Antigravity OpenAI-compatible route
      responses:
        '200':
          description: Model list
  /antigravity/v1/chat/completions:
    post:
      summary: Create a chat completion through the Antigravity OpenAI-compatible route
      responses:
        '200':
          description: Chat completion result
  /antigravity/v1/responses:
    post:
      summary: Create a Responses API result through the Antigravity OpenAI-compatible route
      responses:
        '200':
          description: Responses API result
  /antigravity/v1/embeddings:
    post:
      summary: Create embeddings through the Antigravity OpenAI-compatible route
      responses:
        '200':
          description: Embedding result
  /antigravity/v1/messages:
    post:
      summary: Antigravity Anthropic Messages route
      responses:
        '200':
          description: Anthropic-compatible message result
  /antigravity/v1beta/models:
    get:
      summary: Antigravity Gemini model list
      security:
        - googleApiKey: []
      responses:
        '200':
          description: Gemini-compatible model list
  /antigravity/v1beta/models/{model}:generateContent:
    post:
      summary: Antigravity Gemini generateContent
      security:
        - googleApiKey: []
      parameters:
        - name: model
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Gemini-compatible result
components:
  parameters:
    SubmissionID:
      name: submission_id
      in: path
      required: true
      schema: {type: string}
    VideoID:
      name: video_id
      in: path
      required: true
      schema: {type: string}
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      schema: {type: string}
  requestBodies:
    VideoRequest:
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/VideoRequest'
  schemas:
    ImageGeneration:
      type: object
      required: [model, prompt]
      properties:
        model: {type: string}
        prompt: {type: string}
        n: {type: integer, minimum: 1}
        size: {type: string}
        quality: {type: string}
    VideoRequest:
      type: object
      required: [model, prompt, duration, resolution, ratio]
      properties:
        model: {type: string}
        prompt: {type: string}
        duration: {type: integer, minimum: 1, description: Output duration in seconds.}
        resolution: {type: string}
        ratio: {type: string}
        first_image: {type: string}
        last_image: {type: string}
        referenceImages: {type: array, items: {type: string}}
        referenceVideos: {type: array, items: {type: string}}
        referenceAudios: {type: array, items: {type: string}}
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
    googleApiKey:
      type: apiKey
      in: header
      name: x-goog-api-key
