Google Gemini API Key Set Up for AI/Machine Learning Tools
This article describes how to connect your own Google Gemini account to LegalServer to enable LegalServer's artificial intelligence (AI) features.
Some features in LegalServer use AI, and this requires an account with an AI provider. This "Bring Your Own Key" (BYOK) model gives you full control over your billing and usage. This guide will walk you through generating a Google API key and connecting it to LegalServer.
Prerequisites
Before you begin, you must have the following:
- A Google Account.
- A Google Cloud Platform (GCP) account. You can create one at .
- A GCP Project created within your account.
- An active Billing Account linked to your GCP Project. Generating API keys and using the models is not free.
- An add-on subscription to LegalServer's AI / Machine Learning Tools
Supported Features
Subscribing to LegalServer's AI / Machine Language tools and connecting a Gemini API key can enable features such as:
Process Overview (At-a-Glance)
- Enable the API: In your GCP project, you will enable the "Generative Language API."
- Create the API Key: You will generate a new, secure API key.
- Restrict the API Key: You will add security restrictions so the key can only be used for the Generative Language API.
- Configure LegalServer: You will copy the new key into the LegalServer admin settings.
Detailed Gemini API Key Setup Instructions
Step 1: Enable the Generative Language API
Your GCP project needs permission to use the Gemini models.
- Go to the Google Cloud Console API Library:
- Ensure the correct GCP Project is selected in the top navigation bar.
- In the search bar, type "Generative Language API".
- Click on the result and then click the Enable button.
Step 2: Create and Restrict Your API Key
There are two ways to create the key. We recommend Method 1 for better security and management.
Method 1: Google Cloud Platform (Recommended)
This method gives you full control over the key's security settings.
- In the Google Cloud Console, navigate to APIs & Services > Credentials (or go to ).
- Click + Create Credentials at the top of the page and select API key.
- A new key will be generated. Immediately copy this key and store it in a secure place (like a password manager). You will need it for Step 3.
- Close the "API key created" dialog.
- Find your new API key in the list. Click the overflow menu (three vertical dots) on the right and select Edit API key.
- Change the Name to something descriptive, like "LegalServer Gemini Key".
- Under API restrictions, select Restrict key.
- In the "Select APIs" dropdown, find and select Generative Language API.
- Click OK and then click Save.
Your key is now created and restricted.
Method 2: Google AI Studio
This is a simpler interface that connects to your GCP billing account.
- Go to Google AI Studio:
- If prompted, connect AI Studio to your existing GCP Project that has billing enabled.
- Click Create API key in new project.
- A new key will be generated. Copy this key and store it in a secure place.
Note: We still recommend logging into the to apply the API restrictions described in Method 1 (Step 6-9) for enhanced security.
Step 3: Configure LegalServer
The final step is to add your new API key to LegalServer.
- Log in to your LegalServer site as an Administrator.
- Navigate to the Admin > AI & Machine Learning settings page.
- Find the Engine Selection setting and choose Gemini as your preferred "OCR & AI LLM."
- Find the API Key Input field (this may be on the document settings or a main AI page) and paste your newly created Google API key.
- Save the settings.
Important Considerations
- Security: Your API key is a secret. Never share it publicly, commit it to code repositories, or expose it in client-side code. Always restrict your key as shown in Step 2.
- Pricing: You are responsible for all costs associated with your API key.
- HIPAA and Data Usage: Google's data usage and compliance terms apply. For more information, please review Google's policies.
- Vertex AI Support: LegalServer integrates with the Gemini models via the Generative Language API. The platform does not yet support integration with Google's Vertex AI platform.