Skip to content
TutujinAPI

API reference

Gemini generateContent API

Headers, path, parameters, request and response examples for Gemini's native generateContent endpoint. Same format as the Google Gemini API; the Google Gen AI SDK works after changing the base URL. Verified on this site.

The native Gemini endpoint uses the Google Gemini API format: the model name goes in the URL path, the conversation is built from contents and parts, and generation settings go in generationConfig. Code written with the Google Gen AI SDK works once you set the base URL to https://www.tutujin.com. We have verified this endpoint (generateContent) on this site.

POSThttps://www.tutujin.com/v1beta/models/gemini-3.8-flash:generateContent

The path pattern is /v1beta/models/MODEL:generateContent. Replace MODEL with the model you want; the request body does not need a model field.

Headers

HeaderRequiredDescription
x-goog-api-keyOne of the twoAn API key from the console (sk-...). The Google Gen AI SDK uses this header by default
AuthorizationOne of the twoBearer sk-..., as an alternative to x-goog-api-key
Content-TypeYesapplication/json

Request body

ParameterTypeRequiredDescription
contentsarrayYesThe conversation, oldest first. Each item has a role (user or model) and parts
contents[].partsarrayYesContent parts. Text is {"text": "..."}; images, PDFs and other files use inlineData with a mimeType and base64 data
systemInstructionobjectNoSystem prompt, shaped like a content item, e.g. {"parts": [{"text": "..."}]}
generationConfigobjectNoGeneration settings — see the next table
safetySettingsarrayNoSafety filter thresholds by category
toolsarrayNoTools, e.g. functionDeclarations
toolConfigobjectNoFunction-calling mode, e.g. only allow specific functions

generationConfig

FieldTypeDescription
temperaturenumberSampling temperature; higher is more varied
topPnumberNucleus sampling
topKintegerSample only from the K most likely tokens
maxOutputTokensintegerMost tokens to generate
stopSequencesarrayStop generating when one of these strings appears
responseMimeTypestringapplication/json asks for JSON output
responseSchemaobjectSchema to use with JSON output
thinkingConfigobjectThinking settings, e.g. {"thinkingBudget": 1024}; supported fields vary by model
candidateCountintegerNumber of candidate answers

Request example

curl "https://www.tutujin.com/v1beta/models/gemini-3.8-flash:generateContent" \
  -H "x-goog-api-key: $TUTUJIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "systemInstruction": {"parts": [{"text": "You are an e-commerce copy assistant. Keep it short."}]},
    "contents": [
      {"role": "user", "parts": [{"text": "Write 3 selling points for a 500 ml insulated bottle"}]}
    ],
    "generationConfig": {"temperature": 0.7, "maxOutputTokens": 512}
  }'

The SDKs append /v1beta/models/... to the base URL, so the base URL is just the site root.

Response example

JSON
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [{ "text": "1. Double-wall vacuum keeps drinks hot for hours..." }]
      },
      "finishReason": "STOP",
      "index": 0
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 28,
    "candidatesTokenCount": 96,
    "totalTokenCount": 124
  },
  "modelVersion": "gemini-3.8-flash"
}
FieldDescription
candidates[].content.parts[].textThe model's answer, possibly split across several parts
candidates[].finishReasonSTOP finished normally; MAX_TOKENS hit the limit; SAFETY blocked by the safety filter
usageMetadata.promptTokenCountInput tokens, billed at the input price
usageMetadata.candidatesTokenCountOutput tokens, billed at the output price
usageMetadata.thoughtsTokenCountThinking tokens, on models with thinking enabled; counted as output
usageMetadata.cachedContentTokenCountInput tokens served from cache; when present, billed at the cache-read price

Streaming

Gemini's streaming path is /v1beta/models/MODEL:streamGenerateContent?alt=sse; in the SDKs it is generate_content_stream (Python) and generateContentStream (Node.js).

Streaming requests are relayed as-is, but native-format Gemini streaming has not been verified separately on this site, so test it with a little traffic before going live. You can also call Gemini models that the catalog lists for Chat Completions in that format and use "stream": true.

Notes

  • The model name goes in the URL path and must match the model hub exactly, including case.
  • The model's side of the conversation uses role model, not assistant.
  • Images, PDFs and other files go in the body as base64 inlineData; bigger files mean bigger requests, so keep sizes in check.
  • On models with thinking, thinking tokens count as output; set a budget with thinkingConfig.
  • Gemini groups differ in line and price — see Choosing a group. The same Gemini model can usually be called through Chat Completions too, which keeps one code path across vendors.

Models that support this endpoint

ModelVendorCheapest groupInput ¥/1MOutput ¥/1MPer request ¥
gemini-3.8-flashGoogleStandard¥1.5¥7.5—
gemini-3.1-pro-previewGoogleStandard¥4¥24—
gemini-2.5-flash-imageGoogleGemini Plus——¥0.16
Nano-bananaGoogleGemini Plus——¥0.16
gemini-nano-banana-2.1-2kGoogleStandard——¥0.2
gemini-nano-banana-2.1-4kGoogleStandard——¥0.2
gemini-nano-banana-2.1GoogleStandard——¥0.2
gemini-3.1-flash-lite-imageGoogleGemini Plus——¥0.2

Prices in CNY, cheapest group for each model; updated Nov 13, 2026, 6:08 PM.

63 models support this endpoint; the table shows some of them. See them all in the model hub

Still stuck? Add our WeChat support JsnonoChat and send the request id from the error message, and we will look into it.