Finding the project ID
To work with generative AI assets in IBM watsonx.ai programmatically, you must identify the resources that you want to access.
To inference the foundation models that are provided with watsonx.ai, you must specify the ID for the watsonx.ai project.
To get your project ID, complete the following steps:
- From your project, click the Manage tab.
- Copy the project ID from the Details section of the General page.
Specifying the project ID in a notebook
If you're running the notebook from the project with the assets that you want to use, you can set the project ID automatically by specifying the following code. If the project ID cannot be returned, the notebook prompts the use to specify the project ID at runtime.
import os
try:
project_id = os.environ["PROJECT_ID"]
except KeyError:
project_id = input("Enter your project ID: ")
If you use the APIClient
that is available with the library to manage credentials for you, you can also define a default project or space so that you don't have to specify it with each method.
After defining the credentials, set a default project to use throughout the notebook by using the following statement:
client.set.default_project(project_id)
For more information, see Using the APIClient.
Finding the deployment ID
After you create or update an asset in your project and you're ready to run the asset, you deploy the asset in a deployment space. Your deployment space has a unique space ID that you can reference in the same way as a project ID.
To inference a tuned foundation model or use a deployed prompt template, you must provide the deployment ID for the asset.
To get the deployment ID, complete the following steps:
- From the main menu, click Deployments, and then click your deployment space.
- Open the Deployments page, and then click the deployment for the asset that you want to access programmatically.
- Copy the deployment ID from the About this deployment panel.
Learn more
Parent topic: Coding genertaive AI solutions