Facing issue with creating a thread in Open AI using rest api in c#

We followed the below steps when we tried to use rest api’s for c# in open ai and it is throwing error. Please suggest.

  1. Add file: Added file to open ai using open api v1 files and it returned the file id in response

  2. Created a assistant using open api v1 assistants and it returned assistant id in response

  3. Created a thread using open api v1 threads and got error.

Below is the input that we gave in c#

var array = new
{
new
{
role = “user”,
content = create_a_thread_content,
attachments = new
{
new
{
file_id = fileId,
tools = new
{
new { type = “file_search” }
}
}
}
}
};

string json = JsonConvert.SerializeObject(array, Formatting.Indented);

object data = new { messages= array };

Response:

{
“error”: {
“message”: "Files with extensions [none] are not supported for retrieval.
“type”: “invalid_request_error”,
“param”: null,
“code”: “unsupported_file”
}
}

You seem to have conflation of v1 header and v2 methods. Also that you are likely sending a file content but no file name.

I would develop using v2 file search, not v1 retrieval, as the v1 API will be the first to go in December (and the methods of retrieval are expensive document navigation by AI).

Full headers to use, as sending project also is especially important for data scoping:

OpenAI-Beta: assistants=v2
Authorization: Bearer $OPENAI_API_KEY
OpenAI-Organization: OPENAI_ORG_ID
OpenAI-Project: $OPENAI_PROJECT_ID

Then files that will be attached to a user message are simply references to a file_id that you’ve already uploaded to your account file storage. That is where the file name is important to also send with MIME, along with the “assistants” file purpose.

2 Likes