FILE PHOTO: FILE PHOTO: A Tesla logo is seen at a groundbreaking ceremony of Tesla Shanghai Gigafactory in Shanghai, China January 7, 2019. REUTERS/Aly Song

(Reuters) - Tesla Inc said on Thursday it signed an agreement with lenders in China for a 12-month facility of up to 3.5 billion yuan ($521 million) for the electric carmaker’s Gigafactory in Shanghai, and secured new commitments from banks that could be used for investments in the United States and elsewhere.

The company broke ground on the factory in January. A Shanghai city government official said on Wednesday the factory is expected to be completed in May.

Tesla has said that the Gigafactory will cost around $2 billion.

In its filing, Tesla said it had amended its asset-backed lending credit agreement with a syndicate of banks, increasing revolving commitments by $500 million to a total of $2.425 billion, while extending the maturity date of the agreement by three years.

The credit agreement is secured by part of Tesla’s accounts receivable, inventory and equipment. Tesla borrowed $431.0 million under the agreement in 2018.

The amendment also doubled the letter of credit subfacility to $400 million from $200 million.

Producing cars in China is likely to help the company minimize the impact of the U.S.-China trade war, which has forced Tesla to adjust prices of its U.S.-made cars in China.

Keeping prices in check will also help Tesla fend off competition from a swathe of domestic electric vehicle startups such as Nio Inc, Byton and XPeng Motors.

($1 = 6.7132 Chinese yuan renminbi)