Safeguard Docs
Integrations

ModelScope

Connect ModelScope to Safeguard. The SDK token a private connection needs, which token tiers work, what Safeguard reads, and step-by-step setup.

Availability

This integration is switched on per workspace. If you do not see the card under Integrations, ask your Safeguard contact.

What it does

The ModelScope card connects Safeguard to models on ModelScope (modelscope.cn). Each model is scanned at the newest commit of its master branch: Safeguard downloads the files through ModelScope's API, checks each against the SHA-256 ModelScope publishes, runs the model malware scan and records the model in your AI inventory with its licence. Find the card under Integrations in the AI models group.

Public vs private

PublicPrivate
What you enterA model URL, such as https://modelscope.cn/models/<owner>/<model>A Name and a ModelScope SDK token
Credential neededNoneAn SDK token
What you can scanPublic models you add by URLYour account's models, private and gated ones included, plus any you add by URL

Supported auth methods

MethodUse it whenNotes
SDK token (access token)Your own or private modelsSent as Authorization: Bearer on the OpenAPI and as the m_session_id cookie on the file API, as the official SDK does
NonePublic modelsNothing to create

Permissions required

Safeguard only reads. It never pushes, edits or deletes anything.

SDK token

What Safeguard calls (ModelScope API, as the official SDK)Required?What Safeguard uses it for
GET /openapi/v1/users/meRequiredThe username the token belongs to
GET /openapi/v1/models?owner=<you> (every page)RequiredListing your models
GET /openapi/v1/models/{owner}/{name}RequiredWhether a model is private or gated, and its licence
GET /api/v1/models/{owner}/{name}/repo/files and /repoRequiredThe file list with SHA-256, and each file's download

Least privilege: ModelScope issues tokens at read, write or admin level. A read token is all Safeguard needs.

Token types

Token typeWorks?Notes
Read tokenYes (recommended)
Write or admin tokenWorks, not recommendedSafeguard never writes

Expiry: rotate the token at least every 90 days.

What we never need: write or admin access, Studio or deployment access, or another person's token.

Step-by-step setup

Create the credential in ModelScope

  1. Sign in to ModelScope and open your account's Access Token page.
  2. Create a token with read access and copy it.

Or with the ModelScope SDK

To check the token before you paste it into Safeguard:

modelscope login --token "$MODELSCOPE_API_TOKEN"

Connect it in Safeguard

  1. Open Integrations and click Connect on the ModelScope card.
  2. For public models, choose Public, enter a Name, paste a model URL, click Add, then Next.
  3. For your own models, choose Private, enter a Name, paste the token into Access Token and verify it.
  4. Click Next, select the models to scan, review and connect.

Webhooks and triggers

This integration has no webhooks. Each selected model is scanned when you connect it; to rescan new commits, set a schedule under Integrations > Scheduled or rescan by hand from the project.

What we read and store

  • Read: your username, your models' names, licences and visibility, each model's file list with SHA-256, and the files of the models you select.
  • Pinning: ModelScope documents no branch-to-commit lookup, so a branch is pinned to the newest commit its file list names, and only when that commit lists the same files with the same SHA-256.
  • Limits: ModelScope's API lists at most 3,000 models per account and 3,000 files per model; past that Safeguard says so instead of cutting the list silently. Add other models by URL.
  • Stored: the connection's settings, the scan results and AI inventory entry of each scanned model, and the token, encrypted at rest and never shown again after you save it.
  • Not stored: model files. They are read for the scan and removed.
  • No customer data from this integration is sent to third-party LLMs.

Troubleshooting

Message you seeCauseFix
ModelScope refused the ModelScope SDK tokenThe token was revoked or mistypedCreate a new token and paste it again
This ModelScope model is private or gatedThe model needs a token that can read itUse Private with a token, after accepting any gating terms on ModelScope
A scan says ModelScope is still checking a fileModelScope's own file check is not finishedRescan later
A scan fails with a file hash mismatchThe download did not match the SHA-256 ModelScope listsRescan; if it repeats, the model changed during the download

Rotation and disconnect

  • Rotate: create a new token in ModelScope, find the connection under Project Configurations, choose Update, paste the new token and save, then delete the old token.
  • Disconnect: choose Delete from the connection's menu under Project Configurations, then delete the token in ModelScope.

Vendor references

On this page