Cloud
Google Vertex AI
Gemini and partner models on Google Cloud.
Quick start
import polygate response = polygate.chat( provider="vertex", base_url="...", model="google/gemini-2.0-flash", messages=[{"role": "user", "content": "Say hi in one word."}],) print(response.content) # "Hi!"print(response.usage) # Usage(prompt_tokens=..., completion_tokens=...)Names
Any of these work as provider. They all reach the same adapter, so pick whichever reads best in your code.
vertexvertexaiConfiguration
| Variable | Holds |
|---|---|
| GOOGLE_ACCESS_TOKEN | your API key |
| VERTEX_BASE_URL | the OpenAI-compatible endpoint for your project and region |
Any of these may hold a comma-separated list. polygate rotates across them, parks a rate-limited one for its Retry-After, and drops one the provider rejects — so a key pool is configuration, not code.
Endpoint
There is no fixed host: the URL contains your own account, workspace or project, so base_url is required. Omit it and polygate raises MissingEndpointError naming the variable to set, rather than letting the request fail somewhere less informative.
Models
Examples that work today. Model names change; the provider's own list is the authority.
google/gemini-2.0-flashgoogle/gemini-2.5-proThings worth knowing
- The credential is a short-lived OAuth access token, not an API key. Vertex issues no long-lived keys. Get one with
gcloud auth print-access-token; it expires in about an hour, so a token pasted into an environment variable will start returning 401 rather than continuing to work. - Minting tokens is deliberately out of scope. Doing it properly means service-account JWT signing and a refresh cycle, which would put a crypto dependency in a package whose premise is that it has almost none.
- The endpoint names your region twice.
vertex.endpoint(project, region)builds it correctly — a mismatch between the two produces a 404 that names nothing.
Building the endpoint
import subprocessimport polygatefrom polygate.providers import vertex token = subprocess.check_output( ["gcloud", "auth", "print-access-token"], text=True).strip() response = polygate.chat( provider="vertex", api_key=token, base_url=vertex.endpoint("my-project", "europe-west4"), model="google/gemini-2.0-flash", messages=[{"role": "user", "content": "Hello"}],)Batch
Google Vertex AI has no offline batch API. To run many requests at once, use map_chat — full price, but it works everywhere and returns in seconds. See Batching & concurrency.