The Apple Original film "F1", with action scenes filmed at race weekends with the Liberty Media-owned sport's cooperation, is due in cinemas and IMAX internationally on June 25 and in North America on June 27.
Kosinski told reporters after an advance showing at the Canadian Grand Prix that the involvement of Hamilton, who joined Ferrari this season after winning six of his seven titles at Mercedes, had been key.
The 40-year-old Briton is credited as a Co-Producer while his Dawn Apollo production company was also involved.
Kosinski, who directed the Hit 'Top Gun: Maverick', explained how Hamilton was the first person he reached out to with the idea of a movie.
"I sent him an email and just said 'I want to tell the story in your world. I want to make it as authentic as possible. Will you help me?'," he said.
"And luckily Lewis said yes. He had actually talked to me earlier about playing a role in 'Top Gun Maverick'. So that's how I knew Lewis."
Hamilton, who had to turn down a part in that Tom Cruise film because of his racing commitments, acted as go-between with Formula One and as a consultant advising on technical accuracy and authenticity.
--Reuters--