You can work with foundation models in IBM watsonx.ai programmatically by using the watsonx.ai API.
See the API reference documentation.
You can also use the REST API to perform the following tasks:
- Get foundation model information
- Inference foundation models
- Add generative chat to your applications with the chat API
- Build agent-driven chat workflows
- Extract text from documents
- Prompt tuning a foundation model
- Vectorize text
- Rerank document passages
- Forecast future values
Prerequisites
Go to the Developer access page for quick access to the following information:
- Base URL for API endpoints and your
- Project or space ID
From the watsonx.ai home page for the project or space that you want to work with, open the Navigation Menu , and then click Developer access.
You also need the following information to submit REST API requests:
-
To use the watsonx.ai API, you need a bearer token.
For more information, see Credentials for programmatic access.
-
You must specify the
{model_id}
for the foundation model that you want to use.You can use the List the available foundation models method to get the ID for a foundation model.
For a list of the model IDs for the foundation models that are included with watsonx.ai, see Foundation model IDs for APIs.
-
Specify the date on which you created and tested your code in the version parameter that is required with each request. For example,
version=2024-10-21
.
Some tasks require you to reference data that is made available as a data connection. For more information about how to add a file, and then reference a file from the API, see Referencing files from the API.
If you want help with formatting an inference request in the API, you can submit the same request from the Prompt Lab. From the code panel of Prompt Lab, which shows the cURL request that is generated by your prompt, you can check the syntax that is used.
Parent topic: Coding generative AI solutions