# SkillPatch skill: agent-platform-deploy

This skill provides step-by-step instructions for deploying open models or custom weights from Model Garden to Agent Platform endpoints. It covers the full lifecycle including discovering deployable models, deploying, checking deployment status, verifying serving endpoints, undeploying models, and deleting endpoints. It also supports copying and deploying 1P (First-Party) Tuned Models across projects or regions.

You (the agent) were given this URL and asked to use this skill. This is a **public** skill — no SkillPatch account, API key, or prior setup is required. Two ways to use it:

**1. Use it right now** — the skill's complete file tree (SKILL.md + all reference files) is inlined below; read `SKILL.md` first, then follow it, consulting the other files as it directs.

**2. Install the exact package onto disk** (recommended if you can run a shell — this reproduces the skill byte-for-byte, including any binary assets that can't be inlined):

```bash
mkdir -p .claude/skills/agent-platform-deploy
curl -sSL https://skillpatch.dev/install_skill/agent-platform-deploy | tar -xz -C .claude/skills/
```

(`.claude/skills/` is Claude Code's convention; use whatever directory your agent loads skills from.)


---

## Skill files (4)

- `SKILL.md`
- `references/copy_deploy_guide.md`
- `references/usage.md`
- `scripts/config_gcloud_cli.sh`


### `SKILL.md`

````markdown
---
name: agent-platform-deploy
metadata:
  category: AiAndMachineLearning
description: >-
  Deploy open models or custom weights from Model Garden to Agent Platform
  endpoints, check deployment status, verify serving endpoints, or clean up
  resources by undeploying models and deleting endpoints. Use when asked to
  deploy models on Agent Platform, list available Model Garden models, check if
  a model is deployable, query deployment cost, troubleshoot deployment errors
  (like quota limits), or undeploy/clean up endpoints. Also use when copying
  and deploying a 1P Tuned Model. Don't use for public Vertex AI deployments
  (use the `vertex-deploy` skill) or for running model evaluations (use the
  `agent-platform-eval` skill).
---

# Agent Platform Model Garden Deploy Skill

This skill provides instructions for deploying Open Models from Agent Platform
Model Garden to endpoints, and subsequently undeploying them to clean up
resources.

## 1P Tuned Model Copy & Deployment

If you need to copy a **1P (First-Party) Tuned Model** from a source project to a destination region or project and deploy it to a newly created endpoint, refer to the [1P Tuned Model Copy & Deployment Guide](references/copy_deploy_guide.md).

## Safety & Confirmation Tiers (CRITICAL)

Before executing any commands on behalf of the user, you MUST adhere to the
following safety tiers based on the action requested:

1.  **Tier R: Read-only (`list`, `describe`, `list-deployment-config`)**
    *   **Rule**: No confirmation needed. You may execute these commands immediately to gather information for the user.
2.  **Tier M: Mutating & Reversible (`deploy`, `undeploy-model`)**
    *   **Rule**: This requires explicit user confirmation. You MUST present a
        clear confirmation prompt to the user explaining the proposed command.
        You MUST wait for their explicit confirmation before executing. For
        `undeploy-model`, you MUST first verify that the endpoint and deployed
        model exist; if `describe` or `list` returns a 404 or empty result, you
        MUST halt and inform the user rather than attempting undeployment.
3.  **Tier D: Destructive & Irreversible (`delete`)**
    *   **Rule**: This requires **explicit typed confirmation**. You MUST output
        a text message explaining the irreversible nature of endpoint or model
        deletion and asking the user to type "I confirm" or "Yes, delete it"
        before executing the deletion command.

## 1. Prerequisites

Before deploying, ensure you have the correct project and region set. The
commands below use placeholder variables `PROJECT_ID` and `LOCATION_ID`.

Ensure you are authenticated:

```bash
gcloud auth login
gcloud auth application-default login
gcloud config set project $PROJECT_ID
```

## 2. Discovering Deployable Models

You can list models available in Model Garden and check if they can be
self-deployed.

```bash
gcloud ai model-garden models list
```

To see what machine types and accelerators are supported for a specific model
(e.g., `google/gemma3@gemma-3-27b-it`):

```bash
gcloud ai model-garden models list-deployment-config \
    --model="google/gemma3@gemma-3-27b-it"
```

> [!NOTE] Some models, especially Hugging Face models, might require a Hugging
> Face Access Token for deployment.

> [!TIP] **Model Recommendation Instructions:** If a user asks to deploy a model
> but **does not specify which one**, you should recommend a model based on
> their use case (e.g., Llama 3.3 70B for general purpose or Gemma 3 for
> lightweight tasks). * You **MUST** ensure you are recommending the **latest
> version** or **popular version** of the suggested model family. * You **MUST**
> verify the model is currently deployable using `gcloud ai model-garden models
> list` before suggesting it to the user.

## 3. Deploying a Model

> [!WARNING] Deploying models, especially large ones, consumes significant
> compute resources and incurs costs.
>
> 1. You **MUST** refer to
>    [Agent Platform prediction pricing](https://cloud.google.com/products/gemini-enterprise-agent-platform/pricing?hl=en#prediction-and-explanation)
>    to calculate a rough cost estimation based on the requested `--machine-type`
>    and `--accelerator-type` (and count).
> 2. You **MUST** present this cost estimation to the user and warn them that
>    this is the **list price**, which may differ from their actual bill due to
>    potential discounts or reservations.
> 3. You **MUST ALWAYS** request explicit confirmation from the user agreeing to
>    the estimated cost before executing any `deploy` command.

To deploy a model, use the `deploy` command. It is highly recommended to use the
`--asynchronous` flag for long-running deployments, and then poll the status if
necessary.

### Example: Deploying Gemma 3

Here is a typical bash script to deploy a model. You can run this block
directly.

```bash
#!/bin/bash
# Example script to deploy a model from Model Garden

PROJECT_ID=$(gcloud config get-value project)
LOCATION_ID="us-central1" # Recommended default region
MODEL_ID="google/gemma3@gemma-3-27b-it" # Replace with your chosen model ID

echo "Deploying model $MODEL_ID to project $PROJECT_ID in $LOCATION_ID..."

# Model Garden can automatically select the required hardware based on the list-deployment-config if hardware params are omitted.
# Below is a comprehensive command with all supported parameters:
gcloud ai model-garden models deploy \
    --project=$PROJECT_ID \
    --region=$LOCATION_ID \
    --model=$MODEL_ID \
    --machine-type="g2-standard-48" \
    --accelerator-type="NVIDIA_L4" \
    --accelerator-count=4 \
    --endpoint-display-name="my-gemma-deployment" \
    --hugging-face-access-token="YOUR_HF_TOKEN" \
    --reservation-affinity="reservation-affinity-type=specific-reservation,key=compute.googleapis.com/reservation-name,values=my-reservation" \
    --asynchronous

echo "Deployment initiated asynchronously."
```

### Example: Deploying Custom Weights

To deploy a model using custom weights, you can use the exact same `deploy`
command. Instead of providing the model garden model ID, provide the Google
Cloud Storage (GCS) URI to your custom weights folder in the `--model` flag.

```bash
#!/bin/bash
# Example script to deploy a model with custom weights from a GCS bucket

PROJECT_ID=$(gcloud config get-value project)
LOCATION_ID="us-central1"
# Replace with the gs:// URI pointing to your custom weights
MODEL_GCS_URI="gs://your-bucket-name/path/to/custom-weights"

echo "Deploying custom model from $MODEL_GCS_URI to project $PROJECT_ID in $LOCATION_ID..."

gcloud ai model-garden models deploy \
    --project=$PROJECT_ID \
    --region=$LOCATION_ID \
    --model=$MODEL_GCS_URI \
    --machine-type="g2-standard-12" \
    --accelerator-type="NVIDIA_L4" \
    --endpoint-display-name="my-custom-model" \
    --asynchronous

echo "Deployment initiated asynchronously."
```

## 4. Checking Deployment Status

When you deploy a model asynchronously using the `--asynchronous` flag, the
`deploy` command will return an operation ID. You can use this ID to check the
ongoing status of the deployment.

```bash
gcloud ai operations describe YOUR_OPERATION_ID \
    --region=$LOCATION_ID
```

> [!NOTE] As an agent, you can also offer to check the status of a deployment
> for the user if they provide an operation ID or if they just initiated the
> deployment with you.

Alternatively, you can list your endpoints to see if it shows up and check the
Cloud Console under the "Online prediction" tab.

```bash
gcloud ai endpoints list \
    --region=$LOCATION_ID
```

Note: Large models (like Llama 3.1 8B or Gemma 27B) may take 15-20 minutes to
fully deploy and start serving.

### Verifying Deployment

If the model is successfully deployed, verify by making a prediction call to
test. Because Model Garden models are often deployed to Dedicated Endpoints, you
shouldn't use `gcloud ai endpoints predict`. Instead, you must fetch the
endpoint's dedicated DNS name and send a `curl` request.

> [!TIP] Ask the user to try using their own prompt to see the results.
> Otherwise use the default.

Use the following script:

```bash
#!/bin/bash
PROJECT_ID=$(gcloud config get-value project)
LOCATION_ID="us-central1"
ENDPOINT_ID="YOUR_ENDPOINT_ID"
PROMPT=${1:-"Explain quantum computing in simple terms."}

echo "Fetching dedicated Endpoint DNS..."
ENDPOINT_URL=$(gcloud ai endpoints describe $ENDPOINT_ID --project=$PROJECT_ID --region=$LOCATION_ID --format="value(dedicatedEndpointDns)")

if [ -z "$ENDPOINT_URL" ]; then
    echo "Error: Could not retrieve a dedicated endpoint URL. Verify your ENDPOINT_ID."
    exit 1
fi

echo "Sending prediction request to $ENDPOINT_URL..."
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  "https://${ENDPOINT_URL}/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION_ID}/endpoints/${ENDPOINT_ID}/chat/completions" \
  -d '{
    "model": "'"$ENDPOINT_ID"'",
    "messages": [
      {
        "role": "user",
        "content": "'"$PROMPT"'"
      }
    ]
  }'
```

## 5. Undeploying and Cleaning Up

To stop incurring charges, you must undeploy the model from the endpoint. This
is a multi-step process if you don't already have the exact endpoint and
deployed model IDs.

### Example: Finding and Undeploying a Model

Here is a bash script demonstrating how to find the IDs and undeploy the model.

```bash
#!/bin/bash
# Example script to undeploy a model

PROJECT_ID=$(gcloud config get-value project)
LOCATION_ID="us-central1"
# The model ID used during deployment (without the provider prefix sometimes, or exactly as listed in describe)
# It's usually easier to find the specific ID via `gcloud ai models list`
# For this example, let's assume we know the exact Endpoint ID and Deployed Model ID.

# 1. Find the Endpoint ID
echo "Listing endpoints in $LOCATION_ID:"
gcloud ai endpoints list --project=$PROJECT_ID --region=$LOCATION_ID

# (Assuming you extracted ENDPOINT_ID from the above output)
# ENDPOINT_ID="your_endpoint_id"

# 2. Find the Deployed Model ID
echo "Listing models in $LOCATION_ID to find model description:"
gcloud ai models list --project=$PROJECT_ID --region=$LOCATION_ID

# (Assuming you found the specific MODEL_ID)
# MODEL_ID="your_model_id"
# gcloud ai models describe $MODEL_ID --project=$PROJECT_ID --region=$LOCATION_ID
# (Extract the deployedModelId from the output)
# DEPLOYED_MODEL_ID="your_deployed_model_id"

# 3. Undeploy
echo "Undeploying model $DEPLOYED_MODEL_ID from endpoint $ENDPOINT_ID..."
gcloud ai endpoints undeploy-model $ENDPOINT_ID \
    --project=$PROJECT_ID \
    --region=$LOCATION_ID \
    --deployed-model-id=$DEPLOYED_MODEL_ID

echo "Model undeployed."

# 4. Delete Endpoint
echo "Deleting endpoint $ENDPOINT_ID..."
gcloud ai endpoints delete $ENDPOINT_ID \
    --project=$PROJECT_ID \
    --region=$LOCATION_ID \
    --quiet
echo "Endpoint deleted."

# 5. Delete Model
echo "Deleting model $MODEL_ID..."
gcloud ai models delete $MODEL_ID \
    --project=$PROJECT_ID \
    --region=$LOCATION_ID \
    --quiet
echo "Model deleted."
```

> [!WARNING] Failing to undeploy a model will result in continuous charges for
> the allocated compute resources, even if you are not sending prediction
> requests. Always clean up after testing.

## 6. Troubleshooting

### Deployment Failure: Quota or Resource Exhausted

If your deployment fails (or stays in an error state) due to `QUOTA_EXCEEDED` or
`RESOURCE_EXHAUSTED` errors, the specific hardware requested (e.g., `NVIDIA_L4`
or `g2-standard-24`) is either not available in your chosen region or exceeds
your project's quota limits.

**Solution:** Look closely at the error message returned. It will often
recommend an alternative region or machine type that currently has availability.
**Ask the user for confirmation** to retry the deployment using the suggested
`--region` or `--machine-type` parameters.

> [!WARNING] If the alternative suggestions involve changing the machine type or
> accelerator, you **MUST** recalculate the estimated cost using
> [Agent Platform prediction pricing](https://cloud.google.com/products/gemini-enterprise-agent-platform/pricing?hl=en#prediction-and-explanation),
> warn the user about list prices versus actual billing, and get their explicit
> confirmation for the new cost before retrying the deployment.

````


### `references/copy_deploy_guide.md`

````markdown
# Agent Platform 1P Tuned model copy and deployment

> [!NOTE]
> **1P Specific**: This guide and its automated workflows are specifically
> designed for **1P (First-Party) Tuned Models** on Agent Platform.

In tuned model tuning and inferencing, Eng need to copy a tuned model to other
regions or projects and deploy it to a newly created endpoint to test. Eng can
benefit from the endpoint creation, model deployment and verification automation
with minimal user input and intervention.

The tasks can be described as follows:

-   `[]` Configure `gcloud` profile for prod environment.
-   `[]` Add IAM policy binding for P4SA (Service Agent) to the source project
-   `[]` Copy the tuned model to the destination project
-   `[]` Wait for copy operation to complete
-   `[]` Create a new shared endpoint
-   `[]` Deploy copied model to the endpoint
-   `[]` Wait for model deployment to complete
-   `[]` Test the endpoint with test prompts

## Step 0: Env selection and preparation

Ensure the foundational environment is ready before proceeding.
If user is copying model in different region, skip the P4SA setup section.

### 0.0 Pick a development environment & Confirm Destination Context

-   **CRITICAL: Ask for Confirmation.** You MUST present a clear confirmation
    prompt to confirm the development
    environment (e.g., `prod`), destination project (`dest-proj`), and region
    (`us-central1`) with the user. You MUST halt execution and wait for the
    user's explicit confirmation response before running any `gcloud` or `curl`
    commands. If you are generating a script for the user instead of running
    commands live, you MUST explicitly include a note in your response explaining
    that confirming the development environment (e.g., prod) and destination
    context with the user is required before running the script live.
-   Execute the following command to set the global variable.
    `export ENV="prod"`

### 0.1 Authentication & Project Context

-   Check if `gcloud` CLI is installed. If it is not installed, prompt the user for permission to install it before proceeding.
-   Verify `gcloud auth list`. If not authenticated, run `gcloud auth login`.
-   Execute the following command to set the global variable.
    `export PROJECT_ID=${PROJECT_ID} REGION=${REGION}`
-   Check if ${USER} have value, or ask user to set one.

### 0.2 GCloud CLI setup

-   use `scripts/config_gcloud_cli.sh ${ENV} ${PROJECT_ID} ${REGION} ${USER}`

### 0.3 P4SA Setup

#### 0.3.0 Goal

To copy a model from source project ${SOURCE_PROJECT} to the destination project
${PROJECT_ID}, and ${REGION}, follow
<!-- disableFinding(LINE_OVER_80) -->
https://docs.cloud.google.com/gemini-enterprise-agent-platform/machine-learning/model-registry/copy-model, add the
<!-- enableFinding(LINE_OVER_80) -->
P4SA of the destination project as a new principal to the source project and
assign the Vertex AI Service Agent role to it.

#### 0.3.1 P4SA selection

-   Get project number ${PROJECT_NUMBER} from the output of the translator.
    `/google/bin/releases/oneplatform/chemist/project_id_number_translator
    --projects=${PROJECT_ID}`
-   Destination project P4SA ${P4SA} based on ${ENV} selection
    -   **autopush** or **staging**:
        `service-${PROJECT_NUMBER}@gcp-sa-${ENV}-aiplatform.iam.gserviceaccount.com`
    -   **prod**:
        `service-${PROJECT_NUMBER}@gcp-sa-aiplatform.iam.gserviceaccount.com`

#### 0.3.2 P4SA assignment

-   The ${MODEL} to copy should in format of
    `projects/${SOURCE_PROJECT}/locations/${SOURCE_REGION}/models/${MODEL_ID}`

-   Get source project name `${SOURCE_PROJECT}` from the model to copy.

-   Check IAM binding: if destination project `${P4SA}` exist and have `Vertex
    AI Service Agent` role. Sample command:
    ```bash
    gcloud projects get-iam-policy-binding ${SOURCE_PROJECT} \
    --member="serviceAccount:service-${PROJECT_NUMBER}@gcp-sa-staging-aiplatform.iam.gserviceaccount.com"
    ```

-   If not, add it with the sample command, save and wait for 2 minutes.
    ```bash
    gcloud projects add-iam-policy-binding ${SOURCE_PROJECT} \
    --member="serviceAccount:service-${PROJECT_NUMBER}@gcp-sa-staging-aiplatform.iam.gserviceaccount.com" \
    --role="roles/aiplatform.serviceAgent"

    gcloud projects add-iam-policy-binding ${SOURCE_PROJECT} \
    --member="serviceAccount:service-${PROJECT_NUMBER}@gcp-sa-aiplatform.iam.gserviceaccount.com" \
    --role="roles/aiplatform.serviceAgent"
    ```

-   If failed, try to add user's account to destination project.
    ```bash
    gcloud projects add-iam-policy-binding gemini-billing-prober-018 \
    --member="user:${USER}@google.com" --role="roles/aiplatform.admin"
    ```

-   If failed again, prompt user to do it.

## Step 1: Verify the source model exists and valid

```bash
curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" ${ENDPOINT}/ui/${MODEL}
```

## Step 2: Copy source model to destination project

If user is copying to different project and different region, try copy the model
to the desired region in the source project first, then copy across project.

### Step 2.0 Verify the iam binding exists

Make sure the destination project P4SA is added to source project as
`roles/aiplatform.serviceAgent` before proceeding.

### Step 2.1 Run copy model command and poll for LRO completion

Copying a model is a Long-Running Operation (LRO). You MUST capture the
operation ID from the initial `models:copy` response and implement a polling
loop to check the operation status over time. You MUST NOT proceed to create
the endpoint until the operation status is `done: true` and contains the
copied model metadata. If the copy operation fails (e.g., with
`403 PERMISSION_DENIED` or `error`), you MUST halt execution immediately and
report the exact error to the user.

```bash
# 1. Start Copy Operation
COPY_RESP=$(curl -s -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json; charset=utf-8" -d '{ "sourceModel":"'"${MODEL}"'"}' "${ENDPOINT}/v1/projects/${PROJECT_ID}/locations/${REGION}/models:copy")
echo "Copy response: $COPY_RESP"
OPERATION_ID=$(echo "$COPY_RESP" | grep -o '"name": "[^"]*' | grep -o '[^"]*$')

if [ -z "$OPERATION_ID" ]; then
    echo "Error: Failed to initiate model copy. Response: $COPY_RESP"
    exit 1
fi

echo "Polling copy operation: $OPERATION_ID..."
while true; do
    OP_STATUS=$(curl -s -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" "${ENDPOINT}/v1/${OPERATION_ID}")
    IS_DONE=$(echo "$OP_STATUS" | grep -o '"done": true')
    HAS_ERROR=$(echo "$OP_STATUS" | grep -o '"error":')

    if [ -n "$HAS_ERROR" ]; then
        echo "Error during model copy: $OP_STATUS"
        exit 1
    fi

    if [ -n "$IS_DONE" ]; then
        echo "Model copy completed successfully!"
        MODEL_COPY=$(echo "$OP_STATUS" | grep -o '"model": "[^"]*' | grep -o '[^"]*$' | head -n 1)
        break
    fi
    echo "Copy in progress... waiting 10 seconds."
    sleep 10
done
```

### Step 2.2 Run describe model command

Get the copied model ${MODEL_COPY} from the LRO polling output. Describe it.

```bash
curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" ${ENDPOINT}/ui/${MODEL_COPY}
```

## Step 3: Create an endpoint

Prompt user `Creating a Public Shared endpoint in selected region: ${REGION}`.
Ask the user desired endpoint display name ${NAME}, prefer
`${<publisher_model_id>-tuned}` like "gemini-3-flash-tuned", default is
`copy-tuned`. If user wants to create a Dedicated Endpoint, say function to be
add.

```bash
gcloud ai endpoints create --region=${REGION} --display-name=${NAME}
gcloud ai endpoints list --region=${REGION}   --filter=display_name=${NAME}
```

Get the created endpoint id ${NEW_ENDPOINT}, it should be in format of
`projects/${PROJECT_NUMBER}/locations/${REGION}/endpoints/${NEW_ENDPOINT_ID}`.

## Step 4: Deploy the model to the endpoint

```bash
curl -X POST   -H "Content-Type: application/json"  \
 -H "Authorization: Bearer $(gcloud auth print-access-token)"  \
 "${ENDPOINT}/v1/projects/${NEW_ENDPOINT}:deployModel" \
 -d "{'deployedModel': {'model':'${MODEL_COPY}','displayName': '${NAME}'},}"
```

Get the deploy model operation ${OPERATION} status.

`curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)"
${ENDPOINT}/ui/${OPERATION}`

Once operation is done, check the endpoint status.

```bash
gcloud ai endpoints describe ${NEW_ENDPOINT}
```

## Step 5: Send a request and verify the endpoint

```bash
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)"  -H "Content-Type: application/json" ${ENDPOINT}/v1/${NEW_ENDPOINT}:generateContent -d '{  "contents":  {    "role": "USER",   "parts" : { "text" : "Hello world" }  },}'
```

## Clean Up

Prompt asking whether or not user want to clean up each resources created during
execution.

### 1. Endpoint

If user want to delete the created endpoint, undeploy the model first, then
delete the endpoint

```bash
gcloud ai endpoints undeploy-model ${NEW_ENDPOINT} ${MODEL_COPY}
gcloud ai endpoints delete
```

### 2. Model

```bash
gcloud ai models delete ${MODEL_COPY}
```

### 3. Env variables

Only execute these commands after confirm use does no want to or already
finished clean up copied model and endpoint.

```bash
gcloud config configurations delete ${ENV}-cdmodel
unset MODEL_COPY
unset MODEL
unset NEW_ENDPOINT
unset ENDPOINT
unset PROJECT_ID
unset PROJECT_NUMBER
unset ENV
unset REGION
unset OPERATION
unset NAME
```

````


### `references/usage.md`

````markdown
# Sample Prompts

* User prompt:
```
I want to use `prod` as development environment.
copy the tuned model `projects/660615731069/locations/us-central1/models/6924512025989087232`
to project `gemini-billing-prober-018`
in region `us-central1`
and deploy it to a newly created shared endpoint.
All use name `gemini-3-flash-tuned`
and then test the endpoint with a few prompts.
```
````


### `scripts/config_gcloud_cli.sh`

```
#!/bin/bash

ENV=${1:-$ENV}
PROJECT_ID=${2:-$PROJECT_ID}
REGION=${3:-$REGION}
USER=${4:-$USER}

if [[ -z "${PROJECT_ID}" ]]; then
    echo "Error: PROJECT_ID is not set (neither as an argument nor as an environment variable)."
    exit 1
fi

if [[ -z "${USER}" ]]; then
    echo "Error: USER is not set (neither as an argument nor as an environment variable)."
    exit 1
fi

if [[ -z "${ENV}" ]]; then
    ENV="prod"
fi

if [[ -z "${REGION}" ]]; then
    echo "Error: REGION is not set (neither as an argument nor as an environment variable)."
    exit 1
fi

ENDPOINT="https://${REGION}-${ENV}-aiplatform.sandbox.googleapis.com"

echo "PROJECT_ID: ${PROJECT_ID}"
echo "USER: ${USER}"
echo "Env: ${ENV}"
echo "Region: ${REGION}"
echo "Endpoint: ${ENDPOINT}"

if ! gcloud config configurations describe "${ENV}-cdmodel" > /dev/null 2>&1; then
  gcloud config configurations create "${ENV}-cdmodel"
  gcloud config set core/project "${PROJECT_ID}"
  gcloud config set compute/region "${REGION}"
  gcloud config set account "${USER}"@google.com
  gcloud config set api_endpoint_overrides/aiplatform "${ENDPOINT}"
fi

gcloud config configurations activate ${ENV}-cdmodel

# gcloud config configurations delete prod-cdmodel

```
