{"record":{"id":"73d90f1081a3ded3","repo":"openai/openai-python","slug":"passing-both-files-and-content-is-not-supporte","errorCode":null,"errorMessage":"Passing both `files` and `content` is not supported","messagePattern":"Passing both `files` and `content` is not supported","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/openai/_base_client.py","lineNumber":1357,"sourceCode":"        stream_cls: type[_StreamT] | None = None,\n    ) -> ResponseT | _StreamT: ...\n\n    def post(\n        self,\n        path: str,\n        *,\n        cast_to: Type[ResponseT],\n        body: Body | None = None,\n        content: BinaryTypes | None = None,\n        options: RequestOptions = {},\n        files: RequestFiles | None = None,\n        stream: bool = False,\n        stream_cls: type[_StreamT] | None = None,\n    ) -> ResponseT | _StreamT:\n        if body is not None and content is not None:\n            raise TypeError(\"Passing both `body` and `content` is not supported\")\n        if files is not None and content is not None:\n            raise TypeError(\"Passing both `files` and `content` is not supported\")\n        if isinstance(body, bytes):\n            warnings.warn(\n                \"Passing raw bytes as `body` is deprecated and will be removed in a future version. \"\n                \"Please pass raw bytes via the `content` parameter instead.\",\n                DeprecationWarning,\n                stacklevel=2,\n            )\n        opts = FinalRequestOptions.construct(\n            method=\"post\", url=path, json_data=body, content=content, files=to_httpx_files(files), **options\n        )\n        return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))\n\n    def patch(\n        self,\n        path: str,\n        *,\n        cast_to: Type[ResponseT],\n        body: Body | None = None,","sourceCodeStart":1339,"sourceCodeEnd":1375,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/_base_client.py#L1339-L1375","documentation":"Async upload_file_chunked raises this when `file` is in-memory bytes, a filename was supplied, but the `bytes` total-size argument is missing. The upload session cannot be created without a declared size, and bytes objects passed this way don't supply it, so the SDK raises TypeError.","triggerScenarios":"Awaiting upload_file_chunked with bytes, filename=..., but no bytes=len(...) argument.","commonSituations":"Mirroring the low-level three-step upload (create/parts/complete) manually, or copying sync example code into async without the size parameter.","solutions":["Pass bytes=len(data) whenever uploading in-memory bytes","Prefer the high-level file upload helpers that compute size for you","Assert the size is positive before starting"],"exampleFix":"# before\nawait client.uploads.upload_file_chunked(data, purpose='assistants', filename='f.bin')\n# after\nawait client.uploads.upload_file_chunked(data, bytes=len(data), purpose='assistants', filename='f.bin')","handlingStrategy":"validation","validationCode":"assert filename and isinstance(size, int) and size >= 0, 'bytes uploads need filename and byte count'","typeGuard":"def chunked_args_ready(data: object, filename: object, size: object) -> bool:\n    return (not isinstance(data, (bytes, bytearray))) or (bool(filename) and isinstance(size, int) and size >= 0)","tryCatchPattern":null,"preventionTips":["Compute and pass bytes=len(data) for in-memory uploads","Use the managed helpers where possible to avoid size bookkeeping","Verify size matches what you actually stream, or the server rejects completion"],"tags":["openai","uploads","async","content-length","typeerror","in-memory"],"backgroundTag":"missing-filename-in-memory-upload","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}