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

# Generate image

> Generate AI images using Nano Banana models. Supports text-to-image generation with nano-banana-2 (4 credits) and image-to-image editing with google/nano-banana-edit (2 credits).

The generation is asynchronous — poll `GET /images/{taskId}` to check status and retrieve the image URL when ready.



## OpenAPI

````yaml /openapi.json post /images/generate
openapi: 3.0.0
info:
  title: RawUGC API
  version: 1.0.0
  description: >-
    Generate AI videos, images, and music, and schedule social media posts
    programmatically.
  contact:
    name: API Support
    email: support@rawugc.com
    url: https://docs.rawugc.com
  license:
    name: Proprietary
servers:
  - url: https://rawugc.com/api/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Tasks
    description: >-
      Deprecated. Use typed resource endpoints instead: GET /videos/{videoId},
      GET /images/{imageId}, GET /music/{musicId}.
  - name: Image Generation
    description: >-
      Generate and edit AI images using Nano Banana models. Supports
      text-to-image generation (6 credits) and image-to-image editing (2
      credits).
  - name: Video Generation
    description: Generate and manage AI videos using Sora 2, Kling, and Veo 3 models
  - name: Personas
    description: Manage target audience personas for content plans
  - name: Messaging
    description: Manage brand/positioning messaging for content plans
  - name: Products
    description: Manage products for video generation
  - name: Styles
    description: Manage video creative styles and templates
  - name: Characters
    description: List available AI characters for video generation
  - name: Video Editing
    description: Post-process videos with captions, overlays, and effects
  - name: Upload
    description: Upload video and image files for use in generation requests
  - name: Social Scheduling
    description: Schedule and manage social media posts to TikTok, Instagram, and YouTube
  - name: Social Accounts
    description: Manage connected social media accounts
  - name: Music Generation
    description: >-
      Generate AI music tracks using Suno models with customizable genre, mood,
      and style
  - name: Viral Library
    description: >-
      Browse and search analyzed TikTok videos across the platform. Includes
      AI-powered analysis with hooks, keyframes, performance insights, and
      semantic search via natural language queries.
  - name: Research
    description: >-
      Scrape TikTok videos, analyze any video, and generate content plans. Tools
      for competitive research and content strategy.
paths:
  /images/generate:
    post:
      tags:
        - Image Generation
      summary: Generate image
      description: >-
        Generate AI images using Nano Banana models. Supports text-to-image
        generation with nano-banana-2 (4 credits) and image-to-image editing
        with google/nano-banana-edit (2 credits).


        The generation is asynchronous — poll `GET /images/{taskId}` to check
        status and retrieve the image URL when ready.
      operationId: generateImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              text_to_image:
                summary: Text-to-image (nano-banana-2)
                value:
                  model: nano-banana-2
                  prompt: >-
                    Comic poster: cool banana hero in shades leaps from sci-fi
                    pad
                  aspectRatio: '16:9'
                  resolution: 1K
                  outputFormat: jpg
              image_editing:
                summary: Image editing (nano-banana-edit)
                value:
                  model: google/nano-banana-edit
                  prompt: turn this photo into a cartoon character figure
                  imageUrls:
                    - https://example.com/photo.jpg
                  imageSize: '1:1'
                  outputFormat: png
      responses:
        '201':
          description: Image generation initiated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageGenerationResponse'
        '400':
          description: Validation error (invalid model, missing required fields, etc.)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '402':
          description: Insufficient credits
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
components:
  schemas:
    ImageGenerationRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          enum:
            - google/nano-banana-edit
            - nano-banana-2
          description: >-
            Image generation model. 'google/nano-banana-edit' for image editing
            (2 credits), 'nano-banana-2' for text-to-image (4 credits).
        prompt:
          type: string
          minLength: 1
          maxLength: 20000
          description: Text description of the image to generate or the edit to apply.
        imageUrls:
          type: array
          items:
            type: string
            format: uri
          maxItems: 14
          description: >-
            Image URLs. Required for google/nano-banana-edit (source images to
            edit). Optional for nano-banana-2 (reference images, max 14). Must
            be publicly accessible HTTP/HTTPS URLs.
        imageSize:
          type: string
          enum:
            - '1:1'
            - '9:16'
            - '16:9'
            - '3:4'
            - '4:3'
            - '3:2'
            - '2:3'
            - '5:4'
            - '4:5'
            - '21:9'
            - auto
          description: Aspect ratio for google/nano-banana-edit model.
        outputFormat:
          type: string
          enum:
            - png
            - jpeg
            - jpg
          description: >-
            Output image format. Defaults to jpg for nano-banana-2, png for
            nano-banana-edit.
        aspectRatio:
          type: string
          enum:
            - '1:1'
            - '1:4'
            - '1:8'
            - '2:3'
            - '3:2'
            - '3:4'
            - '4:1'
            - '4:3'
            - '4:5'
            - '5:4'
            - '8:1'
            - '9:16'
            - '16:9'
            - '21:9'
            - auto
          description: Aspect ratio for nano-banana-2 model. Defaults to auto.
        googleSearch:
          type: boolean
          description: >-
            Use Google Web Search grounding to generate images based on
            real-time information (nano-banana-2 only). Defaults to false.
        resolution:
          type: string
          enum:
            - 1K
            - 2K
            - 4K
          description: Output resolution for nano-banana-2 model. Defaults to 1K.
    ImageGenerationResponse:
      type: object
      properties:
        imageId:
          type: string
          description: Unique image identifier (img_xxx format)
        model:
          type: string
          description: Image model used for generation
        status:
          type: string
          enum:
            - pending
            - processing
            - completed
            - failed
          description: Current generation status
        creditsUsed:
          type: number
          description: Number of credits deducted for this generation
        newBalance:
          type: number
          description: Remaining credit balance after deduction
        estimatedCompletionTime:
          type: string
          description: Estimated time until image is ready (human-readable)
        createdAt:
          type: number
          description: Timestamp when generation was initiated (milliseconds since epoch)
    ApiError:
      type: object
      properties:
        type:
          type: string
          format: uri
          description: >-
            URI reference identifying the problem type (e.g.,
            https://api.rawugc.com/errors/validation_error)
        title:
          type: string
          description: Short, human-readable summary of the problem
        status:
          type: number
          description: HTTP status code
        detail:
          type: string
          description: Human-readable explanation of the problem
        instance:
          type: string
          format: uri
          description: URI reference identifying this specific occurrence
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: Field-specific validation errors
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        Use your API key from the RawUGC dashboard. Include as: Authorization:
        Bearer YOUR_API_KEY

````