Imagem para imagem
Edite ou altere o estilo de uma imagem com um prompt e imagens de referência.
/v2/open/image/image_to_imagePreço por modeloEntrada
https://static.codia.ai/image_generate/2026-10-04/8c7b6ac0-2c6f-440b-867b-a1f6b77a2192.jpeg
1024 × 1024 px · JPG · 684 KBTurn this into a holiday gift campaign shot: same bottle, festive wrapping paper, satin ribbon and pine sprigs, warm evening light
A execução direta a partir desta página estará disponível em breve. Este é um pedido e um resultado reais da API — crie uma chave para o executar.
Saída
ExemploPreço por modelo


Transforma uma imagem de acordo com uma instrução em texto, desde mudanças de estilo a edições de cena.
- Casos de uso
- Transferência de estilo
- Fotografias de produto sazonais ou temáticas
- Transformar esboços em visuais finalizados
- Entrada
- Um URL público de imagem ou um ficheiro de imagem carregado, um prompt e, opcionalmente, model, size e quality.
- Saída
- data.image_urls com a nova imagem.
- Como funciona
- Síncrona. O preço depende do modelo.
Referência técnica completa(em inglês)
Cost: configured in the live price table (model-dependent — see model field).
Image to Image supports two input modes:
- JSON URL mode: send
application/jsonwith the existing URL field. - Direct upload mode: send
multipart/form-datawith a local image file in theimagefield. The compatible field namefileis also accepted for the primary image. Codia checks credits before reading and uploading the file, so insufficient-credit requests return402without uploading anything.
Direct upload example:
curl 'https://openapi.codia.ai/v2/open/image/image_to_image' \
-H 'Authorization: Bearer {codia_api_key}' \
-F 'image=@./image.png' \
-F 'prompt=make it watercolor'Transform a source image into a new one steered by a text prompt — "this photo, but Studio Ghibli style", "this product shot, but at sunset", "this sketch, refined into a finished painting". Synchronous. Different from remix (which preserves more structure) and replace_background (which only changes the background).
What this API is for
Style transfer, refinement, restylization, scene editing — any task framed as "take this image and change it according to this instruction". Holds onto the source's overall composition more loosely than remix — use that one when you need tighter structural preservation.
Request
| Field | Required | Notes |
|---|---|---|
image_url | yes | Public URL of the source image. |
prompt | yes | Text description of the desired transformation. |
model | no | Default nano_banana_2_1. Same model menu as generate_image: nano_banana_2_1, nano_banana_2, nano_banana_pro, gpt_image_2_6, gpt_image, qwen_image_3_pro, hy_image_3_5, codia_image, seedream_5_pro, seedream_5_flash, seedream_5, seedream_5_5, recraft_v4_1, flux_3_1, ideogram_v4_6. |
size | no | Output dimensions as WIDTHxHEIGHT. For GPT Image 2 and 2.6, supported output tiers are 1K, 2K, and 4K. |
quality | no | For gpt_image, use low, medium, high, or auto. For gpt_image_2_6 (including Flare and Sunburst), xhigh and max are also supported. Omitted quality or auto uses the medium price. For ideogram_v4_6, use auto, low, medium, or high; omitted quality or auto uses medium. For flux_3_1, use fast or quality; omitted quality defaults to quality. For flux_3_1, use fast or quality; omitted quality defaults to quality. For other non-GPT models, this field may carry the resolution tier (for example 1K, 2K, or 4K). |
background | no | GPT Image only: transparent, opaque, or auto. Ignored by non-GPT models. |
reference_images | no | Additional public image URLs for style or subject guidance. For qwen_image_3_pro, image_to_image accepts up to 2 reference_images. For flux_3_1, the source image plus additional references may total up to 10 images. For ideogram_v4_6, one source image plus up to 4 additional references may total up to 5 images. |
Response
Shared ImageUrlListSuccess — data.image_urls carries one URL of the transformed image.
Billing & limits
- Price depends on the selected model, output size, and quality. Call
POST /v2/open/estimatefor an exact current quote. - Synchronous, single-call.
When to pick what
- Want a complete transformation? →
image_to_image. - Want to keep structure but change style? →
remix. - Want to keep subject and only change scene? →
replace_background. - Want to start from scratch with optional refs? →
generate_image.
Errors
Standard set.
Sync vs. async This synchronous endpoint returns the result inline — the simplest path. For production pipelines that need webhook delivery, automatic retry with idempotency, or explicit task cancellation, call
POST /v2/open/taskswithoperation=image_to_imageinstead. Inputs and credit cost are identical.
Instalação e configuração
Guarde a sua chave de API como variável de ambiente no seu runtime.
export CODIA_API_KEY="your-api-key"Autenticação
Envie a sua chave como token Bearer. As chaves são criadas e revogadas no painel.
Authorization: Bearer <your-api-key>Enviar um pedido
Os pedidos JSON aceitam URL públicos. Os endpoints que indicam multipart/form-data também aceitam o carregamento direto de ficheiros.
https://openapi.codia.ai·Preço por modeloEstes exemplos enviam a mesma requisição do exemplo do Sandbox, então funcionam como estão depois de definir CODIA_API_KEY. Troque as URLs pelos seus próprios arquivos públicos.
curl -X POST 'https://openapi.codia.ai/v2/open/image/image_to_image' \
-H "Authorization: Bearer $CODIA_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"image_url": "https://static.codia.ai/image_generate/2026-10-04/8c7b6ac0-2c6f-440b-867b-a1f6b77a2192.jpeg",
"prompt": "Turn this into a holiday gift campaign shot: same bottle, festive wrapping paper, satin ribbon and pine sprigs, warm evening light"
}'curl -X POST 'https://openapi.codia.ai/v2/open/image/image_to_image' \
-H "Authorization: Bearer $CODIA_API_KEY" \
-F 'image=@./product.jpg' \
-F 'prompt=Turn this into a holiday gift campaign shot: same bottle, festive wrapping paper, satin ribbon and pine sprigs, warm evening light'Parâmetros do pedido
Idempotency-Keystring · headeropcionalChave opcional fornecida pelo utilizador (até 255 caracteres). Quando definida, uma resposta bem-sucedida (2xx) fica em cache durante 7 dias. Uma nova tentativa com a mesma chave e o mesmo corpo de pedido devolve a resposta em cache (sem cobrança adicional de créditos); uma nova tentativa com a mesma chave, mas com um corpo diferente, devolve 409. Utilize-a para que repetir um POST após falhas de rede seja seguro. Nos carregamentos multipart/form-data, os pedidos são comparados pelos campos do formulário e pelo conteúdo dos ficheiros, pelo que um carregamento repetido é reproduzido mesmo que o cliente escolha um novo boundary multipart.
image_urlstringobrigatórioURL público da imagem de origem a transformar
promptstringobrigatórioDescrição em texto da transformação pretendida
modelstringopcionalModel that performs the image-to-image transformation. Defaults to nano_banana_2_1. Supported models match Codia Studio for image-to-image generation. Use POST /v2/open/estimate for an exact current quote.
| Model | Best for |
|---|---|
nano_banana_2_1 | Efficient image-to-image edits with improved text and visual consistency (Gemini Flash Image); 1K/2K/4K, up to 14 input images. |
nano_banana_2 | Fast image-to-image edits guided by a text prompt (Gemini 3.1 Flash). |
nano_banana_pro | Studio-quality 4K transformations with advanced reasoning (Gemini 3 Pro). |
gpt_image_2_6 | GPT Image 2.6 with Flare and Sunburst variants; supports low, medium, high, xhigh, max, and auto quality. |
gpt_image | High-fidelity reference-driven edits with crisp text. Supports quality (low/medium/high/auto) and background (transparent/opaque/auto). |
qwen_image_3_pro | Detailed image edits with strong layout and multilingual text rendering. Supports 512/1K/2K outputs, no 4K. Accepts up to 2 reference_images. |
hy_image_3_5 | Reference-guided photorealistic edits at 1K/2K, no 4K. Accepts up to 4 reference_images alongside the source image. |
codia_image | Codia Image reference-guided editing at 1K/2K/4K. Accepts up to 9 reference_images alongside the source image. |
seedream_5_pro | High-precision image editing with advanced visual reasoning. Supports 1K and 2K outputs. |
seedream_5_flash | Fast, low-cost image editing. Supports 1K and 2K outputs at one price. |
seedream_5 | Photorealistic transformations with fine detail. Sizes are 1920-based. |
seedream_5_5 | Latest Seedream for reference-guided photorealistic edits. Supports 1K and 2K outputs. |
recraft_v4_1 | Design-forward image editing with 1K/2K/4K output. |
flux_3_1 | Native 1K/2K/4K editing with up to 10 total input images and fast/quality modes. |
ideogram_v4_6 | Latest Ideogram reference-guided editing for typography-heavy images; supports exact sizes, 1K/2K/4K output, one source plus up to 4 references, and low/medium/high quality. |
"nano_banana_2_1"sizestringopcionalDimensões de saída opcionais no formato WIDTHxHEIGHT, por exemplo 1024x1024. Para GPT Image 2 e 2.6, o preço depende do tamanho de saída selecionado e de quality. Os limites de tamanho, a normalização, o suporte nativo a 4K e os níveis de faturação dependem do modelo selecionado. Um tamanho explícito tem prioridade sobre uma indicação de resolução em quality.
qualitystringopcionalFor gpt_image, use low, medium, high, or auto. For gpt_image_2_6 (including Flare and Sunburst), xhigh and max are also supported. Omitted quality or auto uses the medium billing bucket. For ideogram_v4_6, use auto, low, medium, or high; omitted quality or auto uses medium. For flux_3_1, use fast or quality; omitted quality defaults to quality. For flux_3_1, use fast or quality; omitted quality defaults to quality. For other non-GPT models, this field may carry the resolution tier (for example 1K, 2K, or 4K).
lowmediumhighxhighmaxauto5121K2K4KbackgroundstringopcionalApenas GPT Image. Pede um fundo transparente ou opaco quando suportado. Ignorado pelos modelos não GPT.
transparentopaqueautoreference_imagesstring[]opcionalURL de imagens de referência adicionais para orientar o estilo ou o motivo. Para qwen_image_3_pro, image_to_image aceita até 2 reference_images. Para ideogram_v4_6, podem ser usadas até 5 imagens no total: uma imagem de origem e até 4 referências adicionais.
imagefileobrigatórioFicheiro da imagem de origem
filefileopcionalobsoletoCampo compatível para o ficheiro da imagem de origem (obsoleto: utilize image).
image_urlstringopcionalURL da imagem de origem quando a imagem não é carregada
promptstringobrigatórioPrompt de edição
modelstringopcionalModelo opcional
Esquema da resposta
200URL das imagens processadas
codeintegermessagestringdataobjectdata.image_urlsstring[]URL das imagens geradas ou processadas
{
"code": 0,
"message": "ok",
"data": {
"image_urls": [
"https://static.codia.ai/image_generate/2026-10-04/af70261c-fb9a-4fc5-b732-18cc59f644f5.jpeg"
],
"requested_model": "nano_banana_2_1",
"model": "gemini-nano-banana-2.1",
"provider": "gemini",
"credits_charged": 9
}
}Códigos de erro
Os erros usam o mesmo formato: code espelha o status HTTP, message explica o problema e data é null. Alguns erros incluem um objeto details. Decida pelo código de status, não pelo texto de message.
{
"code": 401,
"message": "Unauthorized",
"data": null
}| Estado | Descrição |
|---|---|
| 400 | O corpo do pedido está malformado ou faltam parâmetros obrigatórios |
| 401 | A chave de API está em falta, é inválida ou foi revogada |
| 402 | O saldo da conta é insuficiente ou a subscrição expirou |
| 403 | A conta não tem acesso a este endpoint |
| 409 | Idempotency-Key reutilizada com um corpo de pedido diferente. |
| 429 | Limite de pedidos atingido. Aguarde o número de segundos indicado no cabeçalho `Retry-After` antes de tentar novamente. |
| 500 | Ocorreu um erro inesperado no servidor |
APIs relacionadas
PopularRecorte o motivo de uma imagem e obtenha um PNG transparente.
NovoDivida uma imagem plana numa pilha ordenada de camadas editáveis.

Aumente a resolução da imagem até 4K mantendo os detalhes nítidos.