Skip to content

Commit ff5a22f

Browse files
authored
Merge pull request #30 from navapbc/fg/vertexai-logging
docs: add BigQuery logging setup for Vertex AI Anthropic models
2 parents 42f71e2 + 1b3f52c commit ff5a22f

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

mastra-test-app/docs/VERTEX_AI_ANTHROPIC_SETUP.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,67 @@ Replace `YOUR-PROJECT-ID` with your actual Google Cloud project ID.
140140

141141
**Quota errors**: Request quota increases in the [Cloud Console](https://console.cloud.google.com/iam-admin/quotas).
142142

143+
## Step 8: Enable BigQuery Logging (Optional)
144+
145+
To log requests and responses to BigQuery for monitoring and analysis:
146+
147+
### Create BigQuery Dataset and Table
148+
149+
```bash
150+
# Create dataset
151+
bq mk --location=US YOUR-PROJECT-ID:anthropic_logging
152+
153+
# The table will be auto-created when logging starts
154+
```
155+
156+
### Enable Logging via REST API
157+
158+
Create a request configuration file:
159+
160+
```json
161+
{
162+
"publisherModelConfig": {
163+
"loggingConfig": {
164+
"enabled": true,
165+
"samplingRate": 1.0,
166+
"bigqueryDestination": {
167+
"outputUri": "bq://YOUR-PROJECT-ID.anthropic_logging.request_response_logging"
168+
},
169+
"enableOtelLogging": true
170+
}
171+
}
172+
}
173+
```
174+
175+
Enable logging for Claude Sonnet 4:
176+
177+
```bash
178+
# Save the JSON above to logging-config-request.json, then run:
179+
curl -X POST \
180+
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
181+
-H "Content-Type: application/json; charset=utf-8" \
182+
-d @logging-config-request.json \
183+
"https://us-east5-aiplatform.googleapis.com/v1beta1/projects/YOUR-PROJECT-ID/locations/us-east5/publishers/anthropic/models/claude-sonnet-4:setPublisherModelConfig"
184+
```
185+
186+
### Verify Logging Configuration
187+
188+
```bash
189+
curl -X GET \
190+
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
191+
"https://us-east5-aiplatform.googleapis.com/v1beta1/projects/YOUR-PROJECT-ID/locations/us-east5/publishers/anthropic/models/claude-sonnet-4:fetchPublisherModelConfig"
192+
```
193+
194+
### Notes
195+
196+
- Logs may take a few minutes to appear in BigQuery
197+
- Sampling rate of 1.0 logs 100% of requests
198+
- The table schema includes fields like `full_request`, `full_response`, `logging_time`, etc.
199+
- No code changes needed - your existing `vertexAnthropic('claude-sonnet-4')` calls will automatically be logged
200+
143201
## Helpful Resources
144202

145203
- [Vertex AI Documentation](https://cloud.google.com/vertex-ai/docs)
146204
- [Anthropic Claude Code Vertex AI Guide](https://docs.anthropic.com/en/docs/claude-code/google-vertex-ai)
147205
- [AI SDK Google Vertex Documentation](https://sdk.vercel.ai/providers/ai-sdk-providers/google-vertex)
206+
- [Vertex AI Request-Response Logging](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/request-response-logging)

0 commit comments

Comments
 (0)