Hello Aqib Riaz,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
Regarding your experience with Unknown Model error. I have put together the following steps to identify and resolve the root causes of the error "unavailable_model: gpt-4o-mini". This guide ensures the problem is addressed effectively and each step includes actionable insights, necessary code examples, and references to Azure documentation.
- To ensure the models are correctly deployed, log into the Azure Portal:
- Navigate to your Azure OpenAI Resource or Azure AI Foundry Resource.
- Under the Model Deployments section, locate the models. Verify whether
gpt-4o-mini
andtext-embedding-ada-002
are listed as active deployments. - Azure OpenAI Documentation - Model Deployment - https://zcusa.951200.xyz/en-us/azure/ai-services/openai/concepts/models
- Replace the model names in your code with the exact names found in the Azure Portal. Often, errors arise from mismatched names. For an example:
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
# Replace with the exact names shown in the Azure Portal
model_info = chat.get_model_info("DEPLOYED_MODEL_NAME")
embedding = embeddings.embed(model="DEPLOYED_EMBEDDING_MODEL_NAME", input=search_query)
This ensures your application uses the correct deployment identifiers.
- To programmatically confirm available models, use the Azure SDK to list deployed models. This is especially useful to cross-check portal information. For an example:
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
import os
# Initialize client with connection string and credential
project = AIProjectClient.from_connection_string(
conn_str=os.environ["AIPROJECT_CONNECTION_STRING"], credential=DefaultAzureCredential()
)
# List and display available models
available_models = project.inference.list_models()
print("Available models:", available_models)
If the desired model (gpt-4o-mini
) is not listed, it has not been deployed or may be unavailable in your subscription or region. Check for more here - https://zcusa.951200.xyz/en-us/python/api/overview/azure/ai?view=azure-python
- Ensure the models are deployed in the correct region:
- Check your connection string and confirm it matches the region of your resource.
- Verify that the resource type (e.g., Azure OpenAI Foundry) supports the models you intend to use.
Certain models may have regional restrictions or limited availability. For instance, some high-performance models are available only in select regions. Check Azure OpenAI Region Availability here - https://zcusa.951200.xyz/en-us/azure/ai-services/openai/overview#regional-availability
- Incorrect or missing environment variables can cause authentication or connection errors:
Verify the .env
file contains:
AIPROJECT_CONNECTION_STRING
: The correct connection string for your Azure AI resource.
INTENT_MAPPING_MODEL
and EMBEDDINGS_MODEL
: The names of deployed models as shown in the Azure Portal. For an example:
import os
# Check environment variable setup
print("Connection String:", os.getenv("AIPROJECT_CONNECTION_STRING"))
print("Intent Model:", os.getenv("INTENT_MAPPING_MODEL"))
print("Embeddings Model:", os.getenv("EMBEDDINGS_MODEL"))
- If the problem persists:
- Use the Azure CLI or Portal to redeploy the models using bash command:
az openai deployment create --resource-group <resource-group> --name <deployment-name> --model <model-id>
- Start with models like
gpt-3.5-turbo
orada
to verify deployment configurations. - Read more about Azure CLI OpenAI Deployment here - https://zcusa.951200.xyz/en-us/cli/azure/openai
NOTE: This is an additional step. If none of these steps resolve the issue:
Ensure your Azure subscription includes access to restricted models AND / OR contact Azure support from your Azure Portal.
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.