The historical Azure Cognitive Services entry covers a family of capabilities, not one universal request contract. Microsoft's current overview uses Foundry Tools branding.
Before adapting an old example, identify the actual capability, resource type, region and API version it targets. Follow that service's authentication instructions. A key that works for one resource should not be presented as a credential that automatically unlocks every service in the family.