This repository provides a guide to set up and use Google Cloud's Vertex AI in a C# project. Follow the steps below to configure your environment and integrate Vertex AI functionality.
Before you begin, ensure you have the following:
- Google Cloud Account: An active Google Cloud account is required.
- Project: Create a project in the Google Cloud Console (e.g.,
ocrai-selfbill
). - Billing: Enable billing for your Google Cloud project.
- Visual Studio: Install any recent version (e.g., 2019 or 2022) with the .NET workload.
- Navigate to the Google Cloud Console.
- Select your project (e.g.,
ocrai-selfbill
). - Go to APIs & Services > Library.
- Search for Vertex AI API.
- Click Enable to activate the API for your project.
Vertex AI requires authentication via a service account. Follow these steps:
- In the Google Cloud Console, go to IAM & Admin > Service Accounts.
- Click Create Service Account.
- Name it (e.g.,
vertex-ai-service-account
). - Grant it the Vertex AI User role (or a custom role with appropriate permissions).
- Click Create and Continue, then Done.
- From the Service Accounts list, click on your new service account.
- Go to the Keys tab, then click Add Key > Create New Key.
- Select JSON as the key type and download the file (e.g.,
ocrai-selfbill-123456789.json
).
-
Place the JSON key file in a secure location on your machine.
-
Set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable to point to this file:Windows:
set GOOGLE_APPLICATION_CREDENTIALS=C:\path\to\your\service-account-key.json