API template library

Google Gemini mock API and live sandbox

A WireMock simulation of Google Gemini's REST API — covering content generation, embeddings, files, cached contents, semantic retrieval, and tuned models.

Vendor
Google Gemini
Functionality
Generation, files, semantic retrieval
Spec version
v1beta
Endpoints
49
Stubs
57
Protocol
REST
Validation
AI-validated Before publication, an AI agent exercised these endpoints against the real Google Gemini API through WireMock's recording proxy, and the recorded traffic was used to verify each stub's request and response shapes.

Live sandbox · no signup, no API key

Google Gemini API

A running WireMock Cloud instance of this template, callable right now from a terminal, a script, or an AI agent.

Base URL
https://8131q.wiremockapi.cloud

POST Generate Content with Tuned Model

curl -s -X POST 'https://8131q.wiremockapi.cloud/v1beta/tunedModels/your-tunedModelId:generateContent' \
  -H 'Content-Type: application/json' \
  -d '{}'

POST Generate Text with Tuned Model

curl -s -X POST 'https://8131q.wiremockapi.cloud/v1beta/tunedModels/your-tunedModelId:generateText' \
  -H 'Content-Type: application/json' \
  -d '{}'

POST Transfer Tuned Model Ownership

curl -s -X POST 'https://8131q.wiremockapi.cloud/v1beta/tunedModels/your-tunedModelId:transferOwnership' \
  -H 'Content-Type: application/json' \
  -d '{}'
Method Path Summary
GET /v1beta/cachedContents List cached contents
POST /v1beta/cachedContents Create cached content
DELETE /v1beta/cachedContents/{cachedContentId} Delete cached content
GET /v1beta/cachedContents/{cachedContentId} Get cached content
PATCH /v1beta/cachedContents/{cachedContentId} Update cached content
GET /v1beta/corpora List corpora
POST /v1beta/corpora Create corpus
DELETE /v1beta/corpora/{corpusId} Delete corpus
GET /v1beta/corpora/{corpusId} Get corpus
GET /v1beta/corpora/{corpusId}/permissions List corpus permissions
POST /v1beta/corpora/{corpusId}/permissions Create corpus permission
DELETE /v1beta/corpora/{corpusId}/permissions/{permissionId} Delete corpus permission
GET /v1beta/corpora/{corpusId}/permissions/{permissionId} Get corpus permission
PATCH /v1beta/corpora/{corpusId}/permissions/{permissionId} Update corpus permission
GET /v1beta/files List files
POST /v1beta/files Upload a file
DELETE /v1beta/files/{fileId} Delete file
GET /v1beta/files/{fileId} Get file
GET /v1beta/fileSearchStores List file search stores
POST /v1beta/fileSearchStores Create file search store
DELETE /v1beta/fileSearchStores/{fileSearchStoreId} Delete file search store
GET /v1beta/fileSearchStores/{fileSearchStoreId} Get file search store
GET /v1beta/models List models
GET /v1beta/models/{model} Get model
POST /v1beta/models/{model}:batchEmbedContents Batch embed contents
POST /v1beta/models/{model}:batchEmbedText Batch embed text (PaLM)
POST /v1beta/models/{model}:countMessageTokens Count message tokens (PaLM)
POST /v1beta/models/{model}:countTextTokens Count text tokens (PaLM)
POST /v1beta/models/{model}:countTokens Count tokens
POST /v1beta/models/{model}:embedContent Embed content
POST /v1beta/models/{model}:embedText Embed text (PaLM)
POST /v1beta/models/{model}:generateAnswer Generate grounded answer
POST /v1beta/models/{model}:generateContent Generate content
POST /v1beta/models/{model}:generateMessage Generate message (PaLM)
POST /v1beta/models/{model}:generateText Generate text (PaLM)
POST /v1beta/models/{model}:streamGenerateContent Stream generate content
GET /v1beta/tunedModels List tuned models
POST /v1beta/tunedModels Create tuned model
DELETE /v1beta/tunedModels/{tunedModelId} Delete tuned model
GET /v1beta/tunedModels/{tunedModelId} Get tuned model
PATCH /v1beta/tunedModels/{tunedModelId} Update tuned model
POST /v1beta/tunedModels/{tunedModelId}:generateContent Generate content with tuned model
POST /v1beta/tunedModels/{tunedModelId}:generateText Generate text with tuned model (PaLM)
POST /v1beta/tunedModels/{tunedModelId}:transferOwnership Transfer tuned model ownership
GET /v1beta/tunedModels/{tunedModelId}/permissions List tuned model permissions
POST /v1beta/tunedModels/{tunedModelId}/permissions Create tuned model permission
DELETE /v1beta/tunedModels/{tunedModelId}/permissions/{permissionId} Delete tuned model permission
GET /v1beta/tunedModels/{tunedModelId}/permissions/{permissionId} Get tuned model permission
PATCH /v1beta/tunedModels/{tunedModelId}/permissions/{permissionId} Update tuned model permission

Unauthenticated WireMock Cloud demo sandbox for Google Gemini — not an official Google Gemini sandbox, and it returns simulated example data only.

What's inside the Google Gemini template

Generated from the v1beta Gemini API description, the template answers models/{model}:generateContent the way the real service does — a candidates array whose content carries the reply parts, per-candidate safety ratings, and a usageMetadata block counting prompt and candidate tokens. Code that unwraps real Gemini responses, including the google-genai SDK's own parsing, runs against it unchanged.

  • Content generation — generateContent and its streaming counterpart, for base and tuned models
  • Embeddings — embedContent plus batch variants for both content and plain text
  • Model catalog — list and fetch operations over the available Gemini models
  • Files — upload, list, fetch, and delete
  • Context caching — the cachedContents lifecycle for reusing long prompts
  • Semantic retrieval — corpora, their permissions, and grounded generateAnswer
  • Tuned models — creation, updates, permissions, and ownership transfer
  • PaLM compatibility — the legacy generateText, generateMessage, and embedText routes

Example implementation using the google-genai SDK

Google's google-genai SDK routes every call through an http_options base URL, so one constructor field moves a client from the live service to the mock:

Frameworks that wrap the SDK — agent runtimes, LangChain-style toolchains — usually surface that same base-URL setting, so they can be aimed at the sandbox, or at your own copy of the mock, without forking any code.

A fixed Gemini backend turns flaky problems into solved ones: CI that needs no Google credentials, prompt-pipeline tests that can assert on exact output, and cost-free load on the request path while you profile your own service.

from google import genai
from google.genai.types import HttpOptions

# any api_key satisfies the client —
# the mock ignores it
client = genai.Client(
    api_key="any-value",
    http_options=HttpOptions(base_url="https://8131q.wiremockapi.cloud"),
)

reply = client.models.generate_content(
    model="gemini-2.0-flash",
    contents="Explain how AI works",
)
print(reply.text)

Frequently asked questions

Gemini clients send the key as a query parameter or an x-goog-api-key header; the mock accepts anything in either place and inspects neither. A genuine Google Cloud key should still stay out of the picture — the sandbox is public infrastructure with no auth in front of it.

The route exists, but it answers with a single JSON body instead of chunked partial candidates. Verify request wiring against it, and move to a private WireMock Cloud instance if your assertions depend on genuine chunk-by-chunk delivery.

The v1beta surface Google publishes still defines the legacy generateText, generateMessage, and embedText operations, so the template stubs them too — useful when you're migrating an older PaLM integration and want both API generations answering side by side.

Not from the shared instance, which sticks to successful generations. Recreate the template under your own account and stub the failure shapes you need — a candidate with finishReason SAFETY, or a 429 carrying RESOURCE_EXHAUSTED — and drive your fallback logic through them deterministically.

Vendor names identify APIs represented by WireMock template sources. This page does not imply vendor endorsement, certification, partnership, or official integration status.