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

# Recreate a group photo using trained profiles

> Generates a group photo by placing 2–10 trained profiles into a scene derived from a reference image. The aspect ratio is auto-detected from the reference image; an explicit `aspect_ratio` parameter overrides it.

At least 2 valid, ready profiles must be provided. If fewer than 2 pass validation, the request returns `trained_profile_not_found`. Credits are deducted before generation begins and refunded if the job fails.




## OpenAPI

````yaml /openapi.yaml post /api/v2/photo/recreate-group
openapi: 3.0.3
info:
  title: GoStudio API
  version: 2.0.0
  description: >
    The GoStudio v2 REST API. Every response uses a standard envelope: successes
    return `{ status, data }`; errors return `{ status, error: { type, code,
    message } }`.


    All endpoints require a **Bearer token** in the `Authorization` header. The
    one exception is the provider webhook callback, which is authenticated by
    signature.
servers:
  - url: https://www.gostudio.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Watermark Remover
    description: AI watermark removal — orchestration, model metadata, and job polling.
  - name: Photo
    description: >-
      AI photo generation — generate, recreate, and manage trained profile
      photos.
  - name: Image
    description: Image utilities — group photo composition and image-to-prompt analysis.
  - name: Media
    description: Media upload and CDN management.
  - name: Apps
    description: GoStudio application tools — age modifier and other transformations.
  - name: Job Status
    description: Generic job polling — works across all GoStudio tools.
  - name: Webhooks
    description: Endpoints called by external services, not by your application.
paths:
  /api/v2/photo/recreate-group:
    post:
      tags:
        - Photo
      summary: Recreate a group photo using trained profiles
      description: >
        Generates a group photo by placing 2–10 trained profiles into a scene
        derived from a reference image. The aspect ratio is auto-detected from
        the reference image; an explicit `aspect_ratio` parameter overrides it.


        At least 2 valid, ready profiles must be provided. If fewer than 2 pass
        validation, the request returns `trained_profile_not_found`. Credits are
        deducted before generation begins and refunded if the job fails.
      operationId: recreateGroupPhoto
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PhotoRecreateGroupRequest'
            examples:
              basic:
                summary: Three-person group photo
                value:
                  reference_image_url: https://example.com/group-scene.jpg
                  profile_ids:
                    - 42
                    - 43
                    - 44
                  aspect_ratio: '16:9'
      responses:
        '200':
          description: Group photo generated successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    example: 200
                  data:
                    $ref: '#/components/schemas/GroupGenerationResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: Fewer than 2 valid ready profiles found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: 404
                error:
                  type: trained_profile_not_found
                  code: 40403
                  message: Trained profile not found.
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/ServerError'
        '502':
          $ref: '#/components/responses/BadGateway'
components:
  schemas:
    PhotoRecreateGroupRequest:
      type: object
      required:
        - reference_image_url
        - profile_ids
      properties:
        reference_image_url:
          type: string
          format: uri
          description: HTTPS URL of the reference group scene image.
          example: https://example.com/group-scene.jpg
        profile_ids:
          type: array
          description: IDs of trained profiles for group members. Minimum 2, maximum 10.
          items:
            type: integer
          minItems: 2
          maxItems: 10
          example:
            - 42
            - 43
            - 44
        num_output_images:
          type: integer
          description: Number of images to generate.
          default: 1
          minimum: 1
          maximum: 4
        aspect_ratio:
          type: string
          description: >-
            Output aspect ratio. Auto-detected from the reference image if
            omitted.
          enum:
            - '1:1'
            - '3:4'
            - '4:3'
            - '9:16'
            - '16:9'
          example: '16:9'
        resolution:
          type: string
          description: Output resolution.
          enum:
            - 1K
            - 2K
            - 4K
          default: 1K
        output_format:
          type: string
          description: Output image format.
          enum:
            - png
            - jpg
          default: png
        instructions:
          type: string
          description: Additional generation instructions.
    GroupGenerationResult:
      allOf:
        - $ref: '#/components/schemas/GenerationResult'
        - type: object
          properties:
            profile_ids:
              type: array
              description: Profile IDs used in the generation.
              items:
                type: integer
              example:
                - 42
                - 43
                - 44
    ErrorResponse:
      type: object
      properties:
        status:
          type: integer
          example: 400
        error:
          type: object
          properties:
            type:
              type: string
              example: validation_error
            code:
              type: string
              example: invalid_input
            dev:
              type: integer
              example: 40001
            message:
              type: string
              example: Some information is invalid.
    GenerationResult:
      type: object
      properties:
        kind:
          type: string
          description: Always "generation".
          example: generation
        job_id:
          type: string
          description: >
            Encoded job identifier. Use with `GET /api/v2/apps/job/{job_id}` to
            poll status or re-fetch results.
          example: enc_abc123
        credits_deducted:
          type: integer
          description: Credits spent on this generation.
          example: 10
        credit_balance:
          type: integer
          description: Remaining credit balance after this request.
          example: 490
        created_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the job was created.
        output_urls:
          type: array
          description: CDN URLs for the generated images.
          items:
            type: string
            format: uri
  responses:
    BadRequest:
      description: The request was malformed or failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 400
            error:
              type: validation_error
              code: invalid_input
              dev: 40001
              message: Some information is invalid.
    Unauthorized:
      description: Missing or invalid Authorization Bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 401
            error:
              type: authentication_error
              code: unauthorized
              dev: 40100
              message: Missing or invalid Authorization Bearer token.
    PaymentRequired:
      description: The account does not have enough credits for this request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 402
            error:
              type: billing_error
              code: insufficient_credits
              dev: 40200
              message: You don't have enough credits.
    Forbidden:
      description: Caller type not allowed for this endpoint.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 403
            error:
              type: permission_error
              code: forbidden
              dev: 40300
              message: You don't have permission for this action.
    RateLimited:
      description: Too many requests.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 429
            error:
              type: rate_limit_error
              code: rate_limited
              dev: 42900
              message: You're doing that too often. Please wait a moment.
    ServerError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 500
            error:
              type: system_error
              code: internal_error
              dev: 50000
              message: Something went wrong on our end.
    BadGateway:
      description: >
        The upstream model provider rejected the submission, was unreachable, or
        returned an unusable response while the job was being submitted or
        checked. The generation is marked failed and the credits reserved for it
        are refunded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 502
            error:
              type: provider_error
              code: provider_bad_gateway
              dev: 50200
              message: Generation is having trouble right now. Please try again.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Supabase user JWT (or an internal service token). Send as
        `Authorization: Bearer <token>`.

````

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