1. 内容生成 (v1beta)
内测文档_v2
  • 支持的模型(逐步更新)
  • 基础接口
    • 任务提交 API
    • 查询任务结果 API
    • 同步图像生成API
  • API文档
    • 可灵
      • 可灵 API
      • 可灵视频生成
    • 通义千问
      • 千问图像生成/编辑-异步
      • 千问图像编辑-同步
    • 即梦
      • 即梦生图参数详解
      • 即梦视频生成
      • 即梦生图
    • 豆包
      • 豆包视频生成参数详解
      • 豆包生视频-异步
      • 豆包生图-异步
      • 豆包生图-同步
    • Google
      • Veo3 视频生成 API
      • Gemini-2.5-flash-image-preview
      • Veo3视频生成
      • 🍌图像生成-异步
      • 🍌图像生成-同步
    • Minimax
      • 视频生成 API
      • Minimax视频生成
    • Vidu
      • 视频生成 API
      • Vidu视频生成
    • OpenAI
      • Sora 视频生成 API
      • Image1 图像生成
      • sora视频生成
      • Image1图像生成-异步
      • Image1图像生成-同步
      • 同步音频转录
      • 创建异步转录任务
    • 火山引擎
      • 火山引擎图片处理
  • 消息接口
    • 创建消息
      POST
  • 内容生成 (v1)
    • 生成内容
      POST
    • 流式生成内容
      POST
  • 内容生成 (v1beta)
    • 生成内容(Beta)
      POST
    • 流式生成内容(Beta)
      POST
  • 查询任务状态
    GET
  1. 内容生成 (v1beta)

流式生成内容(Beta)

POST
https://router.shengsuanyun.com/api/v1beta/models/{model}:streamGenerateContent
使用 Gemini 模型流式生成内容(Beta 版本)

请求参数

Authorization
API Key
在 query 添加参数
key
示例:
key: ********************
or
API Key
在 header 添加参数
x-goog-api-key
示例:
x-goog-api-key: ********************
or
Path 参数

Query 参数

Body 参数application/json必填

示例
{
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "string",
                    "inlineData": {
                        "mimeType": "image/jpeg",
                        "data": "string"
                    },
                    "fileData": {
                        "mimeType": "string",
                        "fileUri": "https://generativelanguage.googleapis.com/v1beta/files/abc123"
                    },
                    "functionCall": {
                        "name": "string",
                        "args": {}
                    },
                    "functionResponse": {
                        "name": "string",
                        "response": {}
                    },
                    "thought": true,
                    "executableCode": {
                        "language": "PYTHON",
                        "code": "string"
                    },
                    "codeExecutionResult": {
                        "outcome": "OUTCOME_OK",
                        "output": "string"
                    }
                }
            ]
        }
    ],
    "systemInstruction": {
        "role": "user",
        "parts": [
            {
                "text": "string",
                "inlineData": {
                    "mimeType": "image/jpeg",
                    "data": "string"
                },
                "fileData": {
                    "mimeType": "string",
                    "fileUri": "https://generativelanguage.googleapis.com/v1beta/files/abc123"
                },
                "functionCall": {
                    "name": "string",
                    "args": {}
                },
                "functionResponse": {
                    "name": "string",
                    "response": {}
                },
                "thought": true,
                "executableCode": {
                    "language": "PYTHON",
                    "code": "string"
                },
                "codeExecutionResult": {
                    "outcome": "OUTCOME_OK",
                    "output": "string"
                }
            }
        ]
    },
    "generationConfig": {
        "temperature": 0.9,
        "topP": 1,
        "topK": 40,
        "maxOutputTokens": 2048,
        "candidateCount": 1,
        "stopSequences": [
            "string"
        ],
        "responseMimeType": "text/plain",
        "responseSchema": {},
        "presencePenalty": -2,
        "frequencyPenalty": -2,
        "responseLogprobs": false,
        "logprobs": 0,
        "seed": 0,
        "responseModalities": [
            "TEXT"
        ],
        "thinkingConfig": {
            "includeThoughts": false,
            "thinkingBudget": 5000
        }
    },
    "safetySettings": [
        {
            "category": "HARM_CATEGORY_HARASSMENT",
            "threshold": "HARM_BLOCK_THRESHOLD_UNSPECIFIED"
        }
    ],
    "tools": [
        {
            "functionDeclarations": [
                {
                    "name": "string",
                    "description": "string",
                    "parameters": {}
                }
            ],
            "googleSearch": {},
            "googleSearchRetrieval": {},
            "codeExecution": {}
        }
    ],
    "toolConfig": {
        "functionCallingConfig": {
            "mode": "AUTO",
            "allowedFunctionNames": [
                "string"
            ]
        }
    },
    "cachedContent": "cachedContents/abc123"
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://router.shengsuanyun.com/api/v1beta/models/:streamGenerateContent?key=<api-key>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "string",
                    "inlineData": {
                        "mimeType": "image/jpeg",
                        "data": "string"
                    },
                    "fileData": {
                        "mimeType": "string",
                        "fileUri": "https://generativelanguage.googleapis.com/v1beta/files/abc123"
                    },
                    "functionCall": {
                        "name": "string",
                        "args": {}
                    },
                    "functionResponse": {
                        "name": "string",
                        "response": {}
                    },
                    "thought": true,
                    "executableCode": {
                        "language": "PYTHON",
                        "code": "string"
                    },
                    "codeExecutionResult": {
                        "outcome": "OUTCOME_OK",
                        "output": "string"
                    }
                }
            ]
        }
    ],
    "systemInstruction": {
        "role": "user",
        "parts": [
            {
                "text": "string",
                "inlineData": {
                    "mimeType": "image/jpeg",
                    "data": "string"
                },
                "fileData": {
                    "mimeType": "string",
                    "fileUri": "https://generativelanguage.googleapis.com/v1beta/files/abc123"
                },
                "functionCall": {
                    "name": "string",
                    "args": {}
                },
                "functionResponse": {
                    "name": "string",
                    "response": {}
                },
                "thought": true,
                "executableCode": {
                    "language": "PYTHON",
                    "code": "string"
                },
                "codeExecutionResult": {
                    "outcome": "OUTCOME_OK",
                    "output": "string"
                }
            }
        ]
    },
    "generationConfig": {
        "temperature": 0.9,
        "topP": 1,
        "topK": 40,
        "maxOutputTokens": 2048,
        "candidateCount": 1,
        "stopSequences": [
            "string"
        ],
        "responseMimeType": "text/plain",
        "responseSchema": {},
        "presencePenalty": -2,
        "frequencyPenalty": -2,
        "responseLogprobs": false,
        "logprobs": 0,
        "seed": 0,
        "responseModalities": [
            "TEXT"
        ],
        "thinkingConfig": {
            "includeThoughts": false,
            "thinkingBudget": 5000
        }
    },
    "safetySettings": [
        {
            "category": "HARM_CATEGORY_HARASSMENT",
            "threshold": "HARM_BLOCK_THRESHOLD_UNSPECIFIED"
        }
    ],
    "tools": [
        {
            "functionDeclarations": [
                {
                    "name": "string",
                    "description": "string",
                    "parameters": {}
                }
            ],
            "googleSearch": {},
            "googleSearchRetrieval": {},
            "codeExecution": {}
        }
    ],
    "toolConfig": {
        "functionCallingConfig": {
            "mode": "AUTO",
            "allowedFunctionNames": [
                "string"
            ]
        }
    },
    "cachedContent": "cachedContents/abc123"
}'

返回响应

🟢200
application/json
成功 - 返回流式响应
Body

示例
"string"
修改于 2025-11-27 10:44:43
上一页
生成内容(Beta)
下一页
查询任务状态
Built with