Skip to navigation

Generate content (Gemini generateContent format)

Use this when your client speaks Google’s Gemini API: gemini-cli, or a Google GenAI SDK with a custom base URL. Set the base URL to MEADOW_BASE_URL and the API key to a Meadow key. Send the key in x-goog-api-key, where the Gemini clients send it, or in Authorization: Bearer. Meadow also reads the key query parameter, but avoid it: query strings end up in proxy, browser and server logs. Meadow drops the key before it logs, records or calls the vendor, and no answer repeats the request URL.

The same two methods are served under /v1, the default API version of the Google GenAI SDKs: POST /v1/models/{model}:generateContent and POST /v1/models/{model}:streamGenerateContent. Meadow calls Google AI Studio with the version you used. It calls Vertex on v1.

{model} is a Meadow model id. A catalog id such as gemini-3.8-flash routes to google, then vertex. google/<id> pins Google AI Studio and vertex/<id> pins Vertex. Claude, GPT and Grok models are not served in this format.

The body is Google’s GenerateContentRequest and goes to the vendor unchanged. The response is Google’s GenerateContentResponse, unchanged. Meadow converts nothing between this format and the other three. It reads usageMetadata to record tokens and cost, and generationConfig.maxOutputTokens and candidateCount to estimate a call. A key with a token limit or a dollar limit needs generationConfig.maxOutputTokens. Meadow’s own models and provider fields are not read on this route: project routing applies.

Meadow’s own errors on this route use Google’s envelope, {"error": {"code", "message", "status", "details"}}, with Meadow’s error code as the reason of an ErrorInfo detail. A vendor error is passed through as the vendor sent it.

countTokens, embedContent, batchEmbedContents and batchGenerateContent answer 501 in Google’s envelope. File upload, files, cached contents, batches and the Live API WebSocket paths answer 404 in Google’s envelope. None reaches a vendor. Google’s model list is not served.

Scope: models.

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":"Reply with the single word: meadow"}]}],
"generationConfig":{"maxOutputTokens":16}}'

Authentication

AuthorizationBearer

A Meadow API key, sent as Authorization: Bearer mdw_.... The header x-api-key: mdw_... is accepted in its place.

Path parameters

modelstringRequired

A Meadow model id, for example gemini-3.8-flash, google/gemini-3.8-flash or vertex/gemini-3.8-flash.

Request

A Google GenerateContentRequest, passed to the vendor unchanged. At most 16 MiB.

Response headers

x-meadow-providerstringOptional

The provider that answered, for example anthropic. Present on a 200 and on a vendor error that was passed through.

x-meadow-modelstringOptional
The vendor's own id for the model that answered.
x-meadow-attemptsintegerOptional
The number of vendors tried, including the one that answered. A value above 1 means a fallback happened.
x-meadow-routestringOptional

Why this vendor answered, in stable codes only. direct: <vendor> when the first vendor in the route served the call. fallback: <vendor> <reason> -> <vendor> when an earlier vendor failed, with the same reason codes as attempts[].reason in an error body. failed: ... on a vendor error passed through. It never carries vendor error text.

x-meadow-provider-auth-failedstringOptional

Comma-separated providers that rejected your stored credential during this request (HTTP 401 or 403, or a failed token exchange). Absent when none did. Replace the provider key for each one named.

x-meadow-abandoned-attemptsstringOptional

Comma-separated providers that received the request and may bill for it, but whose response was not used (a timeout or broken connection after the request was sent, or an unusable 200 body). Absent when there are none.

x-request-idstringOptional

Meadow’s id for this request, req_ and 24 hex characters. Every response carries it, including errors, streams and unknown routes. Every error in the Error schema repeats it as request_id. Quote it when you report a problem.

x-meadow-provider-request-idstringOptional

The request id of the vendor that answered, taken from its x-request-id, request-id, x-amzn-requestid, apim-request-id or x-generation-id header, the first one present in that order. Use it with that vendor’s support. Vendors tried before a fallback are not listed. Absent when the vendor sent none.

Response

The vendor’s GenerateContentResponse, unchanged. Usage is in usageMetadata.

Errors

400
Bad Request Error