Multimodal AI Gateway
Supports Gemini (Google Gen AI SDK; requests use /v1beta paths) and OpenAI / DeepSeek (OpenAI SDK; baseURL includes /v1). Set SDK baseUrl to https://<host>/g/<public-id> (do not append /v1beta). The model field in each request works like the official SDK; the gateway endpoint resolves it using console logical routes and model connections.
Platform API key
Requests must use a platform API key from the console (not your upstream Gemini/OpenAI key), sent as x-goog-api-key (Gemini) or Authorization: Bearer (OpenAI). The key must belong to the Gateway’s team. If the key was created bound to a Gateway, it may only call that Gateway’s /g/<public-id>/... paths. Unbound keys may call any Gateway in the same team (the public-id in the URL must still match). Binding the key to the target Gateway in API keys is recommended.
Create keys under API keys; configure upstream provider keys (model connections) on the Gateway detail page.
Prerequisites
- Public ID: the 10-character code after
/g/on the Gateway detail page → Gateway (upstream API keys required) - Platform API key: see API keys (bind to target Gateway when possible)
- Logical routes & model connections: configure in the Gateway console; the gateway resolves the request model at the endpoint (only one route stays enabled per Gateway when you save)
baseUrl = "https://ai-sass-7pymefszf-keyskulls-projects.vercel.app/g/<public-id>" # do not append /v1beta
Access protocols
Enable client entry points under Access protocols on the Gateway detail page. Disabled protocols return 403. All built-in protocols are enabled by default.
| Protocol id | Path (under /g/<public-id>/) | Client |
|---|---|---|
| gemini-v1beta | v1beta/** | Google Gen AI SDK (baseUrl without /v1beta) |
| openai-chat | v1/chat/completions | OpenAI SDK · Chat Completions (baseURL includes /v1) |
| openai-responses | v1/responses | OpenAI SDK · Responses API |
Gemini SDK also uses /upload/v1beta/... for uploads; no separate protocol toggle (shares baseUrl with Gemini).
JavaScript (@google/genai)
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({
apiKey: process.env.ENGRA_API_KEY!,
httpOptions: {
baseUrl: "https://ai-sass-7pymefszf-keyskulls-projects.vercel.app/g/<public-id>",
},
});
// model comes from the request, same as the official SDK
await ai.models.generateContent({
model: "your-model",
contents: "Hello",
});Python (google-genai)
import os
from google import genai
client = genai.Client(
api_key=os.environ["ENGRA_API_KEY"],
http_options={"base_url": "https://ai-sass-7pymefszf-keyskulls-projects.vercel.app/g/<public-id>"},
)
# model from request, same as the official SDK
client.models.generate_content(model="your-model", contents="Hello")OpenAI / DeepSeek
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ENGRA_API_KEY!,
baseURL: "https://ai-sass-7pymefszf-keyskulls-projects.vercel.app/g/<public-id>/v1",
});
await client.chat.completions.create({
model: "your-model", // model from request
messages: [{ role: "user", content: "Hello" }],
});Requires openai-chat. Configure model connections on the Gateway for Gemini, OpenAI, DeepSeek, and more.
curl example (Gemini generateContent)
Replace YOUR_PLATFORM_KEY and public-id with values from the console.
curl "https://ai-sass-7pymefszf-keyskulls-projects.vercel.app/g/<public-id>/v1beta/models/your-model:generateContent" \
-H "x-goog-api-key: YOUR_PLATFORM_KEY" \
-H "Content-Type: application/json" \
-d '{"contents":[{"parts":[{"text":"Hello"}]}]}'Common errors
| HTTP | Typical cause |
|---|---|
| 401 | Invalid or missing platform API key (Gemini: x-goog-api-key; OpenAI: Authorization header) |
| 403 | Access protocol disabled (e.g. gemini-v1beta, openai-chat) |
| 404 | Invalid public_id or Gateway not enabled |
| 503 | No upstream API key configured under model connections |
Configure logical routes
Configure logical routes, model connections, IF/ELSE conditions (input format or headers/metadata), fallback chains, prompt templates, temperature/JSON/embedding dimensions, etc. Clients pass model in each request as with the upstream SDK; the gateway endpoint resolves it.