Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
通过 Gemini API 调用 Google Gemini 2.5 Pro 流式输出。支持 SSE 实时 Token 流式传输。
curl "https://www.anyfast.ai/v1beta/models/gemini-2.5-pro:streamGenerateContent?key=YOUR_API_KEY&alt=sse" \ -H "Content-Type: application/json" \ -d '{ "contents": [ { "role": "user", "parts": [{ "text": "写一首关于大海的短诗。" }] } ], "generationConfig": { "temperature": 1, "topP": 1, "thinkingConfig": { "includeThoughts": true, "thinkingBudget": 26240 } } }'
import requests url = "https://www.anyfast.ai/v1beta/models/gemini-2.5-pro:streamGenerateContent" params = {"key": "YOUR_API_KEY", "alt": "sse"} data = { "contents": [ { "role": "user", "parts": [{"text": "写一首关于大海的短诗。"}] } ], "generationConfig": { "temperature": 1, "topP": 1, "thinkingConfig": { "includeThoughts": True, "thinkingBudget": 26240 } } } response = requests.post(url, params=params, json=data, stream=True) for line in response.iter_lines(): if line: print(line.decode())
key
alt
sse
contents
{ role, parts }
systemInstruction
parts
generationConfig.temperature
0
2
1
generationConfig.topP
generationConfig.thinkingConfig
safetySettings
此页面对您有帮助吗?