In the history of sportscasting, no broadcaster has probably been more associated with one network than Bob Costas and NBC.

Now, after nearly four decades in which Costas has been the lead announcer on Olympics, World Series, Super Bowls and late-night talk shows, Costas and NBC are in discussions to end the relationship, sources have told The Post.

If a deal can be struck, it would mean finishing Costas’ current multi-million contract three years early as it is goes through 2021, according to a source. The contract calls for exclusivity for NBC, besides the work Costas does for MLB Network.

When contacted, Costas initially declined comment on the talks, saying he couldn’t confirm or deny the discussions. He then relented and went on to say that there were no hard feelings on either side, but with his decision to stop doing the Olympics and with his antipathy toward football, it may be time for a change.

Costas wants to pursue a journalism show that would feature interviews, commentaries and a critical look at the world of sports and perhaps other topics. NBC rarely utilizes Costas on-air after he stepped away from his last major roles on the Olympics and the NFL.

“Sometimes you get to a point where it is not a fit anymore,” Costas said. “It doesn’t mean that anyone is angry or upset.”

NBC declined comment.

Both sides are willing to talk about the terms that could lead to a buyout.

As it stands now, NBC is paying Costas seven figures per year in a “Tom Brokaw-like” emeritus role to pitch in when needed. In the last couple of years, he has only been on the air sparingly for perspectives on news events like the deaths of Muhammad Ali and colleague Dick Enberg, as well as a few minutes during the Triple Crown races.

While Costas does not have a prominent on-air role with the network, he is still associated closely with NBC because of their longtime history and his legendary status.

Costas has always stood out among sports network anchors for his willingness to speak strongly on the issues, even on the events NBC is covering. Costas ended up not hosting last February’s Super Bowl after saying football “destroys people’s brains.”

With NBC’s “Sunday Night Football” contract running through the 2022 season, Costas’ commentaries — even off NBC’s air — could be more of a liability than an asset in retaining its NFL package. The two sides could agree to allow Costas to do other projects, while remaining a part of NBC, but that does not seem to make sense for either.

Costas’ agent, Sandy Montag, and NBC executives already have exchanged ideas and have meetings planned in the near future for what could lead to a potential buyout. Either way, Costas will continue his work with MLB Network.

Both sides have some leverage in the negotiations. Costas, 66, is owed a good deal of money and could simply collect checks, if he so pleased, while NBC could prevent Costas from finishing off his career in the fashion he prefers.

Costas declined to say where a possible new show could be housed. Platforms like HBO, Showtime, Netflix, Amazon and others are often in play for the type of program Costas is trying to create.

“It is gratifying that there are a number of places that are anxious to do the sort of thing that I was seldom able to do over the last several years at NBC,” Costas said.

Costas added he would like to do “thoughtful discussions, reasonable commentaries and essays.” These have all been hallmarks of his time with NBC and HBO when he was the preeminent sportscaster of his prime.

There was a time when Costas thought he may be a one-broadcast-network guy, but that seldom, if ever, happens now in any entertainment or news genre. Still, Costas is probably more closely associated with NBC than Howard Cosell, Jim McKay and Keith Jackson were with ABC or Chris Berman with ESPN or Joe Buck is with Fox.

But as accomplished as all of these sportscasters were — or are, in the case of Buck — none have had the range of Costas, hosting the Olympics and the Super Bowl, calling the play-by-play of the World Series and having a late-night talk show.

Since 1979, Costas did it all at NBC. Soon, that relationship will likely end.