An error occured when getting the model upload URL: 401 Client Error: Unauthorized

Describe your question/issue here! (delete this when you post)

  • Project Type: Players detection
  • Operating System & Browser: Google Colab
  • Project Universe Link or Workspace/Project ID: project = rf.workspace(“felipemoura-uhruu”).project(“quartas_ourteam-82yjc”)
  • Do you grant Roboflow Support permission to access your Workspace for troubleshooting? (Yes/No): Yes

I have trained a model inside the google colab and I am trying to deploy de model, but there is this unauthorized message. My api-key is correct and I am using the same code I always used. However, now, it is unavailable. Please, can someone help me?

Error:

An error occured when getting the model upload URL: 401 Client Error: Unauthorized for url: https://api.roboflow.com/felipemoura-uhruu/quartas_ourteam-82yjc/1/uploadModel?

Thanks!!

Hi Felipe,

Thanks for the details! That 401 can come from a couple of different things, and the Python package hides the actual error message. Could you run this in your Colab and paste the output?

import requests
r = requests.get(
    "https://api.roboflow.com/felipemoura-uhruu/quartas_ourteam-82yjc/1/uploadModel",
    params={"api_key": "YOUR_API_KEY", "modelType": "THE_MODEL_TYPE_YOU_PASS_TO_DEPLOY", "nocache": "true"},
)
print(r.status_code, r.text)

Please remove your API key before posting the output. Also let us know:

  • the exact model_type you pass to deploy()
  • your package version (the output of !pip show roboflow)

Hi, Nathan. Thanks for you reply.

Please, find below the answers:

import requests

r = requests.get(

“https://api.roboflow.com/felipemoura-uhruu/quartas_ourteam-82yjc/1/uploadModel”,

params={“api_key”: “XXXX”, “modelType”: “yolov8”, “nocache”: “true”},

)

print(r.status_code, r.text)

401 {“message”:“Model type \“yolov8\” is not recognized.”,“type”:“InvalidModelTypeException”,“hint”:“Please specify a supported model type with its size suffix.”}


That was my deploy command:

project.version(dataset.version).deploy(model_type=“yolov8”, model_path=f"{HOME}/runs/detect/train/")


Name: roboflow
Version: 1.1.48
Summary: Official Python package for working with the Roboflow API
Home-page: GitHub - roboflow/roboflow-python: The official Roboflow Python package. Manage your datasets, models, and deployments. Roboflow has everything you need to build a computer vision application. · GitHub
Author: Roboflow
Author-email:
License: UNKNOWN
Location: /usr/local/lib/python3.13/dist-packages
Requires: certifi, cycler, filetype, idna, kiwisolver, matplotlib, numpy, opencv-python-headless, Pillow, python-dateutil, python-dotenv, PyYAML, requests, requests-toolbelt, six, tqdm, urllib3
Required-by:

Thanks for your support,

Felipe.

Hi Felipe,

Thank you for running that quick test. Our server now needs the model size in the model type (like yolov8n), and your version of the Roboflow package (1.1.48) sends a plain "yolov8" as-is. Either fix below will get the upload working.

Option 1: upgrade the Roboflow package. Newer versions read the size from your trained weights and add it automatically, so your existing deploy() call will work unchanged:

!pip install -U roboflow

Restart the Colab runtime after upgrading, then run your deploy() call again.

Option 2: keep your current version and pass the exact size you trained. For example, if you trained from yolov8n.pt:

project.version(dataset.version).deploy(model_type="yolov8n", model_path=f"{HOME}/runs/detect/train/")

Use yolov8s, yolov8m, yolov8l or yolov8x if you trained one of those sizes instead.

Sorry the original error message wasn’t more helpful, I’ll get this feedback to our product team. Let us know if you run into any other issue!

Best Regards,
Nathan Badanjek

Dear Nathan,

Thanks for your feedback. Option 2 worked! =)

My best regards!