# "Tạo hình ảnh"

Nguồn: https://docs.openaihub.net/api-45208838/

> API origin: `https://api.openaihub.net`. Chọn đúng nhóm API và model. Thông số dưới đây là bản tham chiếu kỹ thuật; chưa phải kết quả kiểm thử từng endpoint bằng tài khoản của bạn.


## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1beta/models/{modeName}:generateContent:
    post:
      summary: Tạo hình ảnh
      deprecated: false
      description: >-
        Tài liệu chính thức:
        https://ai.google.dev/gemini-api/docs/image-generation?hl=zh-cn
      operationId: gemini_v1beta_mode_name_generate_content
      tags:
        - OpenAiHub Việt Nam/OpenAiHub Tiếng Việt/Trò chuyện/Gemini/Định dạng gốc
        - Gemini v1beta
      parameters:
        - name: modeName
          in: path
          description: |-
            Tên mô hình:
            gemini-2.5-flash-image
            gemini-2.5-flash-image-preview
            gemini-3-pro-image-preview
            gemini-3.1-flash-image-preview
          required: true
          example: gemini-2.5-flash-image-preview
          schema:
            type: string
        - name: key
          in: query
          description: 'Khóa API (cũng hỗ trợ Authorization: Bearer)'
          required: true
          example: '{{YOUR_API_KEY}}'
          schema:
            type: string
        - name: Content-Type
          in: header
          description: Loại nội dung của phần thân yêu cầu, thường là application/json
          required: true
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - contents
              properties:
                contents:
                  type: array
                  items:
                    type: object
                    required:
                      - parts
                    properties:
                      parts:
                        type: array
                        items:
                          type: object
                          properties:
                            inline_data:
                              type: object
                              required:
                                - mime_type
                                - data
                              properties:
                                data:
                                  type: string
                                  description: >-
                                    Base64 của hình ảnh hỗ trợ tối đa 14 hình
                                    ảnh đầu vào.
                                mime_type:
                                  type: string
                                  description: Kiểu MIME của hình ảnh
                              description: Dữ liệu được nhúng trong hình ảnh
                              x-apifox-orders:
                                - data
                                - mime_type
                              x-apidog-orders:
                                - data
                                - mime_type
                            text:
                              type: string
                              description: từ trong lời nhắc
                          x-apifox-orders:
                            - inline_data
                            - text
                          x-apidog-orders:
                            - inline_data
                            - text
                        description: >-
                          Danh sách các phần nội dung; có thể bao gồm văn bản,
                          inline_data / inlineData, v.v.
                    x-apifox-orders:
                      - parts
                    x-apidog-orders:
                      - parts
                  description: >-
                    Danh sách nội dung cuộc hội thoại; mỗi mục gồm các phần (văn
                    bản/hình ảnh/v.v.)
                generationConfig:
                  type: object
                  properties:
                    imageConfig:
                      type: object
                      properties:
                        aspectRatio:
                          type: string
                          description: >-
                            Tỷ lệ khung hình:

                            1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
                            hỗ trợ tất cả các mô hình

                            1:4, 1:8, 4:1 và 8:1 chỉ hỗ trợ các mô hình Gemini
                            3.1.
                        imageSize:
                          type: string
                          description: >-
                            Độ phân giải:

                            0.5K, 1K, 2K, 4K

                            Mặc định: 1K

                            Lưu ý: Gemini 2.5 chỉ hỗ trợ 1K, 0.5K chỉ hỗ trợ mô
                            hình Gemini 3.1, giá trị phải được điền là "512"
                      description: Cấu hình hình ảnh
                      x-apifox-orders:
                        - aspectRatio
                        - imageSize
                      x-apidog-orders:
                        - aspectRatio
                        - imageSize
                    responseModalities:
                      type: array
                      items:
                        type: string
                      description: |-
                        Chế độ phản hồi:
                        Text, Image
                        Mặc định: ["Text", "Image"]
                  description: Tạo cấu hình
                  x-apifox-orders:
                    - imageConfig
                    - responseModalities
                  x-apidog-orders:
                    - imageConfig
                    - responseModalities
                response_format:
                  type: string
                  description: >-
                    Điền vào url và trả về url; nếu không, hãy điền base64 mặc
                    định.
              refName: PostV1betaModelsModeNameGenerateContentRequest
              x-apifox-orders:
                - contents
                - generationConfig
                - response_format
              x-apidog-orders:
                - contents
                - generationConfig
                - response_format
            examples: {}
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                x-apidog-orders: []
              examples:
                example:
                  summary: example
                  value:
                    id: resp_example
                    object: phản hồi
                    status: completed
          headers: {}
          x-apidog-name: ''
        '400':
          description: Yêu cầu không hợp lệ hoặc xác thực thất bại
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: object
                    required:
                      - message
                      - type
                    properties:
                      message:
                        type: string
                        description: Thông báo lỗi (thường kết thúc bằng mã yêu cầu)
                      type:
                        type: string
                        description: Loại lỗi; các lỗi cổng cục bộ thường là new_api_error
                        examples:
                          - new_api_error
                    x-apifox-orders:
                      - message
                      - type
                    x-apidog-orders:
                      - message
                      - type
                refName: NewApiError
                x-apifox-orders:
                  - error
                x-apidog-orders:
                  - error
              examples:
                example:
                  summary: example
                  value:
                    error:
                      message: >-
                        Yêu cầu không hợp lệ (mã yêu cầu:
                        20260805120000123456789AbCdEfGh)
                      type: new_api_error
          headers: {}
          x-apidog-name: Yêu cầu không hợp lệ hoặc xác thực thất bại
        '401':
          description: Khóa API bị thiếu hoặc không hợp lệ
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: object
                    required:
                      - message
                      - type
                    properties:
                      message:
                        type: string
                        description: Thông báo lỗi (thường kết thúc bằng mã yêu cầu)
                      type:
                        type: string
                        description: Loại lỗi; các lỗi cổng cục bộ thường là new_api_error
                        examples:
                          - new_api_error
                    x-apifox-orders:
                      - message
                      - type
                    x-apidog-orders:
                      - message
                      - type
                refName: NewApiError
                x-apifox-orders:
                  - error
                x-apidog-orders:
                  - error
              examples:
                example:
                  summary: example
                  value:
                    error:
                      message: >-
                        Mã thông báo không hợp lệ (request id:
                        20260805120000123456789AbCdEfGh)
                      type: new_api_error
          headers: {}
          x-apidog-name: Khóa API bị thiếu hoặc không hợp lệ
      security: []
      x-apidog-folder: OpenAiHub Việt Nam/OpenAiHub Tiếng Việt/Trò chuyện/Gemini/Định dạng gốc
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/1218648/apis/api-45208838-run
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: https://api.openaihub.net
    description: Prod Env
security: []

```
