With Tesla crossing a key financial milestone and enjoying a dizzying climb in the value of its stock, the company is treating itself to a splurge: a new factory.

After months of speculation and unconfirmed reports, Chief Executive Elon Musk previewed plans to build a plant in Austin, Texas, during a conference call to discuss Tesla’s second-quarter earnings Wednesday. The news temporarily overshadowed concerns hanging over the electric-car maker, including competitors’ eating away at its market share in Europe, customer service struggles and a reliance on government credits for its slender profits.

The Austin facility’s main purpose will be the manufacture of cars, pickups and semitrailer trucks, but Musk said the site will also serve as an “ecological paradise,” with publicly accessible pathways and boardwalks along the Colorado River where visitors can watch birds and butterflies.

He offered little other detail. Asked how many vehicles the plant would eventually produce, he said “a lot.”

The factory, scheduled to open in 18 months, would manufacture the company’s Cybertruck pickup, a semitrailer truck and Model 3 and Model Y cars for the Eastern U.S., Musk said.

The company’s California plant, in Fremont, would continue to build the Model S and Model X for global markets, and Models 3 and Y for the Western U.S.

Tesla opened a factory in Shanghai in late December and is erecting another in Gruenheide, Germany, to build vehicles for the European market.

Each plant will cost several billion dollars. Tesla’s current cash flow is not strong enough to pay for such construction without raising more equity, debt or both. Its profits right now come from the sale of regulatory pollution credits, not motor vehicles.

However, if Tesla’s spectacular stock market performance continues — shares have more than quadrupled in value since March, closing Wednesday at $1,592.33 — raising such money shouldn’t pose a problem, as long as financial regulators approve.

Tesla reported revenue of $6.04 billion for the second quarter, up 1% from the first quarter but down 5% from the same period in 2019. The company eked out a $104-million profit for the quarter.

It marked the company’s fourth quarterly profit in a row, which technically qualifies the company for inclusion in the Standard & Poor’s 500 index. If the S&P index committee gives the OK, index funds that buy stocks to replicate the broad market, and many more specialized exchange-traded funds as well, will be required to buy its stock, potentially contributing another updraft to its already heady ascent.

Subtract regulatory credits from the picture and Tesla continues to lose money. Tesla earns those credits because its electric cars, which spit out no tailpipe emissions, give it a credit surplus it can sell to companies to help them meet average fleet-wide emissions standards as they remain dependent on internal combustion engines.

In the second quarter, Tesla said it sold $428 million in credits, all pure profit. Net income for the second quarter came in at $104 million. Without the credits, the 17-year-old company would have lost $324 million.

For the first half of the year, Tesla’s net income was $120 million on the strength of $782 million in credits. For all of 2019, Tesla sold $594 million worth of pollution credits.

“Tesla’s business model is currently 100% predicated on selling one-time temporary credits to guys who increasingly don’t need them,” said Gordon Johnson of GLJ Research, which assesses company finance and strategy for big investors.

But some stock analysts see change ahead. Dan Ives, analyst at Wedbush Securities, said he’s especially excited about future demand in China, which he said “remains a ray of light for Tesla in a dark global macro and appears to be on a run rate to hit 150,000 unit deliveries” this year. Still, he said, he believes the company’s stock is currently overvalued.

Musk told analysts that he’s comfortable with tiny profits for now. “We want to be slightly profitable and maximize growth and make the cars as affordable as possible,” he said Wednesday.

Tesla’s sales in Europe and the U.S. have flattened or declined. In California, the company’s top U.S. market, Tesla registrations were down 48% in the state for the second quarter, to 9,774 cars, according to an analysis from market researcher Cross-Sell.

Tesla last year said it planned to sell 500,000 total vehicles in 2020. With the COVID-19 pandemic sending spasms through the economy, that will be tough to reach. Last year, Tesla sold 367,000 vehicles.

Tesla’s chief financial officer, Zach Kirkhorn, told analysts that the company continues to reduce operating expenses. Money lost because of temporary shutdowns of both the Fremont and Shanghai plants was made up by cutting employee pay and delaying employee bonus payments.

But Musk, who has already earned a $700-million bonus this year, qualified for an additional $2.1-billion bonus Tuesday based on the stock price and the company’s market value, paid in stock options that can be cashed in at a later date.