Troubleshooting of OpenAI API: Difference between revisions

Jump to navigation Jump to search
m
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:


== Troubleshooting of OpenAI API ==
Troubleshooting of OpenAI API
 
{{LanguageSwitcher | content = [[Troubleshooting of OpenAI API | EN]], [[Troubleshooting of OpenAI API in Mandarin | 漢字]] }}


{{Raise hand | text = If you have any questions about the OpenAI API, you can post them on the OpenAI Developer Forum under the latest [https://community.openai.com/c/api/7 API topics].}}
{{Raise hand | text = If you have any questions about the OpenAI API, you can post them on the OpenAI Developer Forum under the latest [https://community.openai.com/c/api/7 API topics].}}
Line 122: Line 124:
   }
   }
</pre>
</pre>
=== How to fix "API Error (HTTP 400): Encrypted content is not supported with this model" ===
Error message: API Error (HTTP 400): Encrypted content is not supported with this model.
<pre>
Error!: API Error (HTTP 400): {
  "error": {
    "message": "Encrypted content is not supported with this model.",
    "type": "invalid_request_error",
    "param": "include",
    "code": null
  }
}
</pre>
Solution:
# This error occurs when using the `include` parameter (e.g., for prompt caching or encrypted content) with a model that does not support it. GPT-4.1 does not support encrypted/included content in this way.
# Remove or omit the `include` parameter from your API request payload.
# Alternatively, switch to a model that supports this feature, such as reasoning models like GPT-5.2 or later.
# See more details on OpenAI's model documentation: https://platform.openai.com/docs/models


=== How to fix "Invalid parameter: 'response_format' of type 'json_object' is not supported with this model" ===
=== How to fix "Invalid parameter: 'response_format' of type 'json_object' is not supported with this model" ===
Line 144: Line 167:


Solution:  
Solution:  
* The model "gpt-4" was not supported. Need to use model of {{kbd | key=gpt-3.5-turbo-1106}} or {{kbd | key=gpt-4-1106-preview}} <ref>[https://github.com/openai/openai-python/issues/887 response_format error · Issue #887 · openai/openai-python]</ref><ref>[https://platform.openai.com/docs/api-reference/chat/create API Reference - OpenAI API]</ref><ref>[https://community.openai.com/t/openai-api-guide-using-json-mode/557265/1 🛡️ OpenAI API Guide: Using JSON Mode - API - OpenAI Developer Forum]</ref>.
* The model "gpt-4" was not supported. Need to use model of {{kbd | key=gpt-3.5-turbo-1106}} or {{kbd | key=gpt-4-1106-preview}} or {{kbd | key=gpt-4o}} <ref>[https://github.com/openai/openai-python/issues/887 response_format error · Issue #887 · openai/openai-python]</ref><ref>[https://platform.openai.com/docs/api-reference/chat/create API Reference - OpenAI API]</ref><ref>[https://community.openai.com/t/openai-api-guide-using-json-mode/557265/1 🛡️ OpenAI API Guide: Using JSON Mode - API - OpenAI Developer Forum]</ref>.


<pre>
<pre>
Line 157: Line 180:
         ]
         ]
   }
   }
</pre>
=== How to fix "'messages' must contain the word 'json' in some form, to use 'response_format' of type 'json_object'" ===
Error message
<pre>
"error": {
        "message": "'messages' must contain the word 'json' in some form, to use 'response_format' of type 'json_object'.",
        "type": "invalid_request_error",
        "param": "messages",
        "code": null
      }
</pre>
Solution
* Add "output in JSON format" to the prompt ("system message") e.g.
<pre>
Output Format: Provide your analysis in the following JSON format:
...
</pre>
</pre>


Line 277: Line 320:
* Retry your request as suggested in the message
* Retry your request as suggested in the message
* Send an issue to [https://help.openai.com/en/ OpenAI Help Center]
* Send an issue to [https://help.openai.com/en/ OpenAI Help Center]
=== How to fix "The project you are requesting has been archived and is no longer accessable (accessible)" ===
Error message:
<pre>
{
    "error": {
        "message": "The project you are requesting has been archived and is no longer accessable",
        "type": "invalid_request_error",
        "param": null,
        "code": "not_authorized_invalid_project"
    }
}
</pre>
Solution:
* If you are the administrator, first visit https://platform.openai.com/organization/api-keys to verify which API key is associated with which project.
* Next, go to https://platform.openai.com/organization/projects to determine if the project is active or archived.
* If the project is archived, you may need to assign the API key to another active project or a new one<ref>[https://help.openai.com/en/articles/9186755-managing-your-work-in-the-api-platform-with-projects Managing your work in the API platform with Projects | OpenAI Help Center]</ref>.


=== How to fix "This model's maximum context length is 4097 tokens" ===
=== How to fix "This model's maximum context length is 4097 tokens" ===
Line 386: Line 448:
Explanation: The backslash {{kbd | key=<nowiki>\</nowiki>}} at the end of each line indicates that the command is not yet finished and will continue on the next line. Ensure that there are no extra characters or commands after the -d parameter or any other parameters to avoid similar errors.
Explanation: The backslash {{kbd | key=<nowiki>\</nowiki>}} at the end of each line indicates that the command is not yet finished and will continue on the next line. Ensure that there are no extra characters or commands after the -d parameter or any other parameters to avoid similar errors.


=== 強制保持繁體中文輸出 ===
=== Force Traditional Chinese Output ===
 
* Add #zh-TW before your question <ref>[https://learntech.tw/chatgpt-traditional-chinese/ ChatGPT: How to Force Traditional Chinese Output | Learn Technology, Save Time - Learn Technology]</ref>
* Or say "Use Traditional Chinese commonly used in Taiwan"
 
<pre>
```
Use Traditional Chinese commonly used in Taiwan:
 
Rules
- Use full-width punctuation marks and add spaces between Chinese and English text.
- Below is a common AI terminology correspondence table (English -> Traditional Chinese):
  * Transformer -> Transformer
  * Token -> Token
  * LLM/Large Language Model -> 大語言模型
  * Zero-shot -> 零樣本
  * Few-shot -> 少樣本
  * AI Agent -> AI 代理
  * AGI -> 通用人工智慧
- The following is a table of common Taiwanese terms (English -> Traditional Chinese):
  * create -> 建立
  * quality -> 質量
  * information = 資訊
  * message = 訊息
  * store = 儲存
  * search = 搜尋
  * view = 檢視, 檢視表 (No 視圖 as always)
  * create = created = 建立
  * data = 資料
  * object = 物件
  * queue = 佇列
  * stack = 堆疊
  * invocation = 呼叫
  * code = 程式碼
  * running = 執行
  * library = 函式庫
  * building = 建構
  * package = 套件
  * video = 影片
  * class = 類別
  * component = 元件
  * Transaction = 交易
  * Code Generation = 程式碼產生器
  * Scalability = 延展性
  * Metadata =  Metadata
  * Clone = 複製
  * Memory = 記憶體
  * Built-in = 內建
  * Global = 全域
  * Compatibility = 相容性
  * Function = 函式
  * document = 文件
  * example = 範例
  * blog = 部落格
  * realtime = 即時
  * document = 文件
  * integration = 整合
```
 
</pre>
 


* 在問題前面加上 #zh-TW <ref>[https://learntech.tw/chatgpt-traditional-chinese/ ChatGPT:如何強制保持繁體中文輸出 |學科技、省時間 - 學科技]</ref>
* 或「使用臺灣常用的繁體中文」


== Further reading ==
== Further reading ==


* [[ChatGPT prompts]]
* [[AI Prompt Engineering]] ([[ChatGPT prompts#How to improve the prompt design | How to improve the prompt design]])
* [https://help.openai.com/en/collections/3780021-general-top-faq General Top FAQ | OpenAI Help Center]
* [https://help.openai.com/en/collections/3780021-general-top-faq General Top FAQ | OpenAI Help Center]
* [https://help.openai.com/en/collections/3675931-openai-api#api-error-codes-explained OpenAI API | OpenAI Help Center]
* [https://help.openai.com/en/collections/3675931-openai-api#api-error-codes-explained OpenAI API | OpenAI Help Center]
Line 399: Line 519:
* [https://stackoverflow.com/questions/tagged/openai-api Highest scored 'openai-api' questions - Stack Overflow]
* [https://stackoverflow.com/questions/tagged/openai-api Highest scored 'openai-api' questions - Stack Overflow]
* [https://platform.openai.com/docs/guides/error-codes Error codes - OpenAI API]
* [https://platform.openai.com/docs/guides/error-codes Error codes - OpenAI API]
* [https://errerrors.blogspot.com/2024/07/openai-batch-api-troubleshooting.html OpenAI Batch API 常見技術問題排除]
* [https://platform.openai.com/docs/guides/production-best-practices Production best practices - OpenAI API]


== References ==
== References ==

Navigation menu