Notfound error when uploading a file to azure openai

Amin Elsehemy 0 Reputation points
2024-10-17T21:33:04.98+00:00

NotFoundError: Error code: 404 - {'statusCode': 404, 'message': 'Resource not found'}
Getting the above error when running

file_id = client.files.create(
  file=open("/Users/amne/Documents/GitHub/genai-platform-blueprints/ModelAsService/openai/training_examples.jsonl", "rb"),
  purpose='fine-tune'
).id				

I have properly setup the client and verfied it as I used for generating the samples. please advise

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,306 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Pavankumar Purilla 1,305 Reputation points Microsoft Vendor
    2024-10-18T04:12:39.4666667+00:00

    Hi Amin Elsehemy,
    Greetings & Welcome to Microsoft Q&A forum! Thanks for posting your query!

    I understand that you are encountering a 404 NotFoundError.

    Here are some troubleshooting steps to help resolve this issue:

    • Ensure that the file path you're specifying is correct. Double-check the file location and the path provided in your code.
    • Verify that your environment variables for the Azure OpenAI endpoint and API key are correctly set. You can confirm this by printing os.getenv("AZURE_OPENAI_ENDPOINT") and os.getenv("AZURE_OPENAI_API_KEY") to ensure the correct values are being passed.
    • Make sure that the Azure OpenAI service is available and configured correctly in your resource group, and that you are using the right API version (2024-05-01-preview or later, depending on your specific service setup).
    • Test uploading a simple file from the same directory as your script to verify that there isn’t an issue with the file path.

    Here’s the updated code for your reference:

    # Upload fine-tuning files
    
    import os
    from openai import AzureOpenAI
    
    client = AzureOpenAI(
      azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"), 
      api_key=os.getenv("AZURE_OPENAI_API_KEY"),  
      api_version="2024-05-01-preview"  # This API version or later is required to access seed/events/checkpoint capabilities
    )
    
    training_file_name = 'file path'
    validation_file_name = 'file path'
    
    # Upload the training and validation dataset files to Azure OpenAI with the SDK.
    
    training_response = client.files.create(
        file=open(training_file_name, "rb"), purpose="fine-tune"
    )
    training_file_id = training_response.id
    
    validation_response = client.files.create(
        file=open(validation_file_name, "rb"), purpose="fine-tune"
    )
    validation_file_id = validation_response.id
    
    print("Training file ID:", training_file_id)
    print("Validation file ID:", validation_file_id)
    

    Here is the screenshot of my results for your reference:
    2024-10-18 07_51_34-● gpt4.ipynb - Azure Openai - Visual Studio Code Please refer for more information: Prepare your training and validation data
    If you continue to experience difficulties, please feel free to reach out and will escalate the issue to the appropriate team to ensure it is resolved promptly.

    I hope this information helps.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful.


  2. Zandarashvili, Levani 0 Reputation points
    2024-11-21T20:19:20.21+00:00

    Hello. I'm having a similar problem, and this solution doesn't help. My code is exactly as you described, but I'm still getting Resource Not Found error.
    I posted my question here: https://learn.microsoft.com/en-us/answers/questions/2121821/cant-upload-file-through-api

    I know that my creds/keys are fine, because if I generate chat response using that client, it works fine, but when I try to upload a file or do fine-tuning, I get an error.

    User's image

    User's image

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.