Skip to content

Commit

Permalink
fix: more reasonable error reporting (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone authored Dec 18, 2024
1 parent 8067cb0 commit 01e05a5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/avante/providers/openai.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@ M.parse_curl_args = function(provider, code_opts)
["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
local stream = true
Expand Down

0 comments on commit 01e05a5

Please sign in to comment.