Validate Google Vertex access - Barndoor Documentation
Validate Google Vertex access
cURL
curl --request POST \
--url https://app.barndoor.ai/api/llm-gateway/admin/connections/google-vertex-validate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '\n{
"project_id": "my-gcp-project",
"location": "us-central1",
"auth_type": "google_service_account",
"model_api_family": "vertex_gemini",
"target_service_account": "vertex-runner@my-gcp-project.iam.gserviceaccount.com",
"credentials": {},
"model": "gemini-1.5-pro"
}
'```
### Python
import requests
url = "https://app.barndoor.ai/api/llm-gateway/admin/connections/google-vertex-validate"
payload = {
"project_id": "my-gcp-project",
"location": "us-central1",
"auth_type": "google_service_account",
"model_api_family": "vertex_gemini",
"target_service_account": "vertex-runner@my-gcp-project.iam.gserviceaccount.com",
"credentials": {},
"model": "gemini-1.5-pro"
}
headers = {
"Authorization": "Bearer ",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
### JavaScript
const options = {
method: 'POST',
headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'},
body: JSON.stringify({
project_id: 'my-gcp-project',
location: 'us-central1',
auth_type: 'google_service_account',
model_api_family: 'vertex_gemini',
target_service_account: 'vertex-runner@my-gcp-project.iam.gserviceaccount.com',
credentials: {},
model: 'gemini-1.5-pro'
})
};
fetch('https://app.barndoor.ai/api/llm-gateway/admin/connections/google-vertex-validate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
### PHP
"https://app.barndoor.ai/api/llm-gateway/admin/connections/google-vertex-validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'project_id' => 'my-gcp-project',
'location' => 'us-central1',
'auth_type' => 'google_service_account',
'model_api_family' => 'vertex_gemini',
'target_service_account' => 'vertex-runner@my-gcp-project.iam.gserviceaccount.com',
'credentials' => [
],
'model' => 'gemini-1.5-pro'
]),\
CURLOPT_HTTPHEADER => [
"Authorization: Bearer ",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
}
```
### Go
```
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.barndoor.ai/api/llm-gateway/admin/connections/google-vertex-validate"
payload := strings.NewReader("{\n \"project_id\": \"my-gcp-project\",\n \"location\": \"us-central1\",\n \"auth_type\": \"google_service_account\",\n \"model_api_family\": \"vertex_gemini\",\n \"target_service_account\": \"vertex-runner@my-gcp-project.iam.gserviceaccount.com\",\n \"credentials\": {},\n \"model\": \"gemini-1.5-pro\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer ")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
```
### Java
```
HttpResponse response = Unirest.post("https://app.barndoor.ai/api/llm-gateway/admin/connections/google-vertex-validate")
.header("Authorization", "Bearer ")
.header("Content-Type", "application/json")
.body("{\n \"project_id\": \"my-gcp-project\",\n \"location\": \"us-central1\",\n \"auth_type\": \"google_service_account\",\n \"model_api_family\": \"vertex_gemini\",\n \"target_service_account\": \"vertex-runner@my-gcp-project.iam.gserviceaccount.com\",\n \"credentials\": {},\n \"model\": \"gemini-1.5-pro\"}")
.asString();
```
### Ruby
```
require 'uri'
require 'net/http'
url = URI("https://app.barndoor.ai/api/llm-gateway/admin/connections/google-vertex-validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer '
request["Content-Type"] = 'application/json'
request.body = "{\n \"project_id\": \"my-gcp-project\",\n \"location\": \"us-central1\",\n \"auth_type\": \"google_service_account\",\n \"model_api_family\": \"vertex_gemini\",\n \"target_service_account\": \"vertex-runner@my-gcp-project.iam.gserviceaccount.com\",\n \"credentials\": {},\n \"model\": \"gemini-1.5-pro\"}"
response = http.request(request)
puts response.read_body
```
### Response
- **200**: \n ```json
{
"ok": true
}
```
- **400**: \n ```json
{
"error": "BadRequest",
"message": "request_timeout_secs must be between 1 and 3600"
}
```
### Authorizations
#### Authorization
- **Type**: `string`
- **In**: `header`
- **Required**: `Yes`
- **Description**: JWT obtained through Barndoor's authentication flow. Pass the token verbatim in `Authorization: Bearer `. Use the Barndoor SDK's `loginInteractive()` helper to obtain a token in scripts and notebooks.
### Body
| Field | Type | Required | Example |
|-----------------------|------------|----------|-----------------------------------|
| project_id | string | Yes | "my-gcp-project" |
| location | string | Yes | "us-central1" |
| auth_type | string | No | "google_service_account" |
| model_api_family | enum | No | "vertex_gemini" |
| target_service_account | string | No | "vertex-runner@my-gcp-project.iam.gserviceaccount.com" |
| credentials | object | No | {} |
| model | string | No | "gemini-1.5-pro" |