Skip to content
PALM SOUQ

Model provider

Google Gemini and Vertex AI logoPALM SOUQ for Google Gemini and Vertex AI

Govern Gemini traffic from the Gemini API or Vertex AI with one base URL change. PALM SOUQ meters cached content tokens and thinking tokens, and handles the long-context price bands Gemini models use.

One base URL change · tenant headers · <5 ms added
google-gemini · setup
import os
from google import genai
from google.genai import types

client = genai.Client(
    api_key=os.environ["GEMINI_API_KEY"],
    http_options=types.HttpOptions(
        base_url="https://gateway.palmsouqltd.com/gemini",
        headers={
            "X-PalmSouq-Key": os.environ["PALMSOUQ_KEY"],
            "X-PalmSouq-Tenant": tenant.id,
            "X-PalmSouq-Tier": tenant.plan,
        },
    ),
)

resp = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Classify this support ticket by urgency.",
)

Two Google surfaces, one policy

Google sells Gemini models through two front doors: the Gemini API with an API key, and Vertex AI inside a Google Cloud project with IAM credentials. PALM SOUQ supports both at gateway.palmsouqltd.com/gemini and gateway.palmsouqltd.com/vertex. Quotas, breakers and fallback chains are written once against the model name and apply whichever door the request uses.

With the google-genai SDK you set http_options with the gateway base URL and headers. For Vertex AI the gateway forwards your OAuth access token unchanged, so service account permissions and VPC Service Controls on the Google side keep working as they do today.

Metering context caching and thinking

Gemini reports usage in usageMetadata: promptTokenCount, candidatesTokenCount, cachedContentTokenCount and thoughtsTokenCount. PALM SOUQ prices cached content at the cached rate, prices thinking tokens as output (which is how Google bills them) and shows them as a separate line so a tenant whose prompts trigger long reasoning is visible before the month closes.

Several Gemini models charge a higher rate above a prompt length threshold. The gateway checks the prompt token count on each call and applies the correct band, so a tenant that pastes whole document sets into one prompt is priced at the long-context rate, not the headline rate in a pricing table.

Where Gemini fits in a fallback chain

Gemini 2.5 Flash and Flash-Lite are among the cheapest capable models in the PALM SOUQ price index, which makes them natural fallback targets. A common policy downgrades a tenant from Gemini 2.5 Pro to 2.5 Flash at 90% of monthly budget, and to Flash-Lite at 100% for read-only features, before returning a hard 429.

Explicit context caches on Gemini also carry a storage charge per hour. PALM SOUQ records cache creation calls with the tenant that created them, so storage cost is attributed to the customer whose document set is being kept warm.

Rolling it out safely

If you use both the Gemini API and Vertex AI, connect one surface first and keep the other direct for a few days. Compare the token counts PALM SOUQ records with the usage reported in Google AI Studio or Cloud Billing for the same window, paying particular attention to thinking tokens on 2.5 Pro and Flash, which are easy to miss in a summary view.

When both surfaces are routed, write your fallback chain once and check the audit log to confirm downgrades fire on the model you expect, whichever door the request came through.

Govern Google Gemini and Vertex AI usage per tenant, starting today.

Route your agent traffic through PALM SOUQ in 2 minutes. Change one base URL, pass a tenant header, and every token is attributed and governed.

14-day free production trial · 100k requests included · no card required