Gemini API
Google's native generateContent API at /v1beta, so the google-genai SDK works unchanged on every catalog model.
このページはまだ翻訳されていません。英語版を表示しています。
Generate content
Set the SDK base URL to https://api.experientiallabs.ai with API version v1beta. Auth: x-goog-api-key (SDK default), ?key=, or Authorization: Bearer. {model} is any slug from GET /v1beta/models (the same set as /v1/models).
/v1beta/models/{model}:generateContentGET/v1beta/modelscurl "https://api.experientiallabs.ai/v1beta/models/gemini-4-argon:generateContent" \
-H "x-goog-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents": [{"role": "user", "parts": [{"text": "Hello"}]}]}'Stream
:streamGenerateContent?alt=sse (alt=sse is required) sends one GenerateContentResponse per frame; the last carries finishReason and usageMetadata.
/v1beta/models/{model}:streamGenerateContentcurl -N "https://api.experientiallabs.ai/v1beta/models/gemini-4-argon:streamGenerateContent?alt=sse" \
-H "x-goog-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents": [{"role": "user", "parts": [{"text": "Hello"}]}]}'Supported fields
| Field | Contract |
|---|---|
contents | Text, inlineData (images, MP4 video, WAV/MP3 audio, PDF), public fileData, functionCall / functionResponse (thought signatures kept) |
systemInstruction | Text parts |
tools, toolConfig | functionDeclarations; AUTO, ANY, NONE, allowedFunctionNames. Google server tools (googleSearch, codeExecution, urlContext, fileSearch) are a 400 |
generationConfig | Sampling, maxOutputTokens, stopSequences, JSON mode, responseJsonSchema / responseSchema, thinkingConfig. candidateCount other than 1, non-text modalities, speechConfig, imageConfig are refused |
safetySettings, labels, seed, logprobs | Dropped with disclosure |
cachedContent | Refused; Gemini lanes cache automatically |
{
"contents": [{"role": "user", "parts": [{"text": "Ada Lovelace, born 1815"}]}],
"generationConfig": {
"responseMimeType": "application/json",
"responseJsonSchema": {"type": "object", "properties": {"name": {"type": "string"}, "born": {"type": "integer"}}}
}
}Usage, tokens and errors
usageMetadata has promptTokenCount (cached reads also as cachedContentTokenCount), candidatesTokenCount, thoughtsTokenCount, totalTokenCount, plus cost. :countTokens answers an estimate, free. Idempotency-Key is not honored. Errors use Google's envelope; the gateway code is in details[0].reason and the field in details[0].metadata.param (Errors).
/v1beta/models/{model}:countTokens{"error": {"code": 400, "message": "...", "status": "INVALID_ARGUMENT",
"details": [{"reason": "unsupported_parameter", "metadata": {"param": "generationConfig.candidateCount"}}]}}