🧭 How toDigital MarketingIntermediate✨ AI-assisted

How to Deploy Phi-4 on Vertex AI for Landing Page Copy Tests

WittyTech Daily··4 min read
#phi-4#vertex ai#model garden#ab testing

Nobody wants to burn frontier-model tokens brainstorming the fifteenth version of "Save Time With AI." Landing page copy tests need volume, not genius: five headline angles, three subhead lengths, a couple of CTA variants, repeated every sprint. That's exactly the job a small model is built for, and Phi-4 on Vertex AI is a cheap way to run it entirely inside your own Google Cloud project instead of piping test copy through a third-party API.

This walks through deploying Microsoft's Phi-4 from Vertex AI Model Garden, generating a batch of landing page copy variants, and tearing the endpoint down so it doesn't quietly bill you between test cycles.

By the end you'll have a live Vertex AI endpoint serving Phi-4 and a Python function that turns a product description into a set of headline and subhead variants ready to drop into your testing tool.

1. Turn on Vertex AI in your project

You need a Google Cloud project with billing enabled and the Vertex AI API turned on.

gcloud config set project <your-project-id>
gcloud services enable aiplatform.googleapis.com

If you've never deployed a model in this project before, also check your GPU quota under IAM & Admin > Quotas, filtered to aiplatform.googleapis.com and the region you plan to deploy in (this guide uses us-central1). Phi-4 deployments need a Custom Model Serving GPU quota; a fresh project often starts at zero and you'll need to request an increase before step 3 will succeed.

2. Install the SDK and authenticate

pip install --upgrade --quiet "google-cloud-aiplatform>=1.106.0" openai
gcloud auth application-default login

The openai-compatible client isn't required for the deployment itself, but Vertex AI's open-model endpoints expose an OpenAI-style chat interface, which is handy if you later want to swap Phi-4 into code that already talks to OpenAI's SDK.

3. Deploy Phi-4 from Vertex AI Model Garden

Microsoft's Phi-4 ships as a gated model in Model Garden, so deploying it means accepting the license and letting Vertex AI provision a GPU-backed endpoint. Google's sample deployment notebook shows the exact call:

import vertexai
from vertexai import model_garden

vertexai.init(project="<your-project-id>", location="us-central1")

# other options: "phi-4-reasoning", "phi-4-reasoning-plus"
MODEL_NAME = "microsoft/phi4@phi-4"

model = model_garden.OpenModel(MODEL_NAME)

endpoint = model.deploy(
    accept_eula=True,
    use_dedicated_endpoint=False,
)

print(endpoint.resource_name)

This takes roughly 15 to 20 minutes while Vertex AI spins up the serving container and loads weights. accept_eula=True is required; without it the call fails immediately. Keep the printed endpoint.resource_name, you'll need it if you reconnect in a new session.

4. Generate landing page copy variants

Once the endpoint is live, call it with a prompt shaped for what you actually need: a batch of distinct headline and subhead pairs, not one polished paragraph.

def generate_variants(endpoint, product, audience, n=4):
    prompt = (
        f"You are a direct-response copywriter. Write {n} distinct "
        f"landing page hero headlines (under 10 words each) with a "
        f"one-sentence subhead, for {product}, targeting {audience}. "
        f"Output as a numbered list, no extra commentary."
    )
    instances = [{
        "prompt": prompt,
        "max_tokens": 300,
        "temperature": 0.9,
        "top_p": 0.95,
        "top_k": 40,
        "raw_response": False,
    }]
    response = endpoint.predict(instances=instances, use_dedicated_endpoint=False)
    return response.predictions[0]

variants = generate_variants(
    endpoint,
    product="an AI-powered expense reconciliation tool",
    audience="finance managers at mid-size companies",
)
print(variants)

The higher temperature and top_p push Phi-4 toward more varied phrasing across the numbered list, which is what you want when the goal is distinct test arms rather than one "best" answer.

5. Wire the variants into your A/B test

Copy the numbered outputs into whatever tool runs your experiment, VWO, Optimizely, a GA4 experiment, or a simple feature flag if you're rolling your own split. Treat Phi-4's output as a first draft: have a human check every claim it makes about the product before it goes live. A 14-billion-parameter model is good at rhythm and structure, not at knowing your actual feature set, so watch for invented stats or capabilities.

6. Shut the endpoint down when you're done

A deployed Phi-4 endpoint bills for GPU time whether or not you're calling it. Delete it as soon as you've pulled your batch of variants:

endpoint.delete(force=True)

force=True undeploys the model from the endpoint first, then deletes the endpoint itself, so you don't need a separate undeploy call.

Gotchas

  • GPU quota rejections show up as a deploy failure, not a clear error. If model.deploy() hangs or fails, check your quota before anything else.
  • accept_eula=True is mandatory. Phi-4 is a gated model in Model Garden and the deploy call fails without it.
  • Endpoints cost money while idle. Don't leave one running between copy-test sprints; redeploying only takes the 15 to 20 minute wait from step 3.
  • Don't trust the numbers Phi-4 invents. It'll happily write "cut costs by 40%" if your prompt doesn't stop it. Strip or verify any specific claim before it reaches a real page.

Running Phi-4 in your own Vertex AI project means your draft copy, and whatever product details you feed it, never leaves your cloud boundary, which matters the moment marketing and legal start asking where that headline came from.

← More in Digital Marketing