openapi: 3.1.0
info:
  title: getimg.ai API
  version: 2.0.0
  description: |
    The getimg.ai API for image and video generation.

    Authenticate with a bearer token in the format `sk_<secret>`.
servers:
  - url: https://api.getimg.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Images
    description: Endpoints for image generation.
  - name: Models
    description: Endpoints for listing available developer models.
  - name: Videos
    description: Endpoints for video generation.
paths:
  /v2/images/generations:
    post:
      tags: [Images]
      operationId: createImageGeneration
      summary: Generate an image
      description: >
        Generate an image and return the completed result.
      x-codeSamples:
        - lang: javascript
          label: Node.js
          source: |
            import GetimgAI from "getimg-ai";

            const client = new GetimgAI();

            const result = await client.images.generate({
              model: "seedream-5-lite",
              prompt: "A cinematic portrait of a cat astronaut",
              aspect_ratio: "1:1",
              resolution: "2K",
              output_format: "jpeg",
            });
        - lang: python
          label: Python
          source: |
            from getimg import GetimgAI

            client = GetimgAI()

            result = client.images.generate(
                model="seedream-5-lite",
                prompt="A cinematic portrait of a cat astronaut",
                aspect_ratio="1:1",
                resolution="2K",
                output_format="jpeg",
            )
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ImageGenerationRequest"
            examples:
              basic:
                summary: Basic image generation
                value:
                  model: seedream-5-lite
                  prompt: A cinematic portrait of a cat astronaut
                  aspect_ratio: "1:1"
                  resolution: "2K"
                  output_format: jpeg
              with_reference:
                summary: Image generation with references
                value:
                  model: seedream-5-lite
                  prompt: Product photo in warm studio lighting
                  images:
                    - url: https://assets.example.com/reference-1.png
                      role: reference_image
                  aspect_ratio: "16:9"
                  resolution: "2K"
                  output_format: webp
      responses:
        "200":
          description: Image generation completed.
          headers:
            X-RateLimit-Limit:
              $ref: "#/components/headers/X-RateLimit-Limit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/X-RateLimit-Remaining"
            X-RateLimit-Reset:
              $ref: "#/components/headers/X-RateLimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ImageGenerationResponse"
              examples:
                completed:
                  summary: Completed image generation
                  value:
                    id: req-01HXYZABCD1234
                    status: completed
                    model: seedream-5-lite
                    data:
                      - url: https://api.getimg.ai/v2/downloads/req-01HXYZABCD1234/0?exp=1760000000&sig=1d9c2f6f4f7f6c03e5c58a4e6fd8b5b8e2d0c2f5f9e1a4cfe8c0e9d9a8b7c6d5
                        width: 1024
                        height: 1024
                        mime_type: image/png
                        deletes_at: 2026-05-02T12:30:00.000Z
                    usage:
                      total_cost: 0.04
                      billable_unit: image
                      unit_price: 0.04
                      quantity: 1
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "402":
          $ref: "#/components/responses/QuotaExceededError"
        "422":
          $ref: "#/components/responses/ContentPolicyViolationError"
        "429":
          $ref: "#/components/responses/RateLimitError"
        "500":
          $ref: "#/components/responses/ServerError"
  /v2/videos/generations:
    post:
      tags: [Videos]
      operationId: createVideoGeneration
      summary: Create a video generation
      description: >
        Submit a video generation request and return a pending result.
      x-codeSamples:
        - lang: javascript
          label: Node.js
          source: |
            import GetimgAI from "getimg-ai";

            const client = new GetimgAI();

            const { id } = await client.videos.generations.create({
              model: "seedance-v1-pro",
              prompt: "A drone shot over a futuristic city skyline at sunset",
              aspect_ratio: "16:9",
              resolution: "1080p",
              duration: 5,
              sound: false,
            });
        - lang: python
          label: Python
          source: |
            from getimg import GetimgAI

            client = GetimgAI()

            submission = client.videos.generations.create(
                model="seedance-v1-pro",
                prompt="A drone shot over a futuristic city skyline at sunset",
                aspect_ratio="16:9",
                resolution="1080p",
                duration=5,
                sound=False,
            )
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/VideoGenerationRequest"
            examples:
              basic:
                summary: Basic video generation
                value:
                  model: seedance-v1-pro
                  prompt: A drone shot over a futuristic city skyline at sunset
                  aspect_ratio: "16:9"
                  resolution: "1080p"
                  duration: 5
                  sound: false
              with_first_and_last_frames:
                summary: Video generation with first/last frame and reference image
                value:
                  model: seedance-v1-5-pro
                  prompt: Transition from sunrise to dusk over mountain landscape
                  images:
                    - url: https://assets.example.com/first-frame.png
                      role: first_frame
                    - url: https://assets.example.com/last-frame.png
                      role: last_frame
                  aspect_ratio: "16:9"
                  resolution: "1080p"
                  duration: 10
                  sound: true
      responses:
        "202":
          description: Video generation request accepted.
          headers:
            X-RateLimit-Limit:
              $ref: "#/components/headers/X-RateLimit-Limit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/X-RateLimit-Remaining"
            X-RateLimit-Reset:
              $ref: "#/components/headers/X-RateLimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VideoGenerationSubmitResponse"
              examples:
                accepted:
                  value:
                    id: req-01HXYZVIDEO1234
                    status: pending
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "402":
          $ref: "#/components/responses/QuotaExceededError"
        "422":
          $ref: "#/components/responses/ContentPolicyViolationError"
        "429":
          $ref: "#/components/responses/RateLimitError"
        "500":
          $ref: "#/components/responses/ServerError"
  /v2/models:
    get:
      tags: [Models]
      operationId: listModels
      summary: List supported models
      description: >
        List available developer models for the authenticated project.
      x-codeSamples:
        - lang: javascript
          label: Node.js
          source: |
            import GetimgAI from "getimg-ai";

            const client = new GetimgAI();

            const models = await client.models.list();

            // Optionally filter by type:
            const videoModels = await client.models.list({ type: "video" });
        - lang: python
          label: Python
          source: |
            from getimg import GetimgAI

            client = GetimgAI()

            models = client.models.list()

            # Optionally filter by type:
            video_models = client.models.list(type="video")
      parameters:
        - $ref: "#/components/parameters/ModelTypeQueryParam"
      responses:
        "200":
          description: Developer models list.
          headers:
            X-RateLimit-Limit:
              $ref: "#/components/headers/X-RateLimit-Limit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/X-RateLimit-Remaining"
            X-RateLimit-Reset:
              $ref: "#/components/headers/X-RateLimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeveloperModelListResponse"
              examples:
                all_models:
                  value:
                    - id: seedream-5-lite
                      name: Seedream 5 Lite
                      type: image
                      created_at: 2026-04-17T10:20:30.000Z
                    - id: seedance-v1-pro
                      name: Seedance v1 Pro
                      type: video
                      created_at: 2026-04-16T09:10:00.000Z
                filtered_by_type:
                  value:
                    - id: seedance-v1-pro
                      name: Seedance v1 Pro
                      type: video
                      created_at: 2026-04-16T09:10:00.000Z
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "500":
          $ref: "#/components/responses/ServerError"
  /v2/videos/generations/{id}:
    get:
      tags: [Videos]
      operationId: getVideoGenerationStatus
      summary: Retrieve video generation status
      description: >
        Retrieve the current status for a video generation request. The response
        status is `pending`, `failed`, or `completed`.
      x-codeSamples:
        - lang: javascript
          label: Node.js
          source: |
            import GetimgAI from "getimg-ai";

            const client = new GetimgAI();

            const result = await client.videos.generations.retrieve("req-01HXYZVIDEO1234");
        - lang: python
          label: Python
          source: |
            from getimg import GetimgAI

            client = GetimgAI()

            result = client.videos.generations.retrieve("req-01HXYZVIDEO1234")
      parameters:
        - $ref: "#/components/parameters/GenerationIdPathParam"
      responses:
        "200":
          description: Current video generation status.
          headers:
            X-RateLimit-Limit:
              $ref: "#/components/headers/X-RateLimit-Limit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/X-RateLimit-Remaining"
            X-RateLimit-Reset:
              $ref: "#/components/headers/X-RateLimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VideoGenerationStatusResponse"
              examples:
                pending:
                  summary: Pending status
                  value:
                    id: req-01HXYZVIDEO1234
                    status: pending
                failed:
                  summary: Failed status
                  value:
                    id: req-01HXYZVIDEO1234
                    status: failed
                    error:
                      message: Upstream provider request timed out.
                      code: server_error
                completed:
                  summary: Completed video generation
                  value:
                    id: req-01HXYZVIDEO1234
                    status: completed
                    model: seedance-v1-pro
                    data:
                      - url: /v2/downloads/req-01HXYZVIDEO1234/0?exp=1760000000&sig=ca4f0f5a5f7d2ca9bc9c7b53b2432d7840a971c11c9161d3d2f29e1cb6e77f8f
                        width: 1920
                        height: 1080
                        duration: 10
                        fps: 24
                        has_sound: true
                        mime_type: video/mp4
                        deletes_at: 2026-05-02T12:30:00.000Z
                    usage:
                      total_cost: 5
                      billable_unit: video_second
                      unit_price: 0.5
                      quantity: 10
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/RateLimitError"
        "500":
          $ref: "#/components/responses/ServerError"
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        Send your API key as a bearer token:
        `Authorization: Bearer sk_<secret>`.
  headers:
    X-RateLimit-Limit:
      description: Maximum requests allowed in the current rate-limit window.
      schema:
        type: string
        pattern: "^[0-9]+$"
      example: "60"
    X-RateLimit-Remaining:
      description: Remaining requests in the current rate-limit window.
      schema:
        type: string
        pattern: "^[0-9]+$"
      example: "59"
    X-RateLimit-Reset:
      description: Unix timestamp (seconds) when the current rate-limit window resets.
      schema:
        type: string
        pattern: "^[0-9]+$"
      example: "1760000042"
    Retry-After:
      description: Number of seconds to wait before retrying.
      schema:
        type: string
        pattern: "^[0-9]+$"
      example: "42"
  parameters:
    GenerationIdPathParam:
      name: id
      in: path
      required: true
      description: Generation request ID.
      schema:
        type: string
        minLength: 1
    ModelTypeQueryParam:
      name: type
      in: query
      required: false
      description: Optional model type filter.
      schema:
        type: string
        enum: [image, video]
  schemas:
    PublicApiError:
      type: object
      required: [error]
      properties:
        error:
          type: object
          required: [message, type, param, code]
          properties:
            message:
              type: string
            type:
              type: string
              const: invalid_request_error
            param:
              anyOf:
                - type: string
                - type: "null"
            code:
              type: string
              enum:
                - invalid_api_key
                - parameter_missing
                - invalid_parameter
                - quota_exceeded
                - rate_limit
                - content_policy_violation
                - not_found
                - server_error
            doc_url:
              type: string
              format: uri
    ImageReference:
      type: object
      required: [url]
      properties:
        url:
          type: string
          description: |
            Publicly accessible reference image URL.
          minLength: 1
    ImageGenerationRequest:
      type: object
      required: [model, prompt]
      properties:
        model:
          type: string
          description: >
            AI model ID. See [supported models](https://getimg.ai/app/developer/models).
        prompt:
          type: string
          minLength: 1
          maxLength: 4096
          description: |
            Description of the image to generate or an editing instruction.
        images:
          type: array
          maxItems: 8
          items:
            $ref: "#/components/schemas/ImageReference"
        aspect_ratio:
          type: string
          description: |
            Optional output aspect ratio. 
            See [supported values by model](https://getimg.ai/app/developer/models).
        resolution:
          type: string
          description: |
            Optional output resolution.
            See [supported values by model](https://getimg.ai/app/developer/models).
        output_format:
          type: string
          enum: [png, jpeg, webp]
          default: jpeg
          description: |
            Output image format.
    Usage:
      type: object
      required: [total_cost, billable_unit, unit_price, quantity]
      properties:
        total_cost:
          type: number
          description: Total cost of the generation.
        billable_unit:
          type: string
          description: The unit of the cost.
        unit_price:
          type: number
          description: The price of the unit.
        quantity:
          type: number
          description: The quantity of the generation.
    ImageDataItem:
      type: object
      required: [url, mime_type, deletes_at]
      properties:
        url:
          type: string
          description: Signed temporary download URL.
        width:
          anyOf:
            - type: integer
            - type: "null"
          description: The width of the image in pixels.
        height:
          anyOf:
            - type: integer
            - type: "null"
          description: The height of the image in pixels.
        mime_type:
          type: string
          description: The MIME type of the image.
        deletes_at:
          type: string
          format: date-time
          description: The date and time the image will be deleted.
    ImageGenerationResponse:
      type: object
      required: [id, status, model, data, usage]
      properties:
        id:
          type: string
          description: The ID of the generation request.
        status:
          type: string
          const: completed
        model:
          type: string
          description: The model used for the generation.
        data:
          type: array
          description: The media items for the generation.
          items:
            $ref: "#/components/schemas/ImageDataItem"
        usage:
          $ref: "#/components/schemas/Usage"
    DeveloperModelListItem:
      type: object
      required: [id, name, type, created_at]
      properties:
        id:
          type: string
          description: The model identifier.
        name:
          type: string
          description: The model display name.
        type:
          type: string
          enum: [image, video]
          description: The generation type supported by the model.
        created_at:
          type: string
          format: date-time
          description: Timestamp when the model was created.
    DeveloperModelListResponse:
      type: array
      items:
        $ref: "#/components/schemas/DeveloperModelListItem"
    VideoReference:
      type: object
      required: [url, role]
      properties:
        url:
          type: string
          description: |
            Publicly accessible reference image URL.
          minLength: 1
        role:
          type: string
          enum: [reference_image, first_frame, last_frame]
          description: The role of the reference image.
    VideoGenerationRequest:
      type: object
      required: [model, prompt]
      properties:
        model:
          type: string
          description: >
            AI model ID. See [supported models](https://getimg.ai/app/developer/models).
        prompt:
          type: string
          minLength: 1
          maxLength: 4096
          description: |
            Description of the video to generate.
        images:
          type: array
          maxItems: 8
          items:
            $ref: "#/components/schemas/VideoReference"
          description: |
            Optional reference images. See [supported values by model](https://getimg.ai/app/developer/models).
        aspect_ratio:
          type: string
          description: |
            Optional output aspect ratio.
            See [supported values by model](https://getimg.ai/app/developer/models).
        resolution:
          type: string
          description: |
            Optional output resolution.
            See [supported values by model](https://getimg.ai/app/developer/models).
        duration:
          type: integer
          description: |
            Optional duration in seconds.
            See [supported values by model](https://getimg.ai/app/developer/models).
        sound:
          type: boolean
          description: |
            Set to `true` to generate audio when supported by the model.
    VideoGenerationSubmitResponse:
      type: object
      required: [id, status]
      properties:
        id:
          type: string
          description: The ID of the generation request.
        status:
          description: The status of the generation request.
          type: string
          const: pending
    VideoDataItem:
      type: object
      required: [url, mime_type, deletes_at]
      properties:
        url:
          type: string
          description: Signed temporary download URL.
        width:
          anyOf:
            - type: integer
            - type: "null"
          description: The width of the video in pixels.
        height:
          anyOf:
            - type: integer
            - type: "null"
          description: The height of the video in pixels.
        duration:
          anyOf:
            - type: number
            - type: "null"
          description: The duration of the video in seconds.
        fps:
          anyOf:
            - type: number
            - type: "null"
          description: The frame rate of the video.
        has_sound:
          type: boolean
          description: Whether the video has and audio track.
        mime_type:
          type: string
          description: The MIME type of the video.
        deletes_at:
          type: string
          format: date-time
          description: The date and time the video will be deleted.
    VideoGenerationPendingResponse:
      type: object
      required: [id, status]
      properties:
        id:
          type: string
          description: The ID of the generation request.
        status:
          type: string
          const: pending
          description: The status of the generation request.
    VideoGenerationFailedError:
      type: object
      required: [message, code]
      properties:
        message:
          type: string
          description: The error message.
        code:
          type: string
          description: The error code.
    VideoGenerationFailedResponse:
      type: object
      required: [id, status, error]
      properties:
        id:
          type: string
          description: The ID of the generation request.
        status:
          type: string
          const: failed
          description: The status of the generation request.
        error:
          $ref: "#/components/schemas/VideoGenerationFailedError"
    VideoGenerationCompletedResponse:
      type: object
      required: [id, status, model, data]
      properties:
        id:
          type: string
          description: The ID of the generation request.
        status:
          type: string
          const: completed
          description: The status of the generation request.
        model:
          type: string
          description: The model used for the generation.
        data:
          type: array
          description: The media items for the generation.
          items:
            $ref: "#/components/schemas/VideoDataItem"
        usage:
          $ref: "#/components/schemas/Usage"
    VideoGenerationStatusResponse:
      oneOf:
        - $ref: "#/components/schemas/VideoGenerationPendingResponse"
        - $ref: "#/components/schemas/VideoGenerationFailedResponse"
        - $ref: "#/components/schemas/VideoGenerationCompletedResponse"
      discriminator:
        propertyName: status
        mapping:
          pending: "#/components/schemas/VideoGenerationPendingResponse"
          failed: "#/components/schemas/VideoGenerationFailedResponse"
          completed: "#/components/schemas/VideoGenerationCompletedResponse"
  responses:
    BadRequestError:
      description: The request payload or parameters are invalid.
      headers:
        X-RateLimit-Limit:
          $ref: "#/components/headers/X-RateLimit-Limit"
        X-RateLimit-Remaining:
          $ref: "#/components/headers/X-RateLimit-Remaining"
        X-RateLimit-Reset:
          $ref: "#/components/headers/X-RateLimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiError"
          examples:
            invalid_parameter:
              value:
                error:
                  message: Unsupported resolution '4K' for model 'seedream-5-lite'.
                  type: invalid_request_error
                  param: resolution
                  code: invalid_parameter
            parameter_missing:
              value:
                error:
                  message: Required parameter 'prompt' is missing.
                  type: invalid_request_error
                  param: prompt
                  code: parameter_missing
    UnauthorizedError:
      description: Authentication failed due to a missing or invalid API key.
      headers:
        X-RateLimit-Limit:
          $ref: "#/components/headers/X-RateLimit-Limit"
        X-RateLimit-Remaining:
          $ref: "#/components/headers/X-RateLimit-Remaining"
        X-RateLimit-Reset:
          $ref: "#/components/headers/X-RateLimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiError"
          examples:
            invalid_api_key:
              value:
                error:
                  message: Incorrect API key provided. You can manage your API keys at https:/getimg.ai/developer/api-keys
                  type: invalid_request_error
                  param: null
                  code: invalid_api_key
                  doc_url: https://docs.getimg.ai/#topic-authentication
    QuotaExceededError:
      description: Your account or project quota is insufficient for this request.
      headers:
        X-RateLimit-Limit:
          $ref: "#/components/headers/X-RateLimit-Limit"
        X-RateLimit-Remaining:
          $ref: "#/components/headers/X-RateLimit-Remaining"
        X-RateLimit-Reset:
          $ref: "#/components/headers/X-RateLimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiError"
          examples:
            quota_exceeded:
              value:
                error:
                  message: Quota exceeded.
                  type: invalid_request_error
                  param: null
                  code: quota_exceeded
    ContentPolicyViolationError:
      description: The prompt or input images failed content policy checks.
      headers:
        X-RateLimit-Limit:
          $ref: "#/components/headers/X-RateLimit-Limit"
        X-RateLimit-Remaining:
          $ref: "#/components/headers/X-RateLimit-Remaining"
        X-RateLimit-Reset:
          $ref: "#/components/headers/X-RateLimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiError"
          examples:
            moderated:
              value:
                error:
                  message: Image or text contains sensitive content.
                  type: invalid_request_error
                  param: null
                  code: content_policy_violation
    NotFoundError:
      description: The requested resource was not found.
      headers:
        X-RateLimit-Limit:
          $ref: "#/components/headers/X-RateLimit-Limit"
        X-RateLimit-Remaining:
          $ref: "#/components/headers/X-RateLimit-Remaining"
        X-RateLimit-Reset:
          $ref: "#/components/headers/X-RateLimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiError"
          examples:
            not_found:
              value:
                error:
                  message: The resource doesn't exist.
                  type: invalid_request_error
                  param: null
                  code: not_found
    RateLimitError:
      description: A rate or concurrency limit was exceeded.
      headers:
        X-RateLimit-Limit:
          $ref: "#/components/headers/X-RateLimit-Limit"
        X-RateLimit-Remaining:
          $ref: "#/components/headers/X-RateLimit-Remaining"
        X-RateLimit-Reset:
          $ref: "#/components/headers/X-RateLimit-Reset"
        Retry-After:
          $ref: "#/components/headers/Retry-After"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiError"
          examples:
            rate_limited:
              value:
                error:
                  message: Too many requests hit the API too quickly.
                  type: invalid_request_error
                  param: null
                  code: rate_limit
    ServerError:
      description: An unexpected server error occurred.
      headers:
        X-RateLimit-Limit:
          $ref: "#/components/headers/X-RateLimit-Limit"
        X-RateLimit-Remaining:
          $ref: "#/components/headers/X-RateLimit-Remaining"
        X-RateLimit-Reset:
          $ref: "#/components/headers/X-RateLimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiError"
          examples:
            server_error:
              value:
                error:
                  message: Something went wrong on our end.
                  type: invalid_request_error
                  param: null
                  code: server_error
