To access your IBM watsonx.ai credentials, generate an IBM Cloud API key from your IBM Cloud account and use it to obtain an IAM bearer token for authentication.
Here is the code snippet you can refer to:

In the above code we are using the following key points:
- Imports the requests library to handle HTTP requests.
- Sends a POST request to IBM Cloud's IAM endpoint with the API key to obtain an IAM bearer token.
- Extracts and prints the access_token from the JSON response for use in authenticating watsonx.ai API requests.
Hence, by generating an IBM Cloud API key and retrieving an IAM bearer token, you can authenticate your applications to securely access IBM watsonx.ai services.