> ## Documentation Index
> Fetch the complete documentation index at: https://docs.swaply.lat/llms.txt
> Use this file to discover all available pages before exploring further.

# Gerar ou editar imagem

> Reserva 20 SWP. JPG, PNG e WebP, até 7 MB no total. O saldo é devolvido se a geração falhar.



## OpenAPI

````yaml /openapi.json post /v1/images/generations
openapi: 3.0.3
info:
  title: Swaply API
  version: 1.0.0
  description: >-
    Integre vídeo ao vivo, troca de personagem e geração de imagens pelo seu
    servidor.
servers:
  - url: https://swaplyapi.shardweb.app
security:
  - bearerAuth: []
paths:
  /v1/images/generations:
    post:
      tags:
        - Imagens
      summary: Gerar ou editar imagem
      description: >-
        Reserva 20 SWP. JPG, PNG e WebP, até 7 MB no total. O saldo é devolvido
        se a geração falhar.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - prompt
              properties:
                reference:
                  type: array
                  maxItems: 4
                  items:
                    type: string
                    format: binary
                prompt:
                  type: string
                  maxLength: 4000
                aspectRatio:
                  type: string
                  enum:
                    - '1:1'
                    - '16:9'
                    - '9:16'
                    - '4:3'
                    - '3:4'
                  default: '1:1'
      responses:
        '202':
          $ref: '#/components/responses/Job'
        '400':
          description: Dados inválidos
        '401':
          description: Chave inválida
        '402':
          description: Saldo insuficiente
        '413':
          description: Envio grande demais
        '429':
          description: Limite de requisições
components:
  responses:
    Job:
      description: >-
        Pedido assíncrono. Consulte até completed, failed ou cancelled. Expira
        após 15 minutos.
      content:
        application/json:
          schema:
            type: object
            properties:
              id:
                type: string
              status:
                type: string
                enum:
                  - checking
                  - uploading
                  - queued
                  - generating
                  - completed
                  - failed
                  - cancelled
              message:
                type: string
                nullable: true
              cost:
                type: integer
                example: 20
              currency:
                type: string
                example: SWP
              expiresAt:
                type: string
                format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.