Uploaded File ID for fine-tuning

I want to fine tune GPT model, I ran this in visual studio code:

import os
import openai
openai.api_key = “I wrote my key here
openai.File.create(
file=open(“train_output.jsonl”, “rb”),
purpose=‘fine-tune’
)

Now, I want to create the fine-tune job, but I can’t find the FileID anywhere.
I would be happy to know where I can find it.

Hello

When you upload the file through OpenAI’s API, the API’s response will include the file’s ID. You can use this file ID for the subsequent fine-tuning process. Ensure you capture or log this response when you upload the file to retrieve the FileID. For more details and a complete overview, you can consult the API documentation on the following page: OpenAI Platform.

I don’t have any experience in coding - I still don’t understand how to access the API response, the code was run using VSC, but there is no message in the terminal or in the output.

If you have no experience in coding you should try to at least take a week and learn some basics.

You can use chatgpt as a pair programmer for that which can explain the why and what while doing that and also can give you some ideas of simple scripts you could build… but you can’t skip that.

You have to actually write code to become a coder.

Welcome to the developer community by the way.

1 Like

Hi, the file id was referred in the object that was returned as a reply to you upload file request. But your code did not save the response. Now you can find the file id if you use the API call to list files (see in docs for details).

Hope that helps.

1 Like

I advise you to use chatgpt itself to have assistance in programming Example Off simple Python code to receive the File ID Using ChatGPT:

import requests

OPENAI_API_KEY = “”

def upload_file(file_path):
url = “https://api.openai.com/v1/files
headers = {
“Authorization”: f"Bearer {OPENAI_API_KEY}"
}
with open(file_path, ‘rb’) as f:
response = requests.post(url, headers=headers, files={“file”: f}, data={“purpose”: “fine-tune”})
return response.json()

if name == “main”:
file_path = “data_final.jsonl”
upload_and_get_file_id(file_path)