{"record":{"id":"3c829f2cc44ffe37","repo":"vercel/ai","slug":"together-ai-does-not-support-mask-based-image-edit","errorCode":null,"errorMessage":"Together AI does not support mask-based image editing. Use FLUX Kontext models (e.g., black-forest-labs/FLUX.1-kontext-pro) with a reference image and descriptive prompt instead.","messagePattern":"Together AI does not support mask-based image editing\\. Use FLUX Kontext models \\(e\\.g\\., black-forest-labs/FLUX\\.1-kontext-pro\\) with a reference image and descriptive prompt instead\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/togetherai/src/togetherai-image-model.ts","lineNumber":71,"sourceCode":"  ) {}\n\n  async doGenerate({\n    prompt,\n    n,\n    size,\n    seed,\n    providerOptions,\n    headers,\n    abortSignal,\n    files,\n    mask,\n  }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<\n    Awaited<ReturnType<ImageModelV4['doGenerate']>>\n  > {\n    const warnings: Array<SharedV4Warning> = [];\n\n    if (mask != null) {\n      throw new Error(\n        'Together AI does not support mask-based image editing. ' +\n          'Use FLUX Kontext models (e.g., black-forest-labs/FLUX.1-kontext-pro) ' +\n          'with a reference image and descriptive prompt instead.',\n      );\n    }\n\n    if (size != null) {\n      warnings.push({\n        type: 'unsupported',\n        feature: 'aspectRatio',\n        details:\n          'This model does not support the `aspectRatio` option. Use `size` instead.',\n      });\n    }\n\n    const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n\n    const togetheraiOptions = await parseProviderOptions({","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/togetherai/src/togetherai-image-model.ts#L53-L89","documentation":"The Together AI image model does not implement mask-based (inpainting) editing. If a mask is provided to doGenerate, it throws immediately with guidance to use FLUX Kontext models instead, which perform instruction-based editing from a reference image plus a descriptive prompt.","triggerScenarios":"Calling generateImage with a Together AI image model and passing a `mask` parameter (image editing/inpainting request).","commonSituations":"Porting code from OpenAI DALL·E-style inpainting (image + mask) to Together AI; migrating an app between providers assuming mask support parity.","solutions":["Remove the mask parameter from the generateImage call.","Switch to a FLUX Kontext model (e.g. black-forest-labs/FLUX.1-kontext-pro) and supply the reference image plus a prompt describing the edit.","Use a different provider that supports mask-based inpainting if masks are mandatory.","Validate/handle the model choice before calling to warn users masks are unsupported."],"exampleFix":"// before\nawait generateImage({ model: togetherai.image('...'), prompt, mask });\n// after\nawait generateImage({\n  model: togetherai.image('black-forest-labs/FLUX.1-kontext-pro'),\n  prompt: 'replace the sky with a sunset',\n  providerOptions: { togetherai: { image: referenceImage } },\n});","handlingStrategy":"validation","validationCode":"if (params.mask && model.provider === 'togetherai') {\n  throw new Error('togetherai: remove mask; use FLUX Kontext with a reference image instead.');\n}","typeGuard":"null","tryCatchPattern":"try {\n  await generateImage(params);\n} catch (error) {\n  if (error.message.includes('mask-based image editing')) {\n    // fall back to a Kontext model or another provider\n  } else throw error;\n}","preventionTips":["Know provider feature parity before porting inpainting code.","Validate that no mask is passed for togetherai models.","Use FLUX Kontext models for edit-style workflows.","Centralize provider-specific image options in one place."],"tags":["image-generation","unsupported-feature","togetherai","api-misuse"],"backgroundTag":"unsupported-feature","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}