What formats should I use for generated social network images?

This depends both of the target social network and the purpose of this image. There are plenty of up to date resources that can help you about this topic, but we'll try to keep a little list here, and watch it evolve, so we can update our size list on a regular basis based on the market evolution.

Example Snippet for Social Network preview images

We usuually go for a 1200x630 image (as recommended by Facebook) for our opengraph preview image.

<!-- Place this within the <head> tag of your site -->
<title>Page Title. Maximum length 60-70 characters</title>
<meta name="description" content="Page description. 50–300 characters." />

<!-- Twitter Card -->
<meta name="twitter:card" value="summary">

<!-- Open Graph -->
<meta property="og:title" content="Your Title Here" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://www.example.com/" />
<meta property="og:image" content="https://aprc.it/api/1200x630/www.example.com" />
<meta property="og:description" content="Description Here" />

This will force your page to render as a capture on social networks.

Note: You should pre-generate the image to avoid social networks to retrieve and cache the "in progress" image for your website.