Not Found for url: https://www.dmxapi.cn/v1/multimodal/chat/completions(请核对模型名、接...

2025年11月18日 15:06 状态: processing

🚨 错误信息

C:\Users\郑豪\PycharmProjects\PythonProject1\.venv\Scripts\python.exe C:\Users\郑豪\PycharmProjects\PythonProject1\dmxapi_image_tagging.py ============================================================ 当前Prompt: 请为这张穿搭图片打标签,严格遵守: 1. 标签从以下体系选,每类最多2个,总数≤8个: 风格类:休闲风、通勤风、甜妹风、酷飒风、复古风、运动风、法式风、韩系风、日系风 场景类:日常出行、职场办公、校园穿搭、约会、旅游度假、运动健身 单品类:T恤、衬衫、卫衣、毛衣、外套、裤子、裙子、连衣裙、运动鞋、高跟鞋、包包 色系类:黑色系、白色系、大地色系、莫兰迪色系、亮色系、同色系 季节类:春季、夏季、秋季、冬季、四季通用 版型类:宽松型、修身型、oversize、阔腿、收腰 2. 仅返回英文逗号分隔的标签列表,无其他内容。 示例:休闲风,日常出行,T恤,阔腿裤,大地色系,秋季,宽松型 ============================================================ 处理图片:test_fashion.jpg C:\Users\郑豪\PycharmProjects\PythonProject1\.venv\Lib\site-packages\urllib3\connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'www.dmxapi.cn'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings warnings.warn( 标签结果:失败:404 Client Error: Not Found for url: https://www.dmxapi.cn/v1/multimodal/chat/completions(请核对模型名、接口路径) 进程已结束,退出代码为 0

🤖 AI解决方案

代码糕手 - 专业报错分析报告

错误翻译

原文:404 Client Error: Not Found for url: https://www.dmxapi.cn/v1/multimodal/chat/completions
译文:404客户端错误:请求的URL地址未找到

原因分析

根本原因:API接口路径不正确或模型名称错误
  • 错误位置:API请求到 https://www.dmxapi.cn/v1/multimodal/chat/completions
  • 具体问题:服务器返回404状态码,表示请求的资源不存在
  • 解决方案

    # 修正后的API调用代码示例
    import requests
    
    # 正确的API端点示例(需要查阅DMXAPI文档获取准确路径)
    def get_image_tags(image_path):
        url = "https://www.dmxapi.cn/v1/正确的端点路径"  # 需要替换为实际有效端点
        
        headers = {
            "Authorization": "Bearer YOUR_API_KEY",
            "Content-Type": "application/json"
        }
        
        # 修正请求参数
        payload = {
            "model": "正确的模型名称",  # 确认模型名称是否正确
            "messages": [
                {
                    "role": "user",
                    "content": "图片分析请求内容"
                }
            ]
        }
        
        # 添加SSL证书验证(消除警告)
        response = requests.post(url, headers=headers, json=payload, verify=True)
        return response.json()

    ️ 预防措施

  • API文档核对:调用前仔细查阅官方API文档,确认端点路径和参数格式
  • 错误处理机制:添加完整的异常捕获和状态码检查
try:
    response = requests.post(url, timeout=10, verify=True)
    response.raise_for_status()  # 自动检查HTTP错误
except requests.exceptions.RequestException as e:
    print(f"API请求失败: {e}")

---
需要进一步协助?请提供更详细的API文档链接或具体错误堆栈信息。