fix: more reasonable error reporting (#965)

This commit is contained in:
yetone 2024-12-18 23:16:41 +08:00 committed by GitHub
parent 8067cb0240
commit 01e05a538b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -142,7 +142,13 @@ M.parse_curl_args = function(provider, code_opts)
["Content-Type"] = "application/json", ["Content-Type"] = "application/json",
} }
if P.env.require_api_key(base) then headers["Authorization"] = "Bearer " .. provider.parse_api_key() end if P.env.require_api_key(base) then
local api_key = provider.parse_api_key()
if api_key == nil then
error(Config.provider .. " API key is not set, please set it in your environment variable or config file")
end
headers["Authorization"] = "Bearer " .. api_key
end
-- NOTE: When using "o1" set the supported parameters only -- NOTE: When using "o1" set the supported parameters only
local stream = true local stream = true