ModelNotFoundError
replicate.exceptions.ModelNotFoundError
Stack trace
replicate.exceptions.ModelNotFoundError: Model version 'v1.2.3' not found for model 'owner/model-name'
Why it happens
The Replicate API requires a valid model version identifier to run a model. If the version string is incorrect, misspelled, or the version has been deprecated or removed, the API returns a ModelNotFoundError. This prevents running models with invalid or non-existent versions.
Detection
Catch replicate.exceptions.ModelNotFoundError when calling client.models.get_version() or client.models.get() and log the requested version string to verify correctness before retrying.
Causes & fixes
Incorrect or misspelled model version string passed to the Replicate client
Verify the exact model version string from the Replicate model page or API and use that exact string in your code.
Model version has been deprecated or removed from Replicate
Update your code to use a currently supported model version by checking the Replicate model repository or documentation.
Using a generic model name without specifying a required version
Explicitly specify the model version when calling the Replicate API to avoid ambiguity.
Code: broken vs fixed
import os
from replicate import Client
client = Client(api_token=os.environ["REPLICATE_API_TOKEN"])
# This line triggers ModelNotFoundError due to invalid version
model_version = client.models.get_version("owner/model-name", "v1.2.3") import os
from replicate import Client
client = Client(api_token=os.environ["REPLICATE_API_TOKEN"])
# Fixed: Use correct existing version string
model_version = client.models.get_version("owner/model-name", "correct-version-string")
print("Model version fetched successfully") Workaround
Wrap the call to get_version() in try/except ModelNotFoundError, then fallback to fetching the latest available version or prompt the user to update the version string.
Prevention
Always fetch and cache the list of available model versions from Replicate before running models, and validate version strings against this list to avoid invalid version errors.