Editing
Troubleshooting of OpenAI API in Mandarin
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
OpenAI API 技術問題疑難排解 {{LanguageSwitcher | content = [[Troubleshooting of OpenAI API | EN]], [[Troubleshooting of OpenAI API in Mandarin | 漢字]] }} {{Raise hand | text = 如果您對 OpenAI API 有任何疑問,您可以在 OpenAI 開發者論壇的最新 [https://community.openai.com/c/api/7 API 主題] 下發表文章。}} === 如何解決「發生錯誤」 === * 錯誤訊息:"An error occurred. If this issue persists please contact us through our help center at help.openai.com." * 解決方案:重新載入網頁 https://chat.openai.com/chat === 如何解決「502 Bad Gateway」 === 錯誤訊息 <pre> { "error": { "code": 502, "message": "Bad gateway.", "param": null, "type": "cf_bad_gateway" } } </pre> 解決方案: * 嘗試重新發送 API 請求。 === 如何解決「messages 是必須的屬性」 === * 錯誤訊息:'messages' is a required property <pre> { "error": { "message": "'messages' is a required property", "type": "invalid_request_error", "param": null, "code": null } } </pre> * 範例輸入: <pre> { "model": "gpt-4", "max_tokens": 1000, "temperature": 0.9, } </pre> * 解決方案:檢查是否有 `messages` 屬性,例如: <pre> { "model": "gpt-4", "max_tokens": 1000, "temperature": 0.9, "messages": [ {"role": "system", "content": "#zh-TW 您是一個有幫助的助手,請幫我摘要文章"}, {"role": "user", "content": "您的文章內容..."} ] } </pre> === 如何解決「"' ' is not of type 'array' - 'messages'"」 === * 錯誤訊息: <pre> { "error": { "message": "'' is not of type 'array' - 'messages'", "type": "invalid_request_error", "param": null, "code": null } } </pre> * 範例輸入: <pre> { "model": "gpt-4", "max_tokens": 1000, "temperature": 0.9, "messages": "" } </pre> * 解決方案:`messages` 屬性應該為陣列,例如: <pre> { "model": "gpt-4", "max_tokens": 1000, "temperature": 0.9, "messages": [ {"role": "system", "content": "#zh-TW 您是一個有幫助的助手,請幫我摘要文章"}, {"role": "user", "content": "您的文章內容..."} ] } </pre> === 如何解決「'2000' 不是類型 'integer' 的值 - 'max_tokens'」 === * 錯誤訊息: <pre> { "error": { "message": "'2000' is not of type 'integer' - 'max_tokens'", "type": "invalid_request_error", "param": null, "code": null } } </pre> 解決方案: * 將 "max_tokens" 參數修改為整數,而非字串。 <pre> { "model": "gpt-4", "max_tokens": 1000, "temperature": 0.9, "messages": "" } </pre> === 如何解決「Invalid parameter: 'response_format' of type 'json_object' is not supported with this model」 === 錯誤訊息: <pre> Invalid parameter: 'response_format' of type 'json_object' is not supported with this model. </pre> * 範例輸入: <pre> { "model": "gpt-4", "max_tokens": 1000, "temperature": 0.9, "messages": [ {"role": "system", "content": "#zh-TW 您是一個有幫助的助手,請幫我摘要文章"}, {"role": "user", "content": null} ] } </pre> 解決方案: * 模型 "gpt-4" 不支援該參數。需要使用 {{kbd | key=gpt-3.5-turbo-1106}} 、{{kbd | key=gpt-4-1106-preview}} 或 {{kbd | key=gpt-4o}}。 <pre> { "model": "gpt-4-1106-preview", "max_tokens": 1000, "temperature": 0.9, "response_format": { "type": "json_object" }, "messages": [ {"role": "system", "content": "#zh-TW 您是一個有幫助的助手,請幫我摘要文章"}, {"role": "user", "content": "您的文章內容..."} ] } </pre> === 如何解決「Request timed out: HTTPSConnectionPool(host='api.openai.com', port=443): Read timed out」 === 錯誤訊息: <pre> Request timed out: HTTPSConnectionPool(host='api.openai.com', port=443): Read timed out. (read timeout=600) </pre> 解決方案: * 可能是伺服器未在設定的時間內(600 秒)回應,請等待幾分鐘後再嘗試。 === 如何解決「The model `gtp-4` does not exist」 === * 錯誤訊息: "The model `gtp-4` does not exist" 或 "The model: `gpt-4` does not exist" <pre> { "error": { "message": "The model: `gpt-4` does not exist", "type": "invalid_request_error", "param": null, "code": "model_not_found" } } </pre> 解決方案: * 修正模型名稱中的拼寫錯誤。 * 訪問 [https://platform.openai.com/docs/models 模型 - OpenAI API] 檢視可用模型列表,或造訪 [https://openai.com/product/gpt-4 GPT-4 產品頁面] 申請加入等待名單。 === 如何解決「該模型當前因其他請求超載」 === 錯誤訊息: <pre> { "error": { "message": "That model is currently overloaded with other requests. You can retry your request, or contact us through our help center at help.openai.com if the error persists. (Please include the request ID XXX in your message.)", "type": "server_error", "param": null, "code": null } } </pre> 解決方案: * 前往 [https://status.openai.com/ OpenAI 狀態頁面] 查看伺服器是否停機。 * 根據訊息提示重新嘗試您的請求。 * 如果問題持續存在,向 [https://help.openai.com/en/ OpenAI 幫助中心] 報告問題。 === 如何解決「RateLimitError: Rate limit reached for default-gpt-3.5-turbo」 === 錯誤訊息:RateLimitError: Rate limit reached for default-gpt-3.5-turbo <pre> RateLimitError: Rate limit reached for default-gpt-3.5-turbo in organization org-XXX on requests per min. Limit: 3 / min. Please try again in 20s. Contact support@openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://platform.openai.com/account/billing to add a payment method. </pre> 其他類似錯誤訊息: <pre> Rate limit reached for default-gpt-4 in organization org-xxx on tokens per min. Limit: 40000 / min. Please try again in 1ms. Contact us through our help center at help.openai.com if you continue to have issues. </pre> 解決方案: * 調整 API 請求的頻率。在腳本中加入 [[Sleep]] 函數於每次 API 請求之間。更多關於速率限制的資訊,請參考 OpenAI 文件:[https://platform.openai.com/docs/guides/rate-limits]. * 了解如何在程式中隨機 [[Sleep]] 若干秒以避免速率限制。 === 如何解決「You exceeded your current quota, please check your plan and billing details.」 === 錯誤訊息: <pre> { "error": { "message": "You exceeded your current quota, please check your plan and billing details.", "type": "insufficient_quota", "param": null, "code": null } } </pre> 解決方案: 1. 訪問 https://platform.openai.com/account/usage 檢視 API 使用量。 2. 查找 "OpenAI API - Hard Limit Notice" 電子郵件,並根據內含表單申請額度增加。 3. 獲得額度增加後,前往 https://platform.openai.com/account/billing/limits 調整您的硬性限制。 === 如何解決「zsh: command not found: -d」 === 執行以下指令時遇到錯誤: <pre> curl https://api.openai.com/v1/vector_stores \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" -d '{ "name": "Enter your preferred name here" }' </pre> 錯誤訊息: <pre> zsh: command not found: -d </pre> 修正後的指令: <pre> curl https://api.openai.com/v1/vector_stores \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -H "OpenAI-Beta: assistants=v2" \ -d '{ "name": "Enter your preferred name here" }' </pre> 解釋: * 每行結尾的反斜線 {{kbd | key=<nowiki>\</nowiki>}} 表示指令尚未完成,會延續到下一行。確保 `-d` 參數或其他參數之後沒有多餘字符或指令,避免類似錯誤。 === 如何解決「強制保持繁體中文輸出」 === * 在問題前加上 #zh-TW。<ref>[https://learntech.tw/chatgpt-traditional-chinese/ ChatGPT:如何強制保持繁體中文輸出 |學科技、省時間 - 學科技]</ref> * 或指定「使用臺灣常用的繁體中文」。 範例: <pre> 請使用台灣常用的繁體中文: 規則: - 使用全形標點符號,中英文之間加入空格。 - 以下是常見的 AI 相關術語詞彙對應表(English -> 中文): * Transformer -> Transformer * Token -> Token * LLM/Large Language Model -> 大語言模型 * Zero-shot -> 零樣本 * Few-shot -> 少樣本 * AI Agent -> AI 代理 * AGI -> 通用人工智慧 </pre> == 延伸閱讀 == * [[ChatGPT prompts in Mandarin | ChatGPT prompts]] ([[ChatGPT prompts in Mandarin#如何改善 prompt 品質 |如何改善 prompt 品質]]) * [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://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb?utm_source=pocket_saves openai-cookbook/How_to_count_tokens_with_tiktoken.ipynb at main · openai/openai-cookbook · GitHub] * [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://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 /> [[Category: Tools]] [[Category: OpenAI]] [[Category: Generative AI]]
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Kbd
(
edit
)
Template:LanguageSwitcher
(
edit
)
Template:Raise hand
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information