Vertex AI
How to use GATE/0 with Google Vertex AI
GATE/0 is fully compatible with Google Vertex AI models, making integration seamless. Simply point your existing OpenAI client to GATE/0’s endpoint — no code changes required. You can enrich requests with custom labels to enable detailed tracking, cost allocation, and forecasting.
Whether you're using openai.ChatCompletion.create()
or other endpoints, GATE/0 acts as a transparent proxy, preserving all functionality while adding powerful analytics and observability.
Set up your Google AI provider in GATE/0
Install OpenAI SDK
pip install openai
npm install openai
Configure the GATE/0 API key Set your GATE/0 API key as an environment variable:
export GATE0_API_KEY=your-gate0-api-key
Start using OpenAI SDK
import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: "https://gateway.gate.io/v1", // GATE0 cloud proxy URL
apiKey: process.env.GATE0_API_KEY, // API key provided by GATE0
});
const chatCompletion = await openai.chat.completions.create({
model: "vertexai/gemini-2.0-flash", // Model name with provider prefix
messages: [{ role: 'user', content: "Hello, how are you?" }],
metadata: { // Custom labels
"project":"alpha",
"client":"frontend",
"env":"prod"
}
});
console.log(chatCompletion.choices);
from openai import OpenAI
import os
client = OpenAI(
base_url="https://gateway.gate.io/v1", # GATE0 cloud proxy URL
api_key=os.environ.get("GATE0_API_KEY"), # API key provided by GATE0
)
completion = client.chat.completions.create(
model="vertexai/gemini-2.0-flash", # Model name with provider prefix
messages=[
{"role": "user", "content": "Hello, how are you?"}
],
extra_body={
"metadata": { # Custom labels
"project":"alpha",
"client":"frontend",
"env":"prod"
}
}
)
print(completion.choices[0].message)
Explanation of the implementation
- An instance of
OpenAI
is created with the base URL set tohttps://gateway.gate0.io/v1
, using your GATE0 API key instead of the default OpenAI key. - A prefixed model name
vertexai/gemini-2.0-flash
is used. - Custom labels are included to allocate and track costs more effectively.