Docs
GPTs API

GPTs API

The complete documentation for GoAPI's GPTs API.

Developers can now add GPTs into their own applications and projects! Sign up now and start integrating! Check out the GPTs API pricing here.

Note: The PPU service option is only available for Developer Plan or above, the BYOA service option is available for all subscription plans.



Conversation API

Create/add-message/add-file to a multimodal ChatGPT conversation

Available models:

  1. gpt-4
  2. gpt-4o

Available domains:

  1. If you are experience server issues with your API calls, please see try different available domains as per GoAPI Domains.

Create conversation


POST

https://api.goapi.xyz/api/chatgpt/v1/conversation

This endpoint allows you to create a conversation with ChatGPT Plus.

Parameters:

Header
NameTypeRequiredDescription
X-API-Keystring✔️YOUR-GOAPI-KEY
Body
NameTypeRequiredDescription
modelstring✔️'gpt-4' or 'gpt-4o'
contentjson✔️content json, see below
gizmo_idstringthe gizmo_id if you want to use GPTs, model must be 'gpt-4-gizmo'

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error
  • If you are experience server issues with your API calls, please see try different available domains as per GoAPI Domains.


Request Body Explained

{
    "model": "gpt-4o",
    "content": {
        "content_type": "text",
        "parts": [
            "hello, introduce yourself"
        ]
    },
    "gizmo_id": "g-3w1rEXGE0" //you can get this id from ChatGPT GPTs conversation page, you will need to remove the GPTs names
    //for example: https://chat.openai.com/g/g-3w1rEXGE0-web-browser , the gizmo_id is g-3w1rEXGE0
}

Request Example

import requests
import json
 
url = "https://api.goapi.xyz/api/chatgpt/v1/conversation"
 
payload = json.dumps({
  "model": "gpt-4",
  "content": {
    "content_type": "text",
    "parts": [
      "draw me a wild cat"
    ]
  }
})
headers = {
  'X-API-Key': 'YOUR_GOAPI_KEY',
  'Content-Type': 'application/json'
}
 
response = requests.request("POST", url, headers=headers, data=payload)
 
print(response.text)

Response Example

this API returns only STREAM response
data: {"message": {"id": "3bbbf479-f201-4530-bc3b-3820531daced", "author": {"role": "system", "name": null, "metadata": {}}, "create_time": null, "update_time": null, "content": {"content_type": "text", "parts": [""]}, "status": "finished_successfully", "end_turn": true, "weight": 0.0, "metadata": {}, "recipient": "all"}, "conversation_id": "4f33f3be-191e-49a2-8ea0-446a78fefeeb", "error": null}
 
data: {"message": {"id": "af818153-563c-4cf2-959c-c11578cc24f6", "author": {"role": "user", "name": null, "metadata": {}}, "create_time": 1704793809.059035, "update_time": null, "content": {"content_type": "text", "parts": ["draw me a wild cat"]}, "status": "finished_successfully", "end_turn": null, "weight": 1.0, "metadata": {"timestamp_": "absolute", "message_type": null}, "recipient": "all"}, "conversation_id": "4f33f3be-191e-49a2-8ea0-446a78fefeeb", "error": null}
 
data: {"message": {"id": "7e7e84ef-12e9-4425-af6b-38103a76599b", "author": {"role": "assistant", "name": null, "metadata": {}}, "create_time": 1704793809.103825, "update_time": null, "content": {"content_type": "code", "language": "json", "text": ""}, "status": "in_progress", "end_turn": null, "weight": 1.0, "metadata": {"inline_gizmo_id": null, "message_type": "next", "model_slug": "gpt-4", "parent_id": "af818153-563c-4cf2-959c-c11578cc24f6"}, "recipient": "dalle.text2im"}, "conversation_id": "4f33f3be-191e-49a2-8ea0-446a78fefeeb", "error": null}
 
data: {"conversation_id": "4f33f3be-191e-49a2-8ea0-446a78fefeeb", "message_id": "af818153-563c-4cf2-959c-c11578cc24f6", "is_completion": false, "moderation_response": {"flagged": false, "blocked": false, "moderation_id": "modr-8f32H4jN06GiEvQ5lqdT2nnmNDYn1"}}
 
data: {"message": {"id": "7e7e84ef-12e9-4425-af6b-38103a76599b", "author": {"role": "assistant", "name": null, "metadata": {}}, "create_time": 1704793809.103825, "update_time": null, "content": {"content_type": "code", "language": "json", "text": "{\""}, "status": "in_progress", "end_turn": null, "weight": 1.0, "metadata": {"inline_gizmo_id": null, "message_type": "next", "model_slug": "gpt-4", "parent_id": "af818153-563c-4cf2-959c-c11578cc24f6"}, "recipient": "dalle.text2im"}, "conversation_id": "4f33f3be-191e-49a2-8ea0-446a78fefeeb", "error": null}


Add message to conversation


POST

https://api.goapi.xyz/api/chatgpt/v1/conversation/{conversation-id}

This endpoint allows you to add a message to an *existing* conversation.

Parameters:

Header
NameTypeRequiredDescription
X-API-Keystring✔️YOUR-GOAPI-KEY
Body
NameTypeRequiredDescription
modelstring✔️'gpt-4' or'gpt-4-gizmo'
contentjson✔️content json, see below

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Request Body Explained

{
    "content": {
        "content_type": "text",
        "parts": [
            "draw me a wild cat"
        ]
    }
}

Request Example

import requests
import json
 
url = "https://api.goapi.xyz/api/chatgpt/v1/conversation/asdlkjfoaiweghlasjdflkjad"
 
payload = json.dumps({
  "content": {
    "content_type": "text",
    "parts": [
      "draw me a wild cat"
    ]
  }
})
headers = {
  'X-API-Key': 'YOUR_GOAPI_KEY',
  'Content-Type': 'application/json'
}
 
response = requests.request("POST", url, headers=headers, data=payload)
 
print(response.text)

Response Example

this API returns only STREAM response
data: {"message": {"id": "3bbbf479-f201-4530-bc3b-3820531daced", "author": {"role": "system", "name": null, "metadata": {}}, "create_time": null, "update_time": null, "content": {"content_type": "text", "parts": [""]}, "status": "finished_successfully", "end_turn": true, "weight": 0.0, "metadata": {}, "recipient": "all"}, "conversation_id": "4f33f3be-191e-49a2-8ea0-446a78fefeeb", "error": null}
 
data: {"message": {"id": "af818153-563c-4cf2-959c-c11578cc24f6", "author": {"role": "user", "name": null, "metadata": {}}, "create_time": 1704793809.059035, "update_time": null, "content": {"content_type": "text", "parts": ["draw me a wild cat"]}, "status": "finished_successfully", "end_turn": null, "weight": 1.0, "metadata": {"timestamp_": "absolute", "message_type": null}, "recipient": "all"}, "conversation_id": "4f33f3be-191e-49a2-8ea0-446a78fefeeb", "error": null}
 
data: {"message": {"id": "7e7e84ef-12e9-4425-af6b-38103a76599b", "author": {"role": "assistant", "name": null, "metadata": {}}, "create_time": 1704793809.103825, "update_time": null, "content": {"content_type": "code", "language": "json", "text": ""}, "status": "in_progress", "end_turn": null, "weight": 1.0, "metadata": {"inline_gizmo_id": null, "message_type": "next", "model_slug": "gpt-4", "parent_id": "af818153-563c-4cf2-959c-c11578cc24f6"}, "recipient": "dalle.text2im"}, "conversation_id": "4f33f3be-191e-49a2-8ea0-446a78fefeeb", "error": null}
 
data: {"conversation_id": "4f33f3be-191e-49a2-8ea0-446a78fefeeb", "message_id": "af818153-563c-4cf2-959c-c11578cc24f6", "is_completion": false, "moderation_response": {"flagged": false, "blocked": false, "moderation_id": "modr-8f32H4jN06GiEvQ5lqdT2nnmNDYn1"}}
 
data: {"message": {"id": "7e7e84ef-12e9-4425-af6b-38103a76599b", "author": {"role": "assistant", "name": null, "metadata": {}}, "create_time": 1704793809.103825, "update_time": null, "content": {"content_type": "code", "language": "json", "text": "{\""}, "status": "in_progress", "end_turn": null, "weight": 1.0, "metadata": {"inline_gizmo_id": null, "message_type": "next", "model_slug": "gpt-4", "parent_id": "af818153-563c-4cf2-959c-c11578cc24f6"}, "recipient": "dalle.text2im"}, "conversation_id": "4f33f3be-191e-49a2-8ea0-446a78fefeeb", "error": null}


Upload file to conversation


OpenAI may change its api protocol. Check this blog if your file is not recongnized by the model: https://gap3ratfzt3.feishu.cn/wiki/HGY4wGGFMiUGJFkSQUxcmTkOnGg?fromScene=spaceOverview (opens in a new tab)

POST

https://api.goapi.xyz/api/chatgpt/v1/conversation/{conversation-id}/file

This endpoint allows you to upload a file to an *existing* conversation.

Parameters:

Header
NameTypeRequiredDescription
X-API-Keystring✔️YOUR-GOAPI-KEY
Body
NameTypeRequiredDescription
filefile✔️multipart file in form-data

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Valid file mimeType

[
    "text/x-tex",
    "text/x-script.python",
    "application/msword",
    "text/x-c",
    "text/x-sh",
    "text/x-c++",
    "text/x-php",
    "text/x-csharp",
    "application/vnd.openxmlformats-officedocument.presentationml.presentation",
    "application/pdf",
    "application/json",
    "text/plain",
    "text/javascript",
    "text/html",
    "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
    "text/x-ruby",
    "text/markdown",
    "application/x-latext",
    "text/x-typescript",
    "text/x-java",
    "image/png",
    "image/gif",
    "image/webp",
    "image/jpeg"
]

Request Example

import requests
 
url = "https://api.goapi.xyz/api/chatgpt/v1/conversation/asdgasdfgasdfasdfasdfasdf/file"
 
payload={}
files=[
  ('file',('hair4.png',open('/hair4.png','rb'),'image/png'))
]
headers = {
  'X-API-Key': 'YOUR-GOAPI-KEY'
}
 
response = requests.request("POST", url, headers=headers, data=payload, files=files)
 
print(response.text)

Response Example

{
    "code": 200,
    "data": {
        "file_name": "hair4.png",
        "file_id": "file-oeqJ9Aj9wLXVn1F36huwkmKj",
        "file_size": 886531
    },
    "message": "success"
}


Download file from conversation


POST

https://api.goapi.xyz/api/chatgpt/v1/conversation/{conversation-id}/download

This endpoint allows you to download target file from an *existing* conversation.

Parameters:

Header
NameTypeRequiredDescription
X-API-Keystring✔️YOUR-GOAPI-KEY
Body
NameTypeRequiredDescription
file_idstring✔️file-id from certain conversation

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Request Example

import requests
import json
 
url = "https://api.goapi.xyz/api/chatgpt/v1/conversation/alosdiugakdjfalskdjflakjsd/download"
 
payload = json.dumps({
  "file_id": "file-oeqJ9Aj9wLXVn1F36huwkmKj"
})
headers = {
  'X-API-Key': 'YOUR-GOAPI-KEY',
  'Content-Type': 'application/json'
}
 
response = requests.request("POST", url, headers=headers, data=payload)
 
print(response.text)

Response Example

{
    "code": 200,
    "data": {
        "status": "success",
        "download_url": "https://files.oaiusercontent.com/file-oeqJ9Aj9wLXVn1F36huwkmKj?se=2024-01-09T11%3A53%3A09Z&sp=r&sv=2021-08-06&sr=b&rscc=max-age%3D299%2C%20immutable&rscd=attachment%3B%20filename%3Dhair4.png&sig=hb2pB4Vg0RwCfvjZ97whwIA8V9ufYLEmY6ia3MPrSbc%3D",
        "file_name": "hair4.png",
        "creation_time": "2024-01-09 11:28:58.988169+00:00"
    },
    "message": "success"
}