0 / 0
Credentials for prompting foundation models (IBM Cloud API key and IAM token)
Last updated: Oct 09, 2024
Credentials for prompting foundation models (IBM Cloud API key and IAM token)

To prompt foundation models in IBM watsonx.ai programmatically, you need an IBM Cloud API key and sometimes an IBM Cloud IAM token.

 

IBM Cloud API key

To use the foundation models Python library, you need an IBM Cloud API key.

Python pseudo-code

my_credentials = {
    "url"    : "https://us-south.ml.cloud.ibm.com",
    "apikey" : <my-IBM-Cloud-API-key>
}
...
model = Model( ... credentials=my_credentials ... )

You can create this API key using multiple interfaces. For full instructions, see Creating an API key

 

IBM Cloud IAM token

When you click the View code button in the Prompt Lab, a curl command is displayed that you can call outside the Prompt Lab to submit the current prompt and parameters to the selected model and get a generated response. In the command, there is a placeholder for an IBM Cloud IAM token.

For information about generating that access token, see: Generating an IBM Cloud IAM token

 

Parent topic: Foundation models Python library

Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more