diff --git a/services/xai_service.py b/services/xai_service.py index eca4758..fb219d8 100644 --- a/services/xai_service.py +++ b/services/xai_service.py @@ -69,8 +69,16 @@ class XAIService: url = f"{XAI_FILES_URL}/v1/files" headers = {"Authorization": f"Bearer {self.api_key}"} - form = aiohttp.FormData() - form.add_field('file', file_content, filename=filename, content_type=mime_type) + # Create multipart form with explicit UTF-8 filename encoding + # aiohttp automatically URL-encodes filenames with special chars, + # but xAI expects raw UTF-8 in the filename parameter + form = aiohttp.FormData(quote_fields=False) + form.add_field( + 'file', + file_content, + filename=filename, + content_type=mime_type + ) async with session.post(url, data=form, headers=headers) as response: try: