How to create an Asset Source programmatically via a plugin?
I don't think you can add asset source types without modifying core. The list of components that is allowed / scanned for does not contain AssetSourceTypes.

Unless you mean create an asset source using an existing AssetSourceType programmatically?

If you want an asset source saved, I would guess it is similar to below:

$source = new AssetSourceModel();
$source-&gt;name   = 'Source name';
$source-&gt;handle = 'Source handle';
$source-&gt;type   = 'Local';
// Not sure about the settings here
$source-&gt;settings = array('path' =&gt; 'path/to/','url' =&gt; 'url/path/to', 'publicURLs' =&gt; '1');

$fieldLayout = craft()-&gt;fields-&gt;getLayoutById(1); // set this to the field layout you want
$fieldLayout-&gt;type = ElementType::Asset;

$source-&gt;setFieldLayout($fieldLayout);

if (craft()-&gt;assetSources-&gt;saveSource($source)) {
    // Success saving
}
else {
    // Error saving
}


You can look at the AssetSources controller actionSaveSource for reference.

There are some areas I'm not sure about such as the settings and the field layout, as they get set by POST data, but this should lead you in the right direction.