neuron-ai
neuron-ai copied to clipboard
Attach file by ID (OpenAI Responses, Anthropic, Mistral)
OpenAI API has functionality to upload a file and reuse it in future requests https://platform.openai.com/docs/api-reference/files/create (same functionality is available for Mistral and Claude)
This saves a lot of time and tokens when you need to use the same file in a few prompts. E.g., I use it once to get a summary and then one more time to validate this summary against the document.
Upload file:
curl https://api.openai.com/v1/files \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F purpose="fine-tune" \
-F file="@mydata.jsonl"
-F expires_after[anchor]="created_at"
-F expires_after[seconds]=2592000
Then this file can be used by ID in future requests to the API https://platform.openai.com/docs/guides/pdf-files?api-mode=responses#uploading-files
Use previously uploaded file by id "file_id": "file-6F2ksmvXxt4VdoqmHRw6kL":
curl "https://api.openai.com/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-5",
"input": [
{
"role": "user",
"content": [
{
"type": "input_file",
"file_id": "file-6F2ksmvXxt4VdoqmHRw6kL"
},
{
"type": "input_text",
"text": "What is the first dragon in the book?"
}
]
}
]
}'