注册

文本生成-流 Gemini原生

Gemini Text Stream

POST https://api.quickrouter.ai/v1beta/models/gemini-3-pro-preview:streamGenerateContent?key=&alt=sse 在线调试 →
Authorization

在 Header 添加参数 Authorization,其值为 Bearer 之后拼接 Token

示例: Authorization: Bearer ********************

请求参数

Header 参数
Content-Type string
必需
示例: application/json
Authorization string
必需
示例: Bearer $OPENAI_API_KEY
Body 参数 application/json
systemInstruction object
可选
系统指令,用于设定模型角色和行为。
contents array [object]
必需
对话内容列表,每条包含 role 和 parts。
generationConfig object
可选
生成配置,包括 temperature、topP、thinkingConfig 等参数。
示例
{
    "systemInstruction": {
        "parts": [
            {
                "text": "You are a cat. Your name is Neko."
            }
        ]
    },
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "Hello there"
                }
            ]
        }
    ],
    "generationConfig": {
        "temperature": 1,
        "topP": 1,
        "thinkingConfig": {
            "includeThoughts": true,
            "thinkingBudget": 26240
        }
    }
}

请求示例代码

curl --location -g --request POST 'https://api.quickrouter.ai/v1beta/models/gemini-3-pro-preview:streamGenerateContent?key=&alt=sse' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "systemInstruction": {
        "parts": [
            {
                "text": "You are a cat. Your name is Neko."
            }
        ]
    },
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "Hello there"
                }
            ]
        }
    ],
    "generationConfig": {
        "temperature": 1,
        "topP": 1,
        "thinkingConfig": {
            "includeThoughts": true,
            "thinkingBudget": 26240
        }
    }
}'
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
   "systemInstruction": {
      "parts": [
         {
            "text": "You are a cat. Your name is Neko."
         }
      ]
   },
   "contents": [
      {
         "role": "user",
         "parts": [
            {
               "text": "Hello there"
            }
         ]
      }
   ],
   "generationConfig": {
      "temperature": 1,
      "topP": 1,
      "thinkingConfig": {
         "includeThoughts": true,
         "thinkingBudget": 26240
      }
   }
});

var requestOptions = {
   method: 'POST',
   headers: myHeaders,
   body: raw,
   redirect: 'follow'
};

fetch("https://api.quickrouter.ai/v1beta/models/gemini-3-pro-preview:streamGenerateContent?key=&alt=sse", requestOptions)
   .then(response => response.text())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
import http.client
import json

conn = http.client.HTTPSConnection("api.quickrouter.ai")
payload = json.dumps({
   "systemInstruction": {
      "parts": [
         {
            "text": "You are a cat. Your name is Neko."
         }
      ]
   },
   "contents": [
      {
         "role": "user",
         "parts": [
            {
               "text": "Hello there"
            }
         ]
      }
   ],
   "generationConfig": {
      "temperature": 1,
      "topP": 1,
      "thinkingConfig": {
         "includeThoughts": True,
         "thinkingBudget": 26240
      }
   }
})
headers = {
   'Authorization': 'Bearer <token>',
   'Content-Type': 'application/json'
}
conn.request("POST", "/v1beta/models/gemini-3-pro-preview:streamGenerateContent?key=&alt=sse", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

返回响应

响应参数 🟢 200 OK · application/json
candidates array [object]
必需
modelVersion string
必需
示例
{
    "candidates": [
        {
            "content": {
                "parts": [
                    {
                        "text": "Meow! Hello there!"
                    }
                ],
                "role": "model"
            },
            "finishReason": "STOP"
        }
    ],
    "modelVersion": "gemini-3-pro-preview"
}