|
| 1 | +# Setting Up Vertex AI as an ExternalProvider |
| 2 | + |
| 3 | +This guide covers configuring Vertex AI (Claude models via Google Cloud) |
| 4 | +as an ExternalProvider on MaaS. |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | + |
| 8 | +- A GCP service account JSON key file with access to Vertex AI Anthropic models |
| 9 | +- Claude models enabled in the GCP project's Model Garden |
| 10 | +- MaaS deployed with IPP (payload-processing) that includes the `apikey-injection` plugin with OAuth2 support |
| 11 | + |
| 12 | +## 1. Create the Secret |
| 13 | + |
| 14 | +The secret must contain the GCP service account JSON key and have the |
| 15 | +`ipp-managed` label so the `apikey-injection` plugin can find it: |
| 16 | + |
| 17 | +```bash |
| 18 | +oc create secret generic vertex-sa-key \ |
| 19 | + --from-file=gcp-service-account-json=<your-service-account-key>.json \ |
| 20 | + -n <model-namespace> |
| 21 | + |
| 22 | +oc label secret vertex-sa-key \ |
| 23 | + inference.llm-d.ai/ipp-managed=true \ |
| 24 | + -n <model-namespace> |
| 25 | +``` |
| 26 | + |
| 27 | +## 2. Create the ExternalProvider |
| 28 | + |
| 29 | +```yaml |
| 30 | +apiVersion: inference.opendatahub.io/v1alpha1 |
| 31 | +kind: ExternalProvider |
| 32 | +metadata: |
| 33 | + name: vertex |
| 34 | + namespace: <model-namespace> |
| 35 | +spec: |
| 36 | + provider: vertex |
| 37 | + endpoint: aiplatform.googleapis.com |
| 38 | + auth: |
| 39 | + type: oauth2 |
| 40 | + secretRef: |
| 41 | + name: vertex-sa-key |
| 42 | + config: |
| 43 | + project: <gcp-project-id> |
| 44 | + location: global |
| 45 | + anthropicVersion: vertex-2023-10-16 |
| 46 | +``` |
| 47 | +
|
| 48 | +### Provider config fields |
| 49 | +
|
| 50 | +| Field | Value | Notes | |
| 51 | +|-------|-------|-------| |
| 52 | +| `provider` | `vertex` | Triggers Vertex-specific request translation | |
| 53 | +| `endpoint` | `aiplatform.googleapis.com` | Global Vertex AI endpoint | |
| 54 | +| `auth.type` | `oauth2` | IPP generates OAuth2 tokens from the service account key automatically | |
| 55 | +| `config.project` | Your GCP project ID | Must match the project where Claude models are enabled | |
| 56 | +| `config.location` | `global` | Required for Opus 4.8; other models may support regional endpoints | |
| 57 | +| `config.anthropicVersion` | `vertex-2023-10-16` | Required Anthropic API version header for Vertex | |
| 58 | + |
| 59 | +## 3. Add Vertex to an ExternalModel |
| 60 | + |
| 61 | +Add a Vertex provider ref to an existing ExternalModel, or create a new one: |
| 62 | + |
| 63 | +```yaml |
| 64 | +apiVersion: inference.opendatahub.io/v1alpha1 |
| 65 | +kind: ExternalModel |
| 66 | +metadata: |
| 67 | + name: <model-name> |
| 68 | + namespace: <model-namespace> |
| 69 | +spec: |
| 70 | + externalProviderRefs: |
| 71 | + - ref: |
| 72 | + name: vertex |
| 73 | + targetModel: <model-name> |
| 74 | + apiFormat: vertex-messages |
| 75 | + path: /v1/projects/{project}/locations/{location}/publishers/anthropic/models/<model-name>:rawPredict |
| 76 | + weight: 100 |
| 77 | +``` |
| 78 | + |
| 79 | +### Model config fields |
| 80 | + |
| 81 | +| Field | Value | Notes | |
| 82 | +|-------|-------|-------| |
| 83 | +| `apiFormat` | `vertex-messages` | Triggers Vertex Anthropic request/response translation | |
| 84 | +| `path` | See above | `{project}` and `{location}` are resolved from the provider config at runtime | |
| 85 | +| `targetModel` | e.g. `claude-opus-4-8` | Model name **without** date suffix | |
| 86 | +| `weight` | `100` | Set to 0 to disable this provider | |
| 87 | + |
| 88 | +## 4. Test |
| 89 | + |
| 90 | +```bash |
| 91 | +export GATEWAY="https://<your-gateway-host>" |
| 92 | +export API_KEY="<your-maas-api-key>" |
| 93 | +
|
| 94 | +curl -sk \ |
| 95 | + -H "Content-Type: application/json" \ |
| 96 | + -H "x-api-key: $API_KEY" \ |
| 97 | + "$GATEWAY/v1/chat/completions" \ |
| 98 | + -d '{ |
| 99 | + "model": "<model-name>", |
| 100 | + "messages": [{"role": "user", "content": "say hello"}], |
| 101 | + "max_tokens": 50 |
| 102 | + }' |
| 103 | +``` |
| 104 | + |
| 105 | +## Important Notes |
| 106 | + |
| 107 | +- **No date suffix**: Use `claude-opus-4-8`, not `claude-opus-4-8-20250527`. Vertex rejects date-suffixed model names. |
| 108 | +- **Location must be `global`**: Regional endpoints may not have all models available. |
| 109 | +- **OAuth2 is automatic**: The IPP `apikey-injection` plugin reads the service account JSON from the secret and generates short-lived OAuth2 tokens. No manual token management needed. |
| 110 | +- **`stream_options` stripped automatically**: The IPP `api-translation` plugin strips `stream_options` from requests to Vertex (Vertex rejects this field). |
| 111 | +- **Multi-provider routing**: You can add Vertex alongside other providers (Anthropic direct, OpenAI, simulator) on the same ExternalModel using weight-based routing. Set `weight: 0` to disable a provider without removing it. |
| 112 | + |
| 113 | +## Sharing Service Account Keys |
| 114 | + |
| 115 | +Use [Bitwarden Send](https://vault.bitwarden.com) to share JSON key files securely: |
| 116 | +- Set expiration to 48 hours |
| 117 | +- Set max access count to 1 |
| 118 | +- Delete after accessed |
| 119 | + |
| 120 | +Never paste service account keys in Slack or other messaging platforms. |
0 commit comments