Compatible con Gemini
Activo
Utilice el modelo, la generación, la transmisión y las rutas de incorporación compatibles con Gemini cuando esté configurado.
GET /v1beta/models
Enumera los modelos compatibles con Gemini visibles para la clave API actual.
Lista de modelos Gemini
curl https://www.token168.cc/v1beta/models \
-H "Authorization: Bearer $TOKEN168_API_KEY"
POST /v1beta/models/{model}:generateContent
generateContent accepts native Gemini content, safety, tool, system instruction, cache, and generationConfig fields. El ejemplo utiliza el ejemplo de documentación del último modelo seleccionado gemini-3.1-pro.
Gemini: generateContent
curl https://www.token168.cc/v1beta/models/gemini-3.1-pro:generateContent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "Summarize the release notes.", "thought": false}]}],
"safetySettings": [{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"}],
"generationConfig": {
"temperature": 0.4,
"topP": 0.9,
"topK": 40,
"maxOutputTokens": 800,
"candidateCount": 1,
"stopSequences": ["END"],
"responseMimeType": "application/json",
"responseSchema": {"type": "object", "properties": {"summary": {"type": "string"}}},
"responseJsonSchema": {"type": "object"},
"presencePenalty": 0,
"frequencyPenalty": 0,
"responseLogprobs": false,
"logprobs": 0,
"enableEnhancedCivicAnswers": false,
"mediaResolution": "MEDIA_RESOLUTION_MEDIUM",
"seed": 123,
"responseModalities": ["TEXT"],
"thinkingConfig": {"includeThoughts": true, "thinkingBudget": 1024, "thinkingLevel": "medium"},
"speechConfig": {"voiceConfig": {"prebuiltVoiceConfig": {"voiceName": "Kore"}}},
"imageConfig": {"aspectRatio": "1:1"}
},
"tools": [{"functionDeclarations": [{"name": "lookup", "parameters": {"type": "object", "properties": {}}}]}],
"toolConfig": {"functionCallingConfig": {"mode": "AUTO", "allowedFunctionNames": ["lookup"]}, "retrievalConfig": {"languageCode": "en"}, "includeServerSideToolInvocations": false},
"systemInstruction": {"role": "system", "parts": [{"text": "Return concise JSON."}]},
"cachedContent": "cachedContents/example"
}'
POST /v1beta/models/{model}:streamGenerateContent
La transmisión utiliza el mismo cuerpo de solicitud con la acción de transmisión o el parámetro de consulta alt=sse.
Transmisión de Gemini
curl "https://www.token168.cc/v1beta/models/gemini-3.1-pro:streamGenerateContent?alt=sse" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "Stream one paragraph."}]}],
"generationConfig": {"temperature": 0.4, "topP": 0.9, "topK": 40, "maxOutputTokens": 400, "candidateCount": 1}
}'
POST /v1beta/models/{model}:embedContent
Las rutas Gemini de estilo integrado se enrutan a través del formato de relé Gemini cuando se configuran.
Incrustación Gemini
curl https://www.token168.cc/v1beta/models/gemini-3.1-pro:embedContent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-d '{
"content": {"parts": [{"text": "Token168 docs"}]},
"taskType": "RETRIEVAL_DOCUMENT",
"title": "Docs"
}'