Anthropic is nearing a $1 trillion valuation, topping rival OpenAI and making it the most valuable artificial intelligence startup, as the two competitors head toward their initial public offerings.