### List Notebooks Request Body Example Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Example payload for listing notebooks. Ensure the 'notebooks' field contains valid GUIDs. ```json { "notebooks": [ "ca3c0e27-46ca-83d4-a646-d49b11c14de9" ] } ``` -------------------------------- ### Custom Properties Example Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Example of user-defined properties as key-value pairs for custom configuration. ```json { "name": "model", "size": 2 } ``` -------------------------------- ### Example cURL Request for Utility Agent Tools Source: https://cloud.ibm.com/apidocs/watsonx-ai This is an example of how to make a cURL request to get all utility agent tools. Ensure to replace `{cluster_url}` with your actual cluster URL. ```bash curl --request GET 'https://{cluster_url}/v1-beta/utility_agent_tools' -H 'Accept: application/json' ``` -------------------------------- ### Example Response: Prompt Template Deployment Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Example of a successful response (Status 202) when a prompt template is deployed. ```APIDOC ## Status 202: A prompt template deployment. ```json { "metadata": { "id": "6213cf1-252f-424b-b52d-5cdd9814956c", "created_at": "2023-05-02T16:27:51Z", "project_id": "12ac4cf1-252f-424b-b52d-5cdd9814987f", "name": "text_classification", "description": "Classification prompt template deployment", "tags": [ "classification" ] }, "entity": { "prompt_template": { "id": "4cedab6d-e8e4-4214-b81a-2ddb122db2ab" }, "online": {}, "deployed_asset_type": "foundation_model", "base_model_id": "google/flan-t5-xl", "status": { "state": "ready", "message": { "level": "info", "text": "The deployment is successful" }, "inference": [ { "url": "https://us-south.ml.cloud.ibm.com/ml/v1/deployments/6213cf1-252f-424b-b52d-5cdd9814956c/text/generation" }, { "url": "https://us-south.ml.cloud.ibm.com/ml/v1/deployments/6213cf1-252f-424b-b52d-5cdd9814956c/text/generation_stream", "sse": true } ] } } } ``` ``` -------------------------------- ### List Available GPUs Response Source: https://cloud.ibm.com/apidocs/watsonx-ai Example response for the 'Get Available GPUs' endpoint, detailing the total count, pagination links, and a list of GPU configurations. Each configuration includes ID, description, type, memory, pricing, and billing information. ```json { "total_count": 12, "limit": 2, "first": { "href": "https://{cluster_url}/ml/v1/gpus?version=2025-01-12" }, "next": { "href": "https://{cluster_url}/ml/v1/gpus?version=2025-01-12&start=..." }, "gpu_configurations": [ { "gpu_id": "1l40s-48g", "description": "Single L40S GPU with 48 GB of memory", "gpu_type": "L40S", "gpu_count": 1, "memory_per_unit_gb": 48, "total_memory_gb": 48, "price": 4.43, "currency": "USD", "billing": "hourly", "hardware_spec": "1l40s-48g" }, { "gpu_id": "2l40s-96g", "description": "Two L40S GPUs with 96 GB of memory", "gpu_type": "L40S", "gpu_count": 2, "memory_per_unit_gb": 48, "total_memory_gb": 96, "price": 8.86, "currency": "USD", "billing": "hourly", "hardware_spec": "2l40s-96g" } ] } ``` -------------------------------- ### Example Response: Reverted Notebook (Status 200) Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp This is an example of a successful response when a notebook is reverted to a specific version. ```json { "metadata": { "name": "my notebook v4.2", "description": "this is my notebook v4.2", "asset_type": "notebook", "created": 1540471021134, "created_at": "2021-07-01T12:37:01Z", "owner_id": "IBMid-310000SG2Y", "catalog_id": "463cb8d8-8480-4a98-b75a-f7443b7d0af9", "asset_id": "41d09a9a-f771-48a2-9534-50c0c622356d", "project_id": "b275be5f-10ff-47ee-bfc9-63f1ce5addbf" }, "entity": { "notebook": { "kernel": { "display_name": "Python 3.9 with Spark", "name": "python39", "language": "python3" }, "originates_from": { "type": "blank" } }, "runtime": { "environment": "spark33py39-b275be5f-10ff-47ee-bfc9-63f1ce5addbf", "spark_monitoring_enabled": true }, "href": "/v2/assets/41d09a9a-f771-48a2-9534-50c0c622356d?project_id=b275be5f-10ff-47ee-bfc9-63f1ce5addbf" } } ``` -------------------------------- ### Example Request Source: https://cloud.ibm.com/apidocs/watsonx-ai An example of how to make a request to a Dallas endpoint, including authentication. ```APIDOC ## Example Request Example request to a Dallas endpoint: ```` curl -H "Authorization: Bearer {token}" -X {request_method} "https://us-south.ml.cloud.ibm.com/{method_endpoint}" ``` ` Copy to clipboard Replace `{request_method}`, and `{method_endpoint}` in this example with the values for your particular API call. See the `Authentication` section below for more details about the bearer `{token}`. ``` -------------------------------- ### Tenant Info Response Example Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Example of a successful response body when retrieving tenant information. ```json { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "my-tenant" } ``` -------------------------------- ### Example Response (200 OK) Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Example response for a successful retrieval of custom foundation models. ```APIDOC ```json { "total_count": 1, "limit": 10, "first": { "href": "https://{cpd_cluster}/ml/v4/custom_foundation_models" }, "resources": [ { "model_id": "my_flan_t5_xl", "description": "A tuned version of flan_t5_xl", "tags": [ "flan_t5_xl" ], "parameters": [ { "name": "max_batch_weight", "display_name": "Maximum batch weight", "default": 10000, "description": "The maximum batch weight that is allowed for this model.", "type": "number", "min": 0, "max": 100000 } ] } ], "parameters": [ { "name": "max_batch_weight", "display_name": "Maximum batch weight", "default": 100, "description": "The maximum batch weight that is allowed for all models.", "type": "number", "min": 0, "max": 10000 } ] } ``` ``` -------------------------------- ### Results Reference Example Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp This example shows how to specify the results reference for a fine-tuning job when using a connection asset. ```json { "connection": { "id": "c4225076-74fa-4033-bf93-1183a9b6c611" }, "location": { "bucket": "experiment_results_bucket", "path": "results" }, "type": "connection_asset" } ``` -------------------------------- ### Tool Calling Example Source: https://cloud.ibm.com/apidocs/watsonx-ai Example of how to use the chat completions API for tool calling. ```APIDOC ## POST /chat/completions (Tool Call Example) ### Description This example demonstrates how to configure the chat completions API to call a tool. ### Method POST ### Endpoint /chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model to use for the chat completion. - **project_id** (string) - Required - The project that contains the resource. - **messages** (array) - Required - The messages for this chat session. - **tools** (array) - Required - Tool functions that can be called with the response. - **tool_choice** (object) - Required - Specify a particular tool via `{"type": "function", "function": {"name": "get_current_weather"}}` forces the model to call that tool. ### Request Example ```json { "model": "meta-llama/llama-3-8b-instruct", "project_id": "12ac4cf1-252f-424b-b52d-5cdd9814987f", "messages": [ { "role": "user", "content": { "type": "text", "text": "What is the weather like in Boston today?" } } ], "tools": [ { "type": "function", "function": { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "description": "The city, e.g. San Francisco, CA", "type": "string" }, "unit": { "enum": [ "celsius", "fahrenheit" ], "type": "string" } }, "required": [ "location" ] } } } ], "tool_choice": { "type": "function", "function": { "name": "get_current_weather" } } } ``` ``` -------------------------------- ### Tool Calling Example Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp This example demonstrates how to enable the model to call external tools. It defines a 'get_current_weather' function and specifies its usage. ```json { "model_id": "meta-llama/llama-3-8b-instruct", "project_id": "63dc4cf1-252f-424b-b52d-5cdd9814987f", "messages": [ { "role": "user", "content": { "type": "text", "text": "What is the weather like in Boston today?" } } ], "tools": [ { "type": "function", "function": { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "description": "The city, e.g. San Francisco, CA", "type": "string" }, "unit": { "enum": [ "celsius", "fahrenheit" ], "type": "string" } }, "required": [ "location" ] } } } ], "tool_choice": { "type": "function", "function": { "name": "get_current_weather", "description": "Get the current weather for a location.\nCall this whenever you need to know the weather,\nor for example when a customer asks 'What is the weather like in New York'\n" } } } ``` -------------------------------- ### QLora Fine Tuning With Connection Asset Source: https://cloud.ibm.com/apidocs/watsonx-ai This example demonstrates how to initiate a QLoRA fine-tuning job using a connection asset for results storage and a data asset for training. ```APIDOC ## POST /ml/v1/fine_tunings ### Description Initiates a fine-tuning job with specified parameters, including QLoRA for efficient tuning and a connection asset for storing results. ### Method POST ### Endpoint `https://{cluster_url}/ml/v1/fine_tunings?version=2024-05-16` ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. - **Content-Type** (string) - Required - `application/json` - **Accept** (string) - Required - `application/json` #### Request Body - **project_id** (string) - Required - The ID of the project. - **name** (string) - Required - The name of the fine-tuning job. - **auto_update_model** (boolean) - Required - Whether to automatically update the model. - **parameters** (object) - Required - Parameters for the fine-tuning job. - **base_model** (object) - Required - Base model configuration. - **model_id** (string) - Required - The ID of the base model. - **peft_parameters** (object) - Required - PEFT (Parameter-Efficient Fine-Tuning) parameters. - **type** (string) - Required - The type of PEFT, e.g., `qlora`. - **results_reference** (object) - Required - Reference to where the results should be stored. - **connection** (object) - Required - Connection details for the results storage. - **id** (string) - Required - The ID of the connection asset. - **location** (object) - Required - Location within the connection asset. - **bucket** (string) - Required - The name of the bucket. - **path** (string) - Required - The path within the bucket. - **type** (string) - Required - The type of the results reference, e.g., `connection_asset`. - **training_data_references** (array) - Required - References to the training data. - **connection** (object) - Required - Connection details for the training data. - **location** (object) - Required - Location of the training data. - **id** (string) - Required - The ID of the data asset. - **href** (string) - Required - The HATEOAS link to the data asset. - **type** (string) - Required - The type of the data reference, e.g., `data_asset`. ### Request Example ```json { "project_id": "dbbbfd33-1cca-4c6b-a9fa-c939b5f611eb", "name": "Example - QLora fine tuning", "auto_update_model": false, "parameters": { "base_model": {"model_id": "meta-llama/llama-3-1-70b-gptq"}, "peft_parameters": {"type": "qlora"} }, "results_reference": { "connection": {"id": "c4225076-74fa-4033-bf93-1183a9b6c611"}, "location": { "bucket": "ftys1prod-donotdelete-pr-fegvx5zvy5ob8q", "path": "fine-tuning/experiment2" }, "type": "connection_asset" }, "training_data_references": [ { "connection": {}, "location": { "id": "69f07f10-ccfa-4137-816c-7a781f8c6b74", "href": "https://{cluster_url}/v2/assets/69f07f10-ccfa-4137-816c-7a781f8c6b74?project_id=dbbbfd33-1cca-4c6b-a9fa-c939b5f611eb" }, "type": "data_asset" } ] } ``` ### Response #### Success Response (200) - **FineTuningResource** (object) - The response of a fine tuning job. - **metadata** (object) - Common metadata for a resource. - **id** (string) - The unique ID of the resource. - **name** (string) - The name of the resource. - **project_id** (string) - The project that contains the resource. - **owner** (string) - The user ID which created this resource. - **created_at** (date-time) - The time when the resource was created. - **rev** (string) - The revision of the resource. - **modified_at** (date-time) - The time when the resource was last modified. - **parent_id** (string) - The ID of the parent resource where applicable. - **description** (string) - A description of the resource. - **tags** (string[]) - A list of tags for this resource. - **commit_info** (object) - Information related to the revision. - **space_id** (string) - The ID of the space this resource belongs to. - **entity** (object) - Status of the training job. - **system** (object) - Optional details coming from the service. #### Response Example ```json { "id": "6213cf1-252f-424b-b52d-5cdd9814956c", "name": "my-fine-tuning-job", "project_id": "12ac4cf1-252f-424b-b52d-5cdd9814987f", "owner": "guy", "created_at": "2023-08-04T13:22:55.289Z", "rev": "2", "modified_at": "2020-05-02T16:30:51Z", "parent_id": "dfe1cf1-252f-424b-b52d-5cdd9814600c", "description": "My resource", "tags": [ "t1", "t2" ], "commit_info": { "committed_at": "2020-05-02T16:27:51Z", "commit_message": "Updated to TF 2.0" } } ``` ``` -------------------------------- ### JSON Mode Example Source: https://cloud.ibm.com/apidocs/watsonx-ai Example of how to use the chat completions API to get JSON output. ```APIDOC ## POST /chat/completions (JSON Mode Example) ### Description This example demonstrates how to configure the chat completions API to output JSON. ### Method POST ### Endpoint /chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model to use for the chat completion. - **project_id** (string) - Required - The project that contains the resource. - **response_format** (object) - Required - Specifies the output format, e.g., `{"type": "json_object"}`. - **messages** (array) - Required - The messages for this chat session. ### Request Example ```json { "model": "meta-llama/llama-3-8b-instruct", "project_id": "12ac4cf1-252f-424b-b52d-5cdd9814987f", "response_format": { "type": "json_object" }, "messages": [ { "role": "system", "content": "You are a helpful assistant designed to output JSON." }, { "role": "user", "content": { "type": "text", "text": "Who won the world series in 2020?" } } ] } ``` ``` -------------------------------- ### Deploy a prompt template Source: https://cloud.ibm.com/apidocs/watsonx-ai This example shows how to deploy a prompt template. ```APIDOC ## POST /ml/v4/deployments ### Description Deploys a prompt template. ### Method POST ### Endpoint `https://{cluster_url}/ml/v4/deployments?version=2023-05-02` ### Parameters #### Request Body - **name** (string) - Required - The name of the deployment. - **description** (string) - Optional - A description for the deployment. - **tags** (array) - Optional - Tags for the deployment (e.g., ["classification"]). - **prompt_template** (object) - Required - Information about the prompt template. - **id** (string) - Required - The ID of the prompt template. - **base_model_id** (string) - Required - The ID of the base model to use with the template. - **online** (object) - Required - Configuration for online deployment. This can be an empty object `{}` if no specific online parameters are needed beyond the default. ### Request Example ```json { "name": "text_classification", "description": "Classification prompt template deployment", "tags": ["classification"], "prompt_template": { "id": "4cedab6d-e8e4-4214-b81a-2ddb122db2ab" }, "base_model_id": "google/flan-t5-xl", "online": {} } ``` ``` -------------------------------- ### List Notebooks Response (200 OK) Example Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Example response for a successful request to list notebooks. Includes total results and a list of notebook resources. ```json { "total_results": 1, "resources": [ { "metadata": { "guid": "41d09a9a-f771-48a2-9534-50c0c622356d", "url": "/v2/notebooks/41d09a9a-f771-48a2-9534-50c0c622356d" }, "entity": { "runtime": { "environment": "spark33py39-b275be5f-10ff-47ee-bfc9-63f1ce5addbf", "spark_monitoring_enabled": true }, "asset": { "asset_id": "41d09a9a-f771-48a2-9534-50c0c622356d", "asset_type": "notebook", "created_at": "2021-07-01T12:37:01Z", "catalog_id": "463cb8d8-8480-4a98-b75a-f7443b7d0af9", "version": 2, "project_id": "b275be5f-10ff-47ee-bfc9-63f1ce5addbf", "href": "/v2/assets/41d09a9a-f771-48a2-9534-50c0c622356d?project_id=b275be5f-10ff-47ee-bfc9-63f1ce5addbf" } } } ] } ``` -------------------------------- ### Retrieve Notebook Version API Endpoint Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Defines the GET endpoint for retrieving a specific notebook version using its GUID and the notebook's GUID. Requires Bearer authentication. ```http GET /v2/notebooks/{notebook_guid}/versions/{version_guid} ``` -------------------------------- ### Create Fine-tuning Job (QLoRA with Connection Asset) Source: https://cloud.ibm.com/apidocs/watsonx-ai Example of creating a fine-tuning job using QLoRA with a connection asset for results. ```APIDOC ## Create Fine-tuning Job (QLoRA with Connection Asset) ### Description Creates a fine-tuning job using QLoRA with a connection asset for results. ### Method POST ### Endpoint /v1/fine-tuning/jobs ### Parameters #### Request Body - **project_id** (string) - Required - The project that contains the resource. Example: `12ac4cf1-252f-424b-b52d-5cdd9814987f` - **name** (string) - Required - The name of the job. - **auto_update_model** (boolean) - Optional - If set to `true`, the result of the training will be uploaded as a model. Default: `false` - **parameters** (object) - Optional - The parameters for the job. - **base_model** (object) - Required - The base model for fine-tuning. - **model_id** (string) - Required - The ID of the base model. - **peft_parameters** (object) - Required - PEFT parameters for fine-tuning. - **type** (string) - Required - The type of PEFT, e.g., `qlora`. - **results_reference** (object) - Required - The training results reference. - **type** (string) - Required - The data source type, e.g., `connection_asset`. - **connection** (object) - Required - Connection details. - **id** (string) - Required - The ID of the connection. - **location** (object) - Required - Location details. - **bucket** (string) - Required - The name of the bucket. - **path** (string) - Required - The path within the bucket. - **training_data_references** (array) - Required - The training datasets. - **type** (string) - Required - The type of data reference, e.g., `data_asset`. - **connection** (object) - Optional - Connection details. - **location** (object) - Required - Location details. - **id** (string) - Required - The ID of the data asset. - **href** (string) - Required - The HATEOAS link to the data asset. ### Request Example ```json { "project_id": "dbbbfd33-1cca-4c6b-a9fa-c939b5f611eb", "name": "Example - QLora fine tuning", "auto_update_model": false, "parameters": { "base_model": { "model_id": "meta-llama/llama-3-1-70b-gptq" }, "peft_parameters": { "type": "qlora" } }, "results_reference": { "connection": { "id": "c4225076-74fa-4033-bf93-1183a9b6c611" }, "location": { "bucket": "ftys1prod-donotdelete-pr-fegvx5zvy5ob8q", "path": "fine-tuning/experiment2" }, "type": "connection_asset" }, "training_data_references": [ { "connection": {}, "location": { "id": "69f07f10-ccfa-4137-816c-7a781f8c6b74", "href": "https://{cluster_url}/v2/assets/69f07f10-ccfa-4137-816c-7a781f8c6b74?project_id=dbbbfd33-1cca-4c6b-a9fa-c939b5f611eb" }, "type": "data_asset" } ] } ``` ### Response #### Success Response (200) - **job_id** (string) - The ID of the created fine-tuning job. - **status** (string) - The status of the job. ``` -------------------------------- ### Create QLoRA Fine-Tuning Job with Connection Asset Source: https://cloud.ibm.com/apidocs/watsonx-ai Use this example to create a fine-tuning job with QLoRA and minimal parameters. Results are stored in a connection asset, requiring a COS or S3 connection with a defined endpoint URL. ```json { "project_id": "dbbbfd33-1cca-4c6b-a9fa-c939b5f611eb", "name": "Example - QLora fine tuning", "auto_update_model": false, "parameters": { "base_model": { "model_id": "meta-llama/llama-3-1-70b-gptq" }, "peft_parameters": { "type": "qlora" } }, "results_reference": { "connection": { "id": "c4225076-74fa-4033-bf93-1183a9b6c611" }, "location": { "bucket": "ftys1prod-donotdelete-pr-fegvx5zvy5ob8q", "path": "fine-tuning/experiment2" }, "type": "connection_asset" }, "training_data_references": [ { "connection": {}, "location": { "id": "69f07f10-ccfa-4137-816c-7a781f8c6b74", "href": "https://{cluster_url}/v2/assets/69f07f10-ccfa-4137-816c-7a781f8c6b74?project_id=dbbbfd33-1cca-4c6b-a9fa-c939b5f611eb" }, "type": "data_asset" } ] } ``` -------------------------------- ### Get Batch Jobs API Endpoint Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp This is the HTTP GET endpoint for retrieving a list of batch jobs. It supports filtering by status and pagination using 'start' and 'limit' parameters. You must provide either 'space_id' or 'project_id'. ```http GET /ml/v1/text/batches ``` -------------------------------- ### Text Chat with System Prompt and Context Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp This example demonstrates how to include a system prompt and additional context to guide the chat model's behavior and responses. ```curl curl --request POST 'https://{cluster_url}/ml/v1/deployments/{id_or_name}/text/chat?version=2023-05-02' -H 'Authorization: Bearer eyJhbGciOiJSUzUxM...' -H 'Content-Type: application/json' -H 'Accept: application/json' --data-raw '{ "context": "Today is Wednesday", "messages": [ { "role": "user", "content": { "type": "text", "text": "Who are you and which day is tomorrow?" } } ] } ' ``` -------------------------------- ### List Notebook Versions in Project (200 OK) Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Example response for a successful retrieval of notebook versions within a project. Includes metadata and entity details for each version. ```json { "total_results": 1, "resources": [ { "metadata": { "guid": "19d63b6b-81a1-4c05-bad2-36a2957bd6d0", "url": "v2/notebooks/a528b427-d1cd-4039-8ddc-04203c2521e2/versions/1a1329e0-fd05-409a-8411-52db106e2142", "created_at": 1543681714106 }, "entity": { "master_notebook_guid": "a528b427-d1cd-4039-8ddc-04203c2521e2", "project_id": "0f7c1111-a79d-45b2-9699-d4950e742964", "created_by_iui": "IBMid-123456ABCD", "file_reference": "myproject-donotdelete-pr-6p65nym92j1bv0/notebooks/GPU_ENVIRONMENT_DEFAULT_GBUXVKHH_version_1543781324804.ipynb", "rev_id": 1 } } ] } ``` -------------------------------- ### Get Tenant Details Response Source: https://cloud.ibm.com/apidocs/watsonx-ai Example response body for retrieving tenant details. Includes tenant ID, name, and remote credential store information. ```json { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "my-tenant", "remote_credential_store": { "ibm_cloud_secret_manager": { "base_url": "https://xxxx.xxxx.secrets-manager.appdomain.cloud", "group": "AccessGroupId-56c5e703-80d4-4f06-a7e6-844618ec39b3" } } } ``` -------------------------------- ### Create Notebook from Scratch Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Creates a new notebook within a specified project. Requires the notebook name, project ID, file reference to the notebook content, and runtime details. The notebook content must be uploaded to project or space storage first. ```json { "name": "my notebook", "description": "this is my notebook", "project": "b275be5f-10ff-47ee-bfc9-63f1ce5addbf", "file_reference": "notebook/my_notebook.ipynb", "runtime": { "environment": "spark33py39-b275be5f-10ff-47ee-bfc9-63f1ce5addbf", "spark_monitoring_enabled": true } } ``` -------------------------------- ### Status 201: Notebook Copied from Existing Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Example response for a notebook created by copying an existing one. The 'originates_from' field specifies the source notebook's GUID. ```json { "metadata": { "name": "my notebook", "description": "this is my notebook", "asset_type": "notebook", "created": 1540471021134, "created_at": "2021-07-01T12:37:01Z", "owner_id": "IBMid-310000SG2Y", "catalog_id": "463cb8d8-8480-4a98-b75a-f7443b7d0af9", "asset_id": "41d09a9a-f771-48a2-9534-50c0c622356d", "project_id": "b275be5f-10ff-47ee-bfc9-63f1ce5addbf" }, "entity": { "notebook": { "kernel": { "display_name": "Python 3.9 with Spark", "name": "python3", "language": "python3" }, "originates_from": { "type": "notebook", "guid": "ca3c0e27-46ca-83d4-a646-d49b11c14de9" } }, "runtime": { "environment": "spark33py39-b275be5f-10ff-47ee-bfc9-63f1ce5addbf", "spark_monitoring_enabled": true }, "href": "/v2/assets/41d09a9a-f771-48a2-9534-50c0c622356d?project_id=b275be5f-10ff-47ee-bfc9-63f1ce5addbf" } } ``` -------------------------------- ### Example Response for Get All Text Extraction Requests Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp This JSON structure represents a successful response when retrieving all text extraction requests. It includes pagination details and a list of resources. ```json { "limit": 10, "first": { "href": "https://us-south.ml.cloud.ibm.com/ml/v1/text_extractions" }, "resources": [ { "metadata": { "id": "6213cf1-252f-424b-b52d-5cdd9814956c", "created_at": "2023-05-02T16:27:51Z", "project_id": "12ac4cf1-252f-424b-b52d-5cdd9814987f", "name": "extract" }, "entity": { "document_reference": { "type": "connection_asset", "connection": { "id": "6f5688fd-f3bf-42c2-a18b-49c0d8a1920d" }, "location": { "file_name": "files/document.pdf" } }, "results_reference": { "type": "connection_asset", "connection": { "id": "2a7c11bc-2913-48d0-9581-a8d9f40fa159" }, "location": { "file_name": "results" } }, "results": { "status": "completed", "number_pages_processed": 3, "running_at": "2023-05-02T16:28:03Z", "completed_at": "2023-05-02T16:29:31Z" } } } ] } ``` -------------------------------- ### QLoRA Fine Tuning With Data Asset Source: https://cloud.ibm.com/apidocs/watsonx-ai Example of initiating a QLoRA fine-tuning job using a data asset reference. Ensure the 'Authorization' header is correctly set. ```json { "project_id": "dbbbfd33-1cca-4c6b-a9fa-c939b5f611eb", "name": "Example - QLora fine tuning", "auto_update_model": false, "parameters": { "base_model": {"model_id": "meta-llama/llama-3-1-70b-gptq"}, "peft_parameters": { "type": "lora", "rank": 16, "target_modules": ["all-linear"], "lora_alpha": 32, "lora_dropout": 0.05 }, "gradient_checkpointing": true }, "results_reference": { "connection": {}, "location": {"path": "fine-tuning/experiment1"}, "type": "container" }, "training_data_references": [ { "connection": {}, "location": { "id": "69f07f10-ccfa-4137-816c-7a781f8c6b74", "href": "https://{cluster_url}/v2/assets/69f07f10-ccfa-4137-816c-7a781f8c6b74?project_id=dbbbfd33-1cca-4c6b-a9fa-c939b5f611eb" }, "type": "data_asset" } ] } ``` -------------------------------- ### Response for PII Detection Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Example JSON response when PII is detected in the input text. It includes the start and end positions, detection type, the detected value (masked), and a confidence score. ```json { "detections": [ { "start": 20, "end": 24, "detection_type": "pii", "detection": "xxxx", "score": 0.846 } ] } ``` -------------------------------- ### Run GoogleSearch Utility Tool Source: https://cloud.ibm.com/apidocs/watsonx-ai Example of running the GoogleSearch tool with specific input and configuration. Ensure the tool name and input are correctly provided. ```json { "tool_name": "GoogleSearch", "input": "What was the weather in Toronto on January 13th 2025?", "config": { "maxResults": 3 } } ``` -------------------------------- ### Get all text extraction requests Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp Retrieves a paginated list of all text extraction resources. Users can filter results using space_id or project_id, and control pagination with start and limit parameters. ```APIDOC ## GET /ml/v1/text/extractions ### Description Retrieves a paginated list of text extraction resources. ### Method GET ### Endpoint /ml/v1/text/extractions ### Parameters #### Query Parameters - **version** (date) - Required - The version date for the API of the form `YYYY-MM-DD`. - **space_id** (string) - Optional - The space that contains the resource. Either `space_id` or `project_id` query parameter has to be given. - **project_id** (string) - Optional - The project that contains the resource. Either `space_id` or `project_id` query parameter has to be given. - **start** (string) - Optional - Token required for token-based pagination. - **limit** (integer) - Optional - How many resources should be returned. By default limit is 100. Max limit allowed is 200. ### Response #### Success Response (200) - **limit** (integer) - The number of items to return in each page. - **first** - The reference to the first item in the current page. - **total_count** (integer) - The total number of resources. - **next** - A reference to the first item of the next page, if any. - **resources** - A list of resources. - **system** - Optional details coming from the service and related to the API call or the associated resource. #### Response Example ```json { "limit": 10, "first": { "href": "https://us-south.ml.cloud.ibm.com/ml/v1/text_extractions" }, "resources": [ { "metadata": { "id": "6213cf1-252f-424b-b52d-5cdd9814956c", "created_at": "2023-05-02T16:27:51Z", "project_id": "12ac4cf1-252f-424b-b52d-5cdd9814987f", "name": "extract" }, "entity": { "document_reference": { "type": "connection_asset", "connection": { "id": "6f5688fd-f3bf-42c2-a18b-49c0d8a1920d" }, "location": { "file_name": "files/document.pdf" } }, "results_reference": { "type": "connection_asset", "connection": { "id": "2a7c11bc-2913-48d0-9581-a8d9f40fa159" }, "location": { "file_name": "results" } }, "results": { "status": "completed", "number_pages_processed": 3, "running_at": "2023-05-02T16:28:03Z", "completed_at": "2023-05-02T16:29:31Z" } } } ] } ``` ``` -------------------------------- ### Retrieve Geospatial Transformation Requests Source: https://cloud.ibm.com/apidocs/watsonx-ai This is a GET request to retrieve a list of geospatial transformation requests. You can filter by space ID or project ID and control the number of results with the limit parameter. Pagination is supported using the start token. ```http GET /ml/v1/geospatial/transformations ``` ``` -------------------------------- ### Tool Calling Example Source: https://cloud.ibm.com/apidocs/watsonx-ai-cp This example demonstrates how to configure the API to call external tools. The 'tools' and 'tool_choice' parameters specify the available functions and which one to use. ```json { "model": "meta-llama/llama-3-8b-instruct", "project_id": "12ac4cf1-252f-424b-b52d-5cdd9814987f", "messages": [ { "role": "user", "content": { "type": "text", "text": "What is the weather like in Boston today?" } } ], "tools": [ { "type": "function", "function": { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "description": "The city, e.g. San Francisco, CA", "type": "string" }, "unit": { "enum": [ "celsius", "fahrenheit" ], "type": "string" } }, "required": [ "location" ] } } } ], "tool_choice": { "type": "function", "function": { "name": "get_current_weather", "description": "Get the current weather for a location.\nCall this whenever you need to know the weather,\nor for example when a customer asks 'What is the weather like in New York'\n" } } } ``` -------------------------------- ### Retrieve Create Schema Requests Source: https://cloud.ibm.com/apidocs/watsonx-ai This GET request retrieves a list of create schema requests for a specified space or project. It requires a version date and either a `space_id` or `project_id`. Pagination is supported via `start` and `limit` parameters. ```http GET /ml/v1/text/schemas/create ```