diff --git a/components/ai_chat/core/browser/engine/oai_api_client.cc b/components/ai_chat/core/browser/engine/oai_api_client.cc index 36979b79e210..46619aaa290e 100644 --- a/components/ai_chat/core/browser/engine/oai_api_client.cc +++ b/components/ai_chat/core/browser/engine/oai_api_client.cc @@ -150,7 +150,11 @@ void OAIAPIClient::OnQueryCompleted(GenerationCompletedCallback callback, DVLOG(2) << "No message dict found in response."; return; } - completion = *message->FindString("content"); + + const std::string* content = message->FindString("content"); + if (content) { + completion = *content; + } } }