diff --git a/lib/chat_models/chat_open_ai.ex b/lib/chat_models/chat_open_ai.ex index 1dea30e0..5a66d22c 100644 --- a/lib/chat_models/chat_open_ai.ex +++ b/lib/chat_models/chat_open_ai.ex @@ -246,7 +246,7 @@ defmodule LangChain.ChatModels.ChatOpenAI do Req.new( url: openai.endpoint, json: for_api(openai, messages, functions), - auth: {:bearer, get_api_key()}, + auth: {:bearer, openai.api_key || get_api_key()}, receive_timeout: openai.receive_timeout, retry: :transient, max_retries: 3,