– Some came to replicate Silicon Valley, others to regulate it.

Thirty-five foreign ambassadors representing countries as big as China and as small as Kiribati, Barbados and Monaco toured the Bay Area last week in what the State Department described as the biggest such diplomatic meetup outside of Washington.

"It's all about finding ways to advance our small nations," said Ambassador Aunese Makoi Simati, of Tuvalu, a country of about 12,000 people living on nine coral atolls in the South Pacific. "It's very hard to invest in Tuvalu. We have to improve our Internet connections first."

Silicon Valley has long drawn foreign leaders hoping to cultivate a tech economy in their homelands or just soak up the wine country sun, but more governments around the world are also now confronting the challenge of managing Bay Area imports such as the "sharing economy" of ride-hailing apps and e-commerce.

The ambassadors toured Facebook and Tesla, along with powerhouse start-ups such as Airbnb, the online peer-to-peer vacation rental marketplace that has met with regulatory trouble from Barcelona to Berlin. They mingled at San Francisco City Hall with U.S. Sen. Dianne Feinstein, D-Calif., and former Secretary of State George Shultz, and on Wednesday took a trip to Napa Valley.

It was a surprise to no one that the trip drew far more foreign dignitaries than a similar trip to Nashville in the fall.

"No. 1 is it's San Francisco and has a romantic ring to it," said U.S. Chief of Protocol Peter Selfridge, who led the tour. "No. 2 is the economy. Silicon Valley is a beacon."

Ambassadors were learning about American culture and ingenuity, "but also hopefully making exchanges," Selfridge said.

Among the most sought-after diplomats was Chinese Ambassador Cui Tiankai, who slipped out of the organized tour of nonprofit Khan Academy in Mountain View for a private chat with founder Salman Khan.

Khan Academy creates video lessons on math, science and other subjects, but has struggled to distribute its Mandarin content in China because it uses Google's YouTube, one of many Silicon Valley online platforms blocked by government censors.

Cui suggested in an interview that if Khan Academy wants to make inroads in China, it might have to work with Chinese companies instead of Google.

"He is looking for partners in China. I would encourage him to do that," Cui said. "You do need local partners."

While China already has its own thriving tech economy, other countries appeared to welcome any kind of investment from Silicon Valley firms. Several boasted of their burgeoning IT sectors.

"We've moved from the 18th century to the 21st century" in just a few decades, said Ambassador Hunaina Al Mughairy of the Sultanate of Oman.

Others admitted they could use some help.

"The majority of our people who wish to learn might not have access to Internet," said Ambassador Pisan Manawapat of Thailand.

Of the countries that sent ambassadors to the Bay Area, Internet use is highest in Iceland, where about 97 percent of the population is online, and lowest in Myanmar, where the rate is closer to 1 percent, according to the World Bank.

Myanmar Ambassador Kyaw Myo Htut disputed that figure during a walk through Tesla's headquarters, noting that Internet use is rapidly growing. The Southeast Asian country began opening up in 2010 after decades of tightfisted military rule.

"We're leapfrogging," he said.

The ambassadors also got a crash course in Silicon Valley culture.

As State Department handlers referred to the group as "your excellencies," tech company hosts showed no such formality. Lousiana-raised Khan addressed them as "all y'all," and Tesla employees welcomed "you guys" to view its electric car chassis in a Palo Alto showroom. By the end of the tour, some of the ambassadors began loosening their collars.

But they were puzzled by the Khan Academy worker who wore a stuffed shark on his head.

"I just wear funny things because it's fun," said the 25-year-old employee, Kyle Slinn, unperturbed as ambassadors from several continents snapped photos of him on their smartphones.