gcp agentic platform consuming llama4 serverless
You don't necessary have to deploy llama-4 to use it, all we need to do is 'enable' and then we will get an endpoint where we can consume it.
We can use curl command :-
export ENDPOINT=us-east5-aiplatform.googleapis.com
exort REGION=us-east5
export PROJECT_ID="project-id"
curl \
-X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" https://${ENDPOINT}/v1/projects/
${PROJECT_ID}/locations/${REGION}/endpoints/openapi/chat/completions \
-d '{"model":"meta/llama-4-maverick-17b-128e-instruct-maas",
"stream":true, "messages":[{"role": "user", "content":
"Summer travel plan to Paris"}]}'
Or we can just use to consume it via python OpenAI endpoint :-
from openai import OpenAI
import google.auth, google.auth.transport.requests
creds, _ = google.auth.default()
creds.refresh(google.auth.transport.requests.Request())
client = OpenAI(
base_url="https://us-east5-aiplatform.googleapis.com/v1/projects/your-project-id/locations/us-east5/endpoints/openapi",
api_key=creds.token,
)
resp = client.chat.completions.create(
model="meta/llama-4-maverick-17b-128e-instruct-maas",
messages=[{"role": "user", "content": "Summer travel plan to Paris"}],
)
print(resp.choices[0].message.content)
Here is an example of an output :-

Comments