Download file through redirect with external API


I’m trying to download a file with a custom GPT using a third party API. The OpenAPI spec looks like the one below. The problem is that to download the file, I have to follow a redirect but the GPT does not and only gets an empty response.

Am I missing something? What should I do to make it follow the redirect and download the file?


openapi: 3.1.0
title: Affinity API
version: 1.0.0
operationId: downloadEntityFile
summary: Download an entity file by file ID.
- name: file_id
in: path
required: true
type: string
example: “12345”
- application/octet-stream
description: A file download response, which may include redirects
description: URL to follow for the file download
type: string
type: string
format: binary
description: Redirect to the file download URL
description: URL to follow for the file download
type: string
- basicAuth:

Hi and welcome to the developer forum!

GPT’s cannot be accessed via the API, they are for ChatGPT users only. You can look into the Assistants API which offers similar functionality, but you will need to implement any internet connectivity yourself.

Thank you for your answer but that’s not what I meant.

I am not trying to access the GPT via API. I am building a custom GPT with actions (i.e. the custom GPT will be accessing third party APIs specified with OpenAPI). It is in that context that I am having the issue described above

That still will not work, Custom GPTs can only be accessed from the ChatGPT website and cannot be accessed externally.

I am accessing the custom GPT from ChatGPT only (no API there). It is the custom GPT that has to access a third party API to fetch some info and answer the prompt from ChatGPT:
User ↔ ChatGPT ↔ Custom GPT Action ↔ Third Party API
It already works for many (Third Party) API calls just not for the one I describe here

Ahhh, my bad, I get you now. I don’t think the GPTs internal system will download from urls, not something I have tested, but that would seem to be potentially problematic. Have you had a GPT do this with a different endpoint?

Suggestion for a workaround:

You set up your own API and invoke a method via a custom action to download the file regardless of the redirects and then provide this file to the GPT as the return.

I found the answer in the doc:

The be able to send files to a custom GPT the third party API has to be very specific. This is a bit odd because it means the custom GPT can’t fetch files from API we don’t control. The only solution would then be to deploy my own proxy API as suggested by vb.

1 Like