Both scripts and APIs are free, but you can get a commercial key from the developer's website with other useful features.
Akismet is a plugin for WordPress, a popular open source content manager. You can use it to filter spam and other unwanted comments on your blog.
It works like this: whenever a comment, trackback, or postbank is posted on your site post, it is sent to the Akismet website, tests it and sends out a favorable or adverse result.
With Akismet, you will not have to keep spammers longer than a black list. This web service takes care of everything.
If you happen to get a false positive, you can always contact Akismet to get different results.
To use Akismet, you need an API key, which you can get from the WordPress user registration page. Click here to access it