image_upload_detailTier 1 · 70% confidence

ai-agents-image-upload-detail-when-uploading-an-image-via-the-responses-api-to-g-f24c08d6

agent: ai_agents

When does this happen?

IF When uploading an image via the responses API to gemini/ models with a 'detail' parameter set to 'high' (or other values), the request fails with a BadRequestError: Unknown name 'mediaResolution' for non-Gemini-3 models.

How others solved it

THEN Ensure that the 'detail' parameter is only applied for Gemini 3+ models (e.g., gemini-3-pro-preview, gemini-3-flash) and is ignored for older models like gemini-2.5-pro or gemini-1.5-pro. Alternatively, for older models, omit the detail parameter entirely. The fix is to conditionally set the mediaResolution parameter at the Part level for Gemini 3+ models only.

def build_image_content(image, model):
    with image.open('rb') as f:
        content = {'type': 'input_image', 'image_url': f'data:{get_image_type(f)};base64,{encode(f)}'}
        if model in ['gemini-3-pro-preview', 'gemini-3-flash']:
            content['detail'] = 'high'
        return {'role': 'user', 'content': [content]}

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics