{"record":{"id":"ddf025f73006d49c","repo":"crewAIInc/crewAI","slug":"unsupported-content-type-for-responses-api-conte","errorCode":null,"errorMessage":"Unsupported content type for Responses API: {content_type}","messagePattern":"Unsupported content type for Responses API: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/crewai-files/src/crewai_files/formatting/openai.py","lineNumber":66,"sourceCode":"\n        Raises:\n            TypeError: If resolved type is not supported.\n        \"\"\"\n        is_image = content_type.startswith(\"image/\")\n        is_pdf = content_type == \"application/pdf\"\n\n        if isinstance(resolved, FileReference):\n            if is_image:\n                return {\n                    \"type\": \"input_image\",\n                    \"file_id\": resolved.file_id,\n                }\n            if is_pdf:\n                return {\n                    \"type\": \"input_file\",\n                    \"file_id\": resolved.file_id,\n                }\n            raise TypeError(\n                f\"Unsupported content type for Responses API: {content_type}\"\n            )\n\n        if isinstance(resolved, UrlReference):\n            if is_image:\n                return {\n                    \"type\": \"input_image\",\n                    \"image_url\": resolved.url,\n                }\n            if is_pdf:\n                return {\n                    \"type\": \"input_file\",\n                    \"file_url\": resolved.url,\n                }\n            raise TypeError(\n                f\"Unsupported content type for Responses API: {content_type}\"\n            )\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-files/src/crewai_files/formatting/openai.py#L48-L84","documentation":"The OpenAI Responses API formatter only accepts images (input_image) and PDFs (input_file) as file content blocks. When a FileReference is formatted and its content_type is neither an image MIME type nor application/pdf, it raises TypeError with the unsupported content type in the message. This is a hard capability boundary of the Responses API, mirrored by the library.","triggerScenarios":"Attaching a FileReference whose content_type is e.g. text/csv, audio/mpeg, video/mp4, or application/json to an OpenAI Responses-API crew; uploading a .txt or .docx via the files API and passing the resulting file_id reference to the formatter.","commonSituations":"Porting a pipeline from Chat Completions (which took plain text file content) to the Responses API; assuming any file type can be attached because file_id uploads succeed; feeding provider-agnostic attachments into an OpenAI-specific formatter.","solutions":["Convert the file content to text and include it in the prompt instead of as a file block.","Only attach image/* or application/pdf files via FileReference to Responses API calls.","Re-encode the document to PDF before uploading if the model must 'see' it as a document.","Branch on content_type before formatting and drop/skip unsupported attachments with a warning."],"exampleFix":"# before\nref = FileReference(file_id=\"file-123\", content_type=\"text/csv\")  # not image/pdf\nblock = responses_formatter.format_block(ref)  # TypeError\n\n# after\nif ref.content_type.startswith(\"image/\") or ref.content_type == \"application/pdf\":\n    block = responses_formatter.format_block(ref)\nelse:\n    csv_text = download_and_read(ref)\n    task_context += f\"\\nFile contents:\\n{csv_text}\"","handlingStrategy":"validation","validationCode":"def responses_attachable(content_type: str) -> bool:\n    return content_type.startswith(\"image/\") or content_type == \"application/pdf\"\n\nif isinstance(resolved, FileReference) and not responses_attachable(resolved.content_type):\n    # inline as text instead of a file block\n    attachments_text.append(read_file_text(resolved))","typeGuard":"def is_responses_file(ref: FileReference) -> TypeGuard[FileReference]:\n    ct = ref.content_type or \"\"\n    return ct.startswith(\"image/\") or ct == \"application/pdf\"","tryCatchPattern":"try:\n    block = responses_formatter.format_block(resolved)\nexcept TypeError as e:\n    if \"Unsupported content type\" in str(e):\n        logger.warning(\"dropping unsupported attachment %s\", getattr(resolved, 'content_type', '?'))\n        block = None  # or inline text\n    else:\n        raise","preventionTips":["Whitelist attachments to image/* and application/pdf for Responses API tasks.","Convert other documents to text or PDF before attaching.","Centralize the content-type gate in one helper used by every attachment path."],"tags":["openai","responses-api","content-type","formatter","typeerror"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}