Skip to navigation

Gemini clients

Meadow serves Google’s own Gemini API shape: generateContent and streamGenerateContent. Point gemini-cli or a Google GenAI SDK at Meadow, give it a Meadow key, and your stored google or vertex key serves the call. The request and the response stay in Google’s format. Meadow converts nothing between this format and the other three.

Next step: store a google key (Provider keys), then run the curl call below.

Not on the hosted beta yet. This route arrives with the hosted beta’s next update. On 2026-11-28 it was run against Google AI Studio from a local server built from the same code: blocking, streamed, on a key with a dollar limit, and from gemini-cli. It was not run against Vertex.

Paths

PathGoogle method
POST /v1beta/models/{model}:generateContentmodels.generateContent
POST /v1beta/models/{model}:streamGenerateContent?alt=ssemodels.streamGenerateContent
POST /v1/models/{model}:generateContentthe same, API version v1
POST /v1/models/{model}:streamGenerateContent?alt=ssethe same, API version v1

The Google GenAI SDKs call v1 unless you set another API version. Google’s own REST examples use v1beta. Meadow calls Google AI Studio with the version you used, and Vertex with v1. Google’s v1 answered 404 for gemini-3-flash-preview, which v1beta served, so use v1beta for preview models.

The stream needs ?alt=sse, which the SDKs and gemini-cli send. Without it Meadow answers 400.

Your key

Send your Meadow key in a header. These two are the recommended forms:

  • the x-goog-api-key header, where gemini-cli and the GenAI SDKs send it;
  • Authorization: Bearer <key>.

Meadow also accepts the key query parameter, because Google’s REST examples use it. Avoid it: query strings end up in proxy, browser and server logs, including logs Meadow does not control. Meadow removes the key from the query before it logs anything, records usage or calls the vendor, and no answer repeats the request URL.

If you send the key in more than one place, every copy must be the same key. An empty x-goog-api-key counts as no key.

The vendor gets your stored key, never your Meadow key: the google key in x-goog-api-key, or a token made from the vertex service account. If a vendor’s error names that stored key or token, in an error body or in a stream’s error event, Meadow replaces it with [REDACTED].

Model ids

{model} is a Meadow model id, as on the other routes:

  • gemini-3.8-flash, or any Gemini id from GET /v1/models, goes to google first and then vertex, when you have both keys;
  • google/gemini-3.8-flash pins Google AI Studio;
  • vertex/gemini-3.8-flash pins Vertex, which Meadow calls at publishers/google/models/gemini-3.8-flash.

GET /v1/models lists generate_content in formats for every provider that serves this route. Claude, GPT and Grok models have no provider for this format and get a 400.

curl

curl -sS "$MEADOW_BASE_URL/v1beta/models/gemini-3.8-flash:generateContent" \
-H "x-goog-api-key: $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents":[{"role":"user","parts":[{"text":"Say hello in five words."}]}],
"generationConfig":{"maxOutputTokens":32}}'

The answer is Google’s GenerateContentResponse as Google sent it, with the x-meadow-provider, x-meadow-model and x-meadow-attempts headers added.

gemini-cli

gemini-cli reads GOOGLE_GEMINI_BASE_URL and sends its key in x-goog-api-key. With that variable set, gemini-cli 0.71.1 chooses an auth type it then refuses (“Invalid auth method selected.”), so also select the API key type in ~/.gemini/settings.json:

{"security": {"auth": {"selectedType": "gemini-api-key"}}}
export GOOGLE_GEMINI_BASE_URL="$MEADOW_BASE_URL"
export GEMINI_API_KEY="$MEADOW_API_KEY"
gemini -m gemini-3-flash-preview -p "Reply with the single word: ok"
ok

That run, against a local server, made one streamed v1beta call. Its system prompt made it 8,414 input tokens. It cost 0.00421 USD at Google’s list price.

Google GenAI SDK

Python:

import os
from google import genai
from google.genai import types
client = genai.Client(
api_key=os.environ["MEADOW_API_KEY"],
http_options=types.HttpOptions(base_url=os.environ["MEADOW_BASE_URL"]),
)
reply = client.models.generate_content(
model="gemini-3.8-flash",
contents="Say hello in five words.",
config=types.GenerateContentConfig(max_output_tokens=32),
)
print(reply.text)

Use the SDK in Gemini API mode. Vertex mode (vertexai=True) calls other paths, which Meadow does not serve. To reach Vertex, keep Gemini API mode and pin vertex/<model>.

Limits and spend

The route goes through the same checks as the other model routes:

  • allowed_models and allowed_providers apply to {model} and the providers that could serve it.
  • A key with a token limit or a dollar limit needs generationConfig.maxOutputTokens. Meadow estimates a call as its body size divided by 3, plus maxOutputTokens times candidateCount.
  • A dollar limit, or a budget with hard_limit, refuses a call that Meadow cannot price before it is sent, with 403 key_spend_price_unknown. Meadow has no Vertex prices, so in a project with both keys, pin google/<model> on such a key.
  • Project routing applies. The body is Google’s, so this route does not read Meadow’s request fields models and provider.

Usage and cost

Usage records show format generate_content. Meadow reads usageMetadata:

Google fieldMeadow field
promptTokenCount + toolUsePromptTokenCountinput tokens
cachedContentTokenCountcache read tokens, priced at the cache read rate
candidatesTokenCount + thoughtsTokenCountoutput tokens
thoughtsTokenCountreasoning tokens
serviceTier, or Vertex trafficTypeservice tier
modelVersionserved model

Google bills thinking tokens as output. On a stream the counts add up, and Meadow keeps the last chunk’s.

A live call to gemini-3-flash-preview with maxOutputTokens 64 and a short arithmetic prompt came back with finishReason MAX_TOKENS and this usage:

{"promptTokenCount":33,"candidatesTokenCount":2,"totalTokenCount":93,"thoughtsTokenCount":58,"serviceTier":"standard"}

Its usage record read 33 input tokens, 60 output tokens (2 + 58), 58 reasoning tokens, cost_status price_table and cost 0.0001965 USD. The thinking stayed inside maxOutputTokens, so the reservation Meadow held for a key with a dollar limit (133 tokens at the model’s highest rate) covered the charge. That is one model on one day. Google’s reference does not promise it for every model. A call that used Google Search or Maps grounding, or carried audio, is stored with no cost and a reason, because Meadow has no price for it. A Vertex call is stored with its tokens and no cost (provider_not_priced).

Errors

A Google error is passed through with Google’s status and body. An error Meadow makes on this route is in Google’s envelope:

{"error":{"code":403,"message":"model \"gemini-3.8-flash\" is not in this api key's allowed_models","status":"PERMISSION_DENIED","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"KEY_MODEL_ACCESS_DENIED","domain":"api.usemeadow.ai","metadata":{"code":"key_model_access_denied","param":"model","request_id":"req_0000aa38","type":"forbidden"}}]}}

code is the HTTP status and status its Google name. reason is Meadow’s error code in upper case, and metadata.code holds it as written in Errors. The list of attempts is not in this envelope. Read x-meadow-route for where the call went.

Not served

Meadow answers these in Google’s error envelope and never passes them to a vendor:

PathAnswer
POST /v1beta/models/{model}:countTokens, :embedContent, :batchEmbedContents, :batchGenerateContent (and the same under /v1)501 UNIMPLEMENTED, code not_implemented
Another method on /v1beta/models/{model}: or /v1/models/{model}:404 NOT_FOUND, code route_not_found
File upload (/upload/v1beta/files) and files (/v1beta/files)404 NOT_FOUND, code route_not_found
Cached contents (/v1beta/cachedContents) and batches (/v1beta/batches)404 NOT_FOUND, code route_not_found
The Live API over WebSocket (/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent and its v1alpha forms)404 NOT_FOUND, code route_not_found

Tuned models and the Interactions API are not served either. Google’s model list is not served: GET /v1beta/models gets a 404, and GET /v1/models answers with Meadow’s own list in OpenAI’s shape, which a Gemini client cannot read. Call Google directly for these. See Known limits.

API reference

Operations on this page: generateContent, streamGenerateContent.