Skip to main content
Use your Hopscotch API key and a vertex-ai/ model id from the model catalog. The examples below use the customer API and your workspace’s normal credit balance.

How to

Check the model and its parameters

Read GET /v1/models for the ids available to your key, then look up the exact id:
Check the detail’s supported endpoints and current prices before choosing an example. uniblock.parameters contains parameter bounds and defaults where recorded. uniblock.supported_parameters contains published parameter names, with known refusals removed. An empty list means no publishable declaration is available; it does not establish that every parameter is unsupported. A listed parameter is not proof that every value works on every endpoint. See Request parameters. For Gemini 3.8 Flash, use reasoning_effort: "low", "medium" or "high" when choosing a thinking level. Google does not support temperature, top_p, top_k, candidate count or frequency and presence penalties on this model. Leave those controls out, including defaults your client adds automatically. The Google model guide describes these restrictions.

Send a text request

curl
Read text from choices[0].message.content. Preserve x-hopscotch-request-id from the response headers for usage lookup. A successful HTTP status alone does not establish that the model produced the text or image your application needs; inspect the output and finish reason.

Stream the response

Send the same body with stream: true and stream_options: {"include_usage": true}. Read text from each choices[].delta.content, retain the final usage frame, and consume the stream through data: [DONE]. A stream can report an error after its HTTP headers have arrived. See Streaming for the event format and error handling.

Generate an image in chat

Choose a model whose catalog entry supports image output. This request uses Gemini 3.1 Flash Image:
Read each image from choices[].message.images[].image_url.url. The value is a data URL; decode the base64 payload after its comma to obtain the image bytes. Text content can be empty when an image is present. For streaming, add the same streaming fields used for text and collect choices[].delta.images[].image_url.url as well as any text deltas. Rendering only delta.content will miss the generated image.

Use the image generation endpoint

For an image-only request, first check that the model publishes the image_generations endpoint:
This endpoint is non-streaming. Decode data[].b64_json directly; it does not have the data URL prefix used by chat images. Chat’s max_tokens, modalities and image_config are not this endpoint’s request controls. See the API reference for its schema.

Check usage and the charge

Keep the response’s usage alongside the request id. Gemini reports reasoning separately from candidate output: do not assume that completion_tokens includes reasoning. Image and audio breakdowns, when reported, appear in the inference response’s token detail fields. Use GET /v1/usage/{id} to read the recorded prompt, completion, cache and reasoning counts and the customer charge. That lookup does not currently expose separate image and audio token counts. Its charge.amount and rate revision identify what the request actually cost; multiplying a text rate by total tokens does not account for the different token kinds. The introductory pricing period for Vertex Gemini 3.8 Flash runs through 2026-12-31. Use the current catalog prices when budgeting later requests; this guide does not promise an automatic price change. Google’s pricing page describes the introductory period.

Account for the current image limitation

Nano Banana 2.1 can currently return a successful response with usage but no text or image in the customer API, in both streaming and non-streaming requests. Treat that as missing output and inspect its usage record before retrying, since it can still incur a charge. Use the Gemini 3.1 Flash Image example above when you need the image flow demonstrated here. For an unavailable or retired model, choose a current id from the catalog instead of constructing a new id from its display name. See Model lifecycle and Errors.

Next