I am making a custom GPT that connects to my own server. I am able to get it to work if only sending a string, but if I try to allow a user to also send a file (I only need it to work with image files) through the chatgpt interface it will not send the image, only the string.How do I modify the schema below to send the image as well?
{
"openapi": "3.1.0",
"info": {
"title": "Send an image and a string",
"description": "Makes it super easy to send an image and a string",
"version": "v1.0.0"
},
"servers": [
{
"url": "https://myawesomeserver.loca.lt"
}
],
"paths": {
"/api/gpt/create": {
"post": {
"description": "Create a string and image",
"operationId": "CreateImageandString",
"parameters": [
{
"name": "an_awesome_string",
"in": "query",
"description": "The value of the string we will create",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"description": "image to be uploaded",
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"image": {
"type": "string",
"format": "binary"
}
}
}
}
}
},
"deprecated": false
}
}
},
"components": {
"schemas": {}
}
}
You had it pretty close but you missed a few things with the
encoding
object, which is optional, but a lot more descriptive for the payload. The other thing is the string should be sent in a json body rather than a query parameter. The query parameters should be reserved for search termsThen you need to make sure your the body is actually formatted as a form-data request with the proper headers as required by the service. The main thing is the
content-disposition
header and thename
properties are required. These are typically associated to the form-data elements where the data originated. Make sure theboundary
is properly defined as that is how the body parts are defined.If you're really keen to learn about the multipart message you can find more info in the RFC2045
Information about the
content-disposition
header can be found in RFC6266