/v1beta/models/{model}:streamGenerateContentStream generated content (Gemini)
Google's streamGenerateContent. alt=sse is required (the google-genai SDK sends it); without it the call is a 400. The last frame carries finishReason, usageMetadata (with cost) and provider; a failure mid-stream arrives as a frame holding the Google error envelope.
認証: AuthorizationヘッダーにBearer形式のAPIキー
パスパラメータ
modelstring必須A model slug.
クエリパラメータ
altstring必須Must be
sse.
リクエストボディ
contentsarray<object>必須Turns of
parts: text,inlineData, publicfileDataURLs,functionCall,functionResponse.systemInstructionobjecttoolsarray<object>functionDeclarationsonly; Google server tools are refused.toolConfigobjectgenerationConfigobjectSampling,
maxOutputTokens,stopSequences,responseSchemaorresponseJsonSchema,thinkingConfig.providerobjectOpenRouter's routing-preference object, resolved against the model's own provider routes. Only tightens, never loosens, your organization's policy.
provider
zdrbooleantrueserves only zero-data-retention routes for this request, or refuses with a 403 naming the excluded providers.onlyarray<string>Keep only these providers.
ignorearray<string>Drop these providers.
orderarray<string>Try these providers first, in order; the rest stay as fallbacks.
allow_fallbacksbooleanfalsewithorderserves only the listed providers; withoutorder, only the first eligible route.
レスポンス
200A stream of GenerateContentResponse frames.
400Invalid request, in the Google envelope.
レスポンス
errorobjecterror
codeintegerThe HTTP status.
messagestringstatusstringFor example
INVALID_ARGUMENT,UNAUTHENTICATED,RESOURCE_EXHAUSTED.detailsarray<object>
401The key is missing or invalid.
レスポンス
errorobjecterror
codeintegerThe HTTP status.
messagestringstatusstringFor example
INVALID_ARGUMENT,UNAUTHENTICATED,RESOURCE_EXHAUSTED.detailsarray<object>
429Rate limited or out of credits. RetryInfo carries the wait when retrying helps.
レスポンス
errorobjecterror
codeintegerThe HTTP status.
messagestringstatusstringFor example
INVALID_ARGUMENT,UNAUTHENTICATED,RESOURCE_EXHAUSTED.detailsarray<object>
リクエスト
curl "https://api.experientiallabs.ai/v1beta/models/gpt-6-luna:streamGenerateContent?alt=sse" \
-H "x-goog-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents": [{"role": "user", "parts": [{"text": "Say hi."}]}]}'
レスポンス
data: {"candidates":[{"content":{"role":"model","parts":[{"text":"Hi"}]},"index":0}],"responseId":"resp_0b7e4f2a9c1d46e8b3a5f7c9e1d2b4a6","modelVersion":"gpt-6-luna"}
data: {"candidates":[{"content":{"role":"model","parts":[{"text":"!"}]},"finishReason":"STOP","index":0}],"usageMetadata":{"promptTokenCount":3,"candidatesTokenCount":2,"totalTokenCount":5,"cost":0.0000013,"is_byok":false},"responseId":"resp_0b7e4f2a9c1d46e8b3a5f7c9e1d2b4a6","modelVersion":"gpt-6-luna","provider":"openai"}
https://api.experientiallabs.ai/v1beta/models/gpt-6-luna:streamGenerateContent?alt=sse