Amazon has agreed to invest $4 billion into the artificial intelligence startup Anthropic to develop high-performing foundation models.