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

# Flux Kontext

> 使用 Flux Kontext 模型生成或编辑图片（异步）

使用 [Black Forest Labs](https://bfl.ai) 的 FLUX.1 Kontext 模型进行上下文感知的图像生成与编辑。

**模型特点：**

* **上下文理解** - 通过文本指令直接修改现有图像，无需复杂工作流
* **角色一致性** - 跨多场景保持人物/物体的视觉特征一致
* **局部编辑** - 精准修改图像特定区域，不影响其他部分
* **快速迭代** - 3-5 秒生成 1MP 图像，比 GPT-Image 快 8 倍


## OpenAPI

````yaml /cn/openapi.yaml POST /generate/k/flux-kontext
openapi: 3.0.0
info:
  contact:
    email: support@sinancode.com
    name: API Support
    url: https://sinancode.com/support
  description: AI 模型任务调度平台 API
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  termsOfService: https://sinancode.com/terms-of-service
  title: TikTomato API
  version: '1.0'
servers:
  - url: https://api.sinancode.com/v1
    description: Production server
security: []
paths:
  /generate/k/flux-kontext:
    post:
      tags:
        - public
      summary: Flux Kontext 图片生成/编辑
      description: 使用 Flux Kontext 模型生成或编辑图片（异步）
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ka.CreateFluxKontextTaskRequest'
        description: 任务参数
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.CreateTaskResponse'
        '400':
          description: 参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/apierror.ErrorResponse'
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/apierror.ErrorResponse'
        '500':
          description: 服务器错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/apierror.ErrorResponse'
      security:
        - AccessToken: []
components:
  schemas:
    ka.CreateFluxKontextTaskRequest:
      properties:
        aspect_ratio:
          default: auto
          description: 宽高比（可选，默认 16:9）
          enum:
            - auto
            - '21:9'
            - '16:9'
            - '4:3'
            - '1:1'
            - '3:4'
            - '9:16'
          example: '16:9'
          type: string
        enable_translation:
          default: true
          description: 启用自动翻译（可选，默认 true）
          example: true
          type: boolean
        input_image:
          description: 输入图片 URL（可选，编辑模式使用）
          example: https://example.com/input.jpg
          type: string
        model:
          default: flux-kontext-pro
          description: 模型版本（可选，默认 flux-kontext-pro）
          enum:
            - flux-kontext-pro
            - flux-kontext-max
          example: flux-kontext-pro
          type: string
        output_format:
          default: jpeg
          description: 输出格式（可选，默认 jpeg）
          enum:
            - jpeg
            - png
          example: jpeg
          type: string
        prompt:
          description: 提示词（必填，支持英文）
          example: a beautiful landscape with mountains
          minLength: 1
          type: string
        prompt_upsampling:
          default: false
          description: 启用提示词增强（可选，默认 false）
          example: false
          type: boolean
        safety_tolerance:
          default: 2
          description: 安全容忍等级（可选，0-6，默认2）
          example: 2
          maximum: 6
          minimum: 0
          type: integer
        upload_cn:
          description: 使用中国大陆服务器上传（可选）
          example: false
          type: boolean
        watermark:
          description: 水印标识（可选）
          example: ''
          type: string
      required:
        - prompt
      type: object
    dto.CreateTaskResponse:
      properties:
        task_id:
          description: Task ID
          example: 01234567-89ab-cdef-0123-456789abcdef
          type: string
      required:
        - task_id
      type: object
    apierror.ErrorResponse:
      properties:
        error_code:
          description: Machine-readable error code (e.g. TASK.INVALID_PARAMS)
          type: string
        message:
          description: User-friendly error message
          type: string
      type: object
  securitySchemes:
    AccessToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 请使用您的 API Token 进行认证

````