{"record":{"id":"055f3435b91b8fe5","repo":"sigoden/aichat","slug":"the-model-does-not-support-network-images-networ","errorCode":null,"errorMessage":"The model does not support network images: {network_image_urls:?}","messagePattern":"The model does not support network images: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/client/bedrock.rs","lineNumber":431,"sourceCode":"                        }));\n                    }\n                    vec![\n                        json!({\n                            \"role\": \"assistant\",\n                            \"content\": assistant_parts,\n                        }),\n                        json!({\n                            \"role\": \"user\",\n                            \"content\": user_parts,\n                        }),\n                    ]\n                }\n            }\n        })\n        .collect();\n\n    if !network_image_urls.is_empty() {\n        bail!(\n            \"The model does not support network images: {:?}\",\n            network_image_urls\n        );\n    }\n\n    let mut body = json!({\n        \"inferenceConfig\": {},\n        \"messages\": messages,\n    });\n    if let Some(v) = system_message {\n        body[\"system\"] = json!([\n            {\n                \"text\": v,\n            }\n        ])\n    }\n\n    if let Some(v) = model.max_tokens_param() {","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/client/bedrock.rs#L413-L449","documentation":"The Bedrock request builder collects image URLs found in user messages that are network URLs (http/https) rather than base64 data. Since Bedrock's InvokeModel API requires images to be passed inline as base64 content, network-hosted image URLs cannot be forwarded, so the builder fails before any request is sent.","triggerScenarios":"build_chat_completions_body (via chat_completions_builder) finds a non-empty network_image_urls list — i.e. a UserContent message contains an image whose source is a remote URL instead of embedded base64 data.","commonSituations":"Passing image URLs scraped from the web directly in chat messages, forgetting to download and base64-encode images before calling Bedrock-backed models, or porting code written for OpenAI (which accepts URLs) to Bedrock.","solutions":["Download the image, base64-encode it, and pass it as inline data (ImageMediaType with decoded data) instead of a URL","Preprocess messages to convert network image URLs to base64 before calling the client","Use a provider that supports URL images (e.g. OpenAI) if inline images are not feasible","Strip image content from messages when targeting Bedrock models"],"exampleFix":"// before\nUserContent::Image(ImageUrl::Url(\"https://example.com/cat.png\".into()))\n// after\nlet bytes = reqwest::get(url).await?.bytes().await?;\nUserContent::Image(ImageUrl::Decode(String::from(\"png\"), base64::encode(bytes)))","handlingStrategy":"validation","validationCode":"let network_imgs: Vec<_> = messages.iter()\n    .flat_map(|m| m.images())\n    .filter(|img| img.url().map_or(false, |u| u.starts_with(\"http\")))\n    .collect();\nif !network_imgs.is_empty() {\n    // download + base64-encode before sending\n}","typeGuard":"fn is_network_image(img: &Image) -> bool {\n    matches!(img, Image::Url(u) if u.starts_with(\"http\"))\n}","tryCatchPattern":null,"preventionTips":["Always convert remote image URLs to base64 inline data for Bedrock","Build a preprocessing step in the message pipeline","Add a unit test that rejects http image URLs for Bedrock targets","Prefer providers that accept URL images when URLs are required"],"tags":["bedrock","images","unsupported-feature","request-validation"],"backgroundTag":"unsupported-operation","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}