ModelNotFoundError
together_ai.errors.ModelNotFoundError
Stack trace
together_ai.errors.ModelNotFoundError: Fine-tuned model 'my-fine-tuned-model' not found or unavailable
File "/app/main.py", line 42, in generate
response = client.models.get('my-fine-tuned-model')
File "/usr/local/lib/python3.9/site-packages/together_ai/client.py", line 88, in get
raise ModelNotFoundError(f"Fine-tuned model '{model_id}' not found or unavailable") Why it happens
This error occurs when the Together AI client attempts to load a fine-tuned model by an ID that does not exist, has been deleted, or the API key lacks permission to access it. It can also happen if the model ID is misspelled or the fine-tuning process did not complete successfully.
Detection
Check for ModelNotFoundError exceptions when calling model loading methods and log the model ID requested to verify correctness before proceeding.
Causes & fixes
The fine-tuned model ID is misspelled or incorrect.
Verify and correct the model ID string to exactly match the fine-tuned model name registered in Together AI.
The fine-tuned model was deleted or never created successfully.
Confirm the fine-tuning job completed successfully and the model is listed in your Together AI dashboard before using it.
API key lacks permission to access the fine-tuned model.
Ensure the API key used has the necessary scopes or roles to access fine-tuned models in your Together AI account.
Code: broken vs fixed
from together_ai import TogetherAIClient
import os
client = TogetherAIClient(api_key=os.environ['TOGETHER_API_KEY'])
# This line triggers ModelNotFoundError if model ID is wrong
response = client.models.get('my-fine-tuned-model')
print(response) from together_ai import TogetherAIClient
import os
client = TogetherAIClient(api_key=os.environ['TOGETHER_API_KEY'])
# Fixed: Correct model ID and ensure model exists
response = client.models.get('correct-fine-tuned-model-id') # corrected model ID
print(response) Workaround
Catch ModelNotFoundError exceptions and fallback to using a base pre-trained model or prompt the user to verify the model ID before retrying.
Prevention
Implement validation checks on model IDs before API calls and maintain a registry of valid fine-tuned model IDs synchronized with Together AI dashboard to avoid invalid references.