How exactly do Authorized Participants determine the securities to exchange?
They will be told by the fund manager (the ETF sponsor). I believe the exact process varies slightly by ETF. As usual, all the details will be in the prospectus. Let's take a look at the SPDR S&P 500 ETF Trust (NYSE Arca: SPY). I quote from its prospectus.
What Authorized Participants (APs) need to provide in exchange for newly created ETF units:
Payment for orders is made by deposits with the Trustee of a portfolio of securities, substantially similar in composition and weighting to Index Securities, and a cash payment in an amount equal to the Dividend Equivalent Payment (as defined below), plus or minus the Balancing Amount [...]
Definition of "Dividend Equivalent Payment" and "Portfolio Deposit":
“Dividend Equivalent Payment” is an amount equal, on a per Creation Unit basis, to the dividends on the Portfolio (with ex-dividend dates within the accumulation period), net of expenses and accrued liabilities for such period [...]
The Dividend Equivalent Payment and the Balancing Amount collectively are referred to as the “Cash Component” and the deposit of a portfolio of securities and the Cash Component collectively are referred to as a “Portfolio Deposit.” Persons placing creation orders must deposit Portfolio Deposit [...]
"So how does the AP know how to compose the basket?":
The Trustee makes available to NSCC before the commencement of trading on each business day that the New York Stock Exchange LLC (the “NYSE”) is open for business (“Business Day”) a list of the names and required number of shares of each of the Index Securities in the current Portfolio Deposit as well as the amount of the Dividend Equivalent Payment for the previous Business Day. The identity and weightings of the Index Securities to be delivered as part of a Portfolio Deposit are determined daily and reflect the relative weighting of the current Index. The value of such Index Securities, together with the Cash Component, is equal to the net asset value of the Trust on a per Creation Unit basis at the close of business on the day of the creation request. The Sponsor makes available every 15 seconds throughout the trading day at the Exchange a number representing, on a per Unit basis, the sum of the Dividend Equivalent Payment effective through and including the previous Business Day, plus the current value of the securities portion of a Portfolio Deposit as in effect on such day (which value occasionally may include a cash-in-lieu amount to compensate for the omission of a particular Index Security from such Portfolio Deposit). [...]
"Are they told that by the fund manager?" Yes.