import asynciofrom comfy_sdk import AsyncComfy# Reads COMFY_API_KEY from the environment.# The SDK automatically creates an idempotency key and reuses it for automatic retries.async def main(): async with AsyncComfy() as client: result = await client.models.run( "vertexai/gemini-3.1-pro-preview", { "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256, }, }, ) print("text:", result["candidates"][0]["content"]["parts"][0]["text"])asyncio.run(main())
import { comfy } from "@comfyorg/sdk";// Reads COMFY_API_KEY from the environment.// The SDK automatically creates an idempotency key and reuses it for automatic retries.type Result = { candidates: { content: { parts: { text: string }[] } }[] };const result = await comfy.models.run<Result>("vertexai/gemini-3.1-pro-preview", { contents: [ { role: "user", parts: [ { text: "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], generationConfig: { temperature: 0.7, maxOutputTokens: 256, },});if (result.kind !== "json") throw new Error("expected a JSON result");console.log("text:", result.data.candidates[0].content.parts[0].text);
curl https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
将相同的请求体发送到 POST https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview/requests。Router 会在运行被受理后立即返回 201 和 request_id,结果就绪后即可从本进程或其他进程收集。队列投递详细介绍了状态查询、取消和结果收集。
import asynciofrom comfy_sdk import AsyncComfy# Reads COMFY_API_KEY from the environment.# Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.async def main(): async with AsyncComfy() as client: handle = await client.models.submit( "vertexai/gemini-3.1-pro-preview", { "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256, }, }, ) print("request_id:", handle.request_id) # with the model ID, all another process needs # Poll until the request completes, waiting the Retry-After the server names. async for update in handle.iter_events(): print(update.status, update.queue_position) # The provider's own payload, the same value models.run() returns. # A request that failed or was cancelled raises the typed Router error here. result = await handle.get() print("text:", result["candidates"][0]["content"]["parts"][0]["text"])asyncio.run(main())
import { comfy } from "@comfyorg/sdk";// Reads COMFY_API_KEY from the environment.// Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.type Result = { candidates: { content: { parts: { text: string }[] } }[] };const handle = await comfy.models.submit<Result>("vertexai/gemini-3.1-pro-preview", { contents: [ { role: "user", parts: [ { text: "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], generationConfig: { temperature: 0.7, maxOutputTokens: 256, },});console.log("requestId:", handle.requestId); // with the model ID, all another process needs// Poll until the request completes, waiting the Retry-After the server names.for await (const update of handle.events()) { console.log(update.status, update.queuePosition);}// The same result models.run() returns. A request that failed or was cancelled rejects here.const result = await handle.get();if (result.kind !== "json") throw new Error("expected a JSON result");console.log("text:", result.data.candidates[0].content.parts[0].text);
# 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.curl https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview/requests \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"# 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.REQUEST_ID="<request_id from the 201 body>"curl -i https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview/requests/$REQUEST_ID/status \ -H "X-API-Key: $COMFY_API_KEY"# 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.curl https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview/requests/$REQUEST_ID \ -H "X-API-Key: $COMFY_API_KEY"
可选。在 Vertex AI 路径(即由 Comfy 自身凭证提供服务的请求,以及使用 GCP 服务账号进行身份验证的 BYOK 请求)上,输出应保存为的图像格式。这些路径上接受的值为 image/png 和 image/jpeg,匹配时不区分大小写,并在请求被转发之前统一转为小写;任何其他值都会被拒绝,并返回 400 错误且指明该字段。省略时默认为 image/png。使用 Google AI Studio API 密钥进行身份验证的 BYOK 请求是个例外:该上游没有此属性,一旦请求中包含它就会拒绝整个调用,因此该字段会从请求中移除,而不是被采用或被拒绝,输出格式由 AI Studio 自行决定。在所有路径上,都应从你收到的响应部分中读回媒体类型(inlineData.mimeType,或者当设置了 uploadImagesToStorage 时读取 fileData.mimeType),而不要假设你发送的值就是最终结果。
{ "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence." } ] } ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256 }}
输出
{ "candidates": [ { "content": { "role": "model", "parts": [ { "text": "A single red maple leaf rests on a plain white background, its edges sharp and its color deep." } ] }, "finishReason": "STOP" } ], "usageMetadata": { "promptTokenCount": 18, "candidatesTokenCount": 24 }}
import asynciofrom comfy_sdk import AsyncComfy# Reads COMFY_API_KEY from the environment.# The SDK automatically creates an idempotency key and reuses it for automatic retries.async def main(): async with AsyncComfy() as client: result = await client.models.run( "vertexai/gemini-3.5-flash", { "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256, }, }, ) print("text:", result["candidates"][0]["content"]["parts"][0]["text"])asyncio.run(main())
import { comfy } from "@comfyorg/sdk";// Reads COMFY_API_KEY from the environment.// The SDK automatically creates an idempotency key and reuses it for automatic retries.type Result = { candidates: { content: { parts: { text: string }[] } }[] };const result = await comfy.models.run<Result>("vertexai/gemini-3.5-flash", { contents: [ { role: "user", parts: [ { text: "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], generationConfig: { temperature: 0.7, maxOutputTokens: 256, },});if (result.kind !== "json") throw new Error("expected a JSON result");console.log("text:", result.data.candidates[0].content.parts[0].text);
curl https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
将相同的请求体发送到 POST https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash/requests。Router 会在运行被受理后立即返回 201 和 request_id,结果就绪后即可从本进程或其他进程收集。队列投递详细介绍了状态查询、取消和结果收集。
import asynciofrom comfy_sdk import AsyncComfy# Reads COMFY_API_KEY from the environment.# Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.async def main(): async with AsyncComfy() as client: handle = await client.models.submit( "vertexai/gemini-3.5-flash", { "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256, }, }, ) print("request_id:", handle.request_id) # with the model ID, all another process needs # Poll until the request completes, waiting the Retry-After the server names. async for update in handle.iter_events(): print(update.status, update.queue_position) # The provider's own payload, the same value models.run() returns. # A request that failed or was cancelled raises the typed Router error here. result = await handle.get() print("text:", result["candidates"][0]["content"]["parts"][0]["text"])asyncio.run(main())
import { comfy } from "@comfyorg/sdk";// Reads COMFY_API_KEY from the environment.// Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.type Result = { candidates: { content: { parts: { text: string }[] } }[] };const handle = await comfy.models.submit<Result>("vertexai/gemini-3.5-flash", { contents: [ { role: "user", parts: [ { text: "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], generationConfig: { temperature: 0.7, maxOutputTokens: 256, },});console.log("requestId:", handle.requestId); // with the model ID, all another process needs// Poll until the request completes, waiting the Retry-After the server names.for await (const update of handle.events()) { console.log(update.status, update.queuePosition);}// The same result models.run() returns. A request that failed or was cancelled rejects here.const result = await handle.get();if (result.kind !== "json") throw new Error("expected a JSON result");console.log("text:", result.data.candidates[0].content.parts[0].text);
# 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.curl https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash/requests \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"# 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.REQUEST_ID="<request_id from the 201 body>"curl -i https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash/requests/$REQUEST_ID/status \ -H "X-API-Key: $COMFY_API_KEY"# 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.curl https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash/requests/$REQUEST_ID \ -H "X-API-Key: $COMFY_API_KEY"
可选。在 Vertex AI 路径(即由 Comfy 自身凭证提供服务的请求,以及使用 GCP 服务账号进行身份验证的 BYOK 请求)上,输出应保存为的图像格式。这些路径上接受的值为 image/png 和 image/jpeg,匹配时不区分大小写,并在请求被转发之前统一转为小写;任何其他值都会被拒绝,并返回 400 错误且指明该字段。省略时默认为 image/png。使用 Google AI Studio API 密钥进行身份验证的 BYOK 请求是个例外:该上游没有此属性,一旦请求中包含它就会拒绝整个调用,因此该字段会从请求中移除,而不是被采用或被拒绝,输出格式由 AI Studio 自行决定。在所有路径上,都应从你收到的响应部分中读回媒体类型(inlineData.mimeType,或者当设置了 uploadImagesToStorage 时读取 fileData.mimeType),而不要假设你发送的值就是最终结果。
{ "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence." } ] } ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256 }}
输出
{ "candidates": [ { "content": { "role": "model", "parts": [ { "text": "A single red maple leaf rests on a plain white background, its edges sharp and its color deep." } ] }, "finishReason": "STOP" } ], "usageMetadata": { "promptTokenCount": 18, "candidatesTokenCount": 24 }}
import asynciofrom comfy_sdk import AsyncComfy# Reads COMFY_API_KEY from the environment.# The SDK automatically creates an idempotency key and reuses it for automatic retries.async def main(): async with AsyncComfy() as client: result = await client.models.run( "vertexai/gemini-2.5-pro", { "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256, }, }, ) print("text:", result["candidates"][0]["content"]["parts"][0]["text"])asyncio.run(main())
import { comfy } from "@comfyorg/sdk";// Reads COMFY_API_KEY from the environment.// The SDK automatically creates an idempotency key and reuses it for automatic retries.type Result = { candidates: { content: { parts: { text: string }[] } }[] };const result = await comfy.models.run<Result>("vertexai/gemini-2.5-pro", { contents: [ { role: "user", parts: [ { text: "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], generationConfig: { temperature: 0.7, maxOutputTokens: 256, },});if (result.kind !== "json") throw new Error("expected a JSON result");console.log("text:", result.data.candidates[0].content.parts[0].text);
curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
将相同的请求体发送到 POST https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro/requests。Router 会在运行被受理后立即返回 201 和 request_id,结果就绪后即可从本进程或其他进程收集。队列投递详细介绍了状态查询、取消和结果收集。
import asynciofrom comfy_sdk import AsyncComfy# Reads COMFY_API_KEY from the environment.# Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.async def main(): async with AsyncComfy() as client: handle = await client.models.submit( "vertexai/gemini-2.5-pro", { "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256, }, }, ) print("request_id:", handle.request_id) # with the model ID, all another process needs # Poll until the request completes, waiting the Retry-After the server names. async for update in handle.iter_events(): print(update.status, update.queue_position) # The provider's own payload, the same value models.run() returns. # A request that failed or was cancelled raises the typed Router error here. result = await handle.get() print("text:", result["candidates"][0]["content"]["parts"][0]["text"])asyncio.run(main())
import { comfy } from "@comfyorg/sdk";// Reads COMFY_API_KEY from the environment.// Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.type Result = { candidates: { content: { parts: { text: string }[] } }[] };const handle = await comfy.models.submit<Result>("vertexai/gemini-2.5-pro", { contents: [ { role: "user", parts: [ { text: "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], generationConfig: { temperature: 0.7, maxOutputTokens: 256, },});console.log("requestId:", handle.requestId); // with the model ID, all another process needs// Poll until the request completes, waiting the Retry-After the server names.for await (const update of handle.events()) { console.log(update.status, update.queuePosition);}// The same result models.run() returns. A request that failed or was cancelled rejects here.const result = await handle.get();if (result.kind !== "json") throw new Error("expected a JSON result");console.log("text:", result.data.candidates[0].content.parts[0].text);
# 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro/requests \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"# 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.REQUEST_ID="<request_id from the 201 body>"curl -i https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro/requests/$REQUEST_ID/status \ -H "X-API-Key: $COMFY_API_KEY"# 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro/requests/$REQUEST_ID \ -H "X-API-Key: $COMFY_API_KEY"
Schema
输入
这些字段遵循 Google 公布的 API 规范,并在 CI 中对照该规范进行校验。Router 针对此模型自身的 Schema 尚未发布,因此请求会未经校验直接转发给提供商。
{ "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence." } ] } ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256 }}
输出
{ "candidates": [ { "content": { "role": "model", "parts": [ { "text": "A single red maple leaf rests on a plain white background, its edges sharp and its color deep." } ] }, "finishReason": "STOP" } ], "usageMetadata": { "promptTokenCount": 18, "candidatesTokenCount": 24 }}
import asynciofrom comfy_sdk import AsyncComfy# Reads COMFY_API_KEY from the environment.# The SDK automatically creates an idempotency key and reuses it for automatic retries.async def main(): async with AsyncComfy() as client: result = await client.models.run( "vertexai/gemini-2.5-flash", { "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256, }, }, ) print("text:", result["candidates"][0]["content"]["parts"][0]["text"])asyncio.run(main())
import { comfy } from "@comfyorg/sdk";// Reads COMFY_API_KEY from the environment.// The SDK automatically creates an idempotency key and reuses it for automatic retries.type Result = { candidates: { content: { parts: { text: string }[] } }[] };const result = await comfy.models.run<Result>("vertexai/gemini-2.5-flash", { contents: [ { role: "user", parts: [ { text: "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], generationConfig: { temperature: 0.7, maxOutputTokens: 256, },});if (result.kind !== "json") throw new Error("expected a JSON result");console.log("text:", result.data.candidates[0].content.parts[0].text);
curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
将相同的请求体发送到 POST https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash/requests。Router 会在运行被受理后立即返回 201 和 request_id,结果就绪后即可从本进程或其他进程收集。队列投递详细介绍了状态查询、取消和结果收集。
import asynciofrom comfy_sdk import AsyncComfy# Reads COMFY_API_KEY from the environment.# Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.async def main(): async with AsyncComfy() as client: handle = await client.models.submit( "vertexai/gemini-2.5-flash", { "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256, }, }, ) print("request_id:", handle.request_id) # with the model ID, all another process needs # Poll until the request completes, waiting the Retry-After the server names. async for update in handle.iter_events(): print(update.status, update.queue_position) # The provider's own payload, the same value models.run() returns. # A request that failed or was cancelled raises the typed Router error here. result = await handle.get() print("text:", result["candidates"][0]["content"]["parts"][0]["text"])asyncio.run(main())
import { comfy } from "@comfyorg/sdk";// Reads COMFY_API_KEY from the environment.// Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.type Result = { candidates: { content: { parts: { text: string }[] } }[] };const handle = await comfy.models.submit<Result>("vertexai/gemini-2.5-flash", { contents: [ { role: "user", parts: [ { text: "Describe a single red maple leaf on a white background in one sentence.", }, ], }, ], generationConfig: { temperature: 0.7, maxOutputTokens: 256, },});console.log("requestId:", handle.requestId); // with the model ID, all another process needs// Poll until the request completes, waiting the Retry-After the server names.for await (const update of handle.events()) { console.log(update.status, update.queuePosition);}// The same result models.run() returns. A request that failed or was cancelled rejects here.const result = await handle.get();if (result.kind !== "json") throw new Error("expected a JSON result");console.log("text:", result.data.candidates[0].content.parts[0].text);
# 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash/requests \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"# 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.REQUEST_ID="<request_id from the 201 body>"curl -i https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash/requests/$REQUEST_ID/status \ -H "X-API-Key: $COMFY_API_KEY"# 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash/requests/$REQUEST_ID \ -H "X-API-Key: $COMFY_API_KEY"
Schema
输入
这些字段遵循 Google 公布的 API 规范,并在 CI 中对照该规范进行校验。Router 针对此模型自身的 Schema 尚未发布,因此请求会未经校验直接转发给提供商。
{ "contents": [ { "role": "user", "parts": [ { "text": "Describe a single red maple leaf on a white background in one sentence." } ] } ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 256 }}
输出
{ "candidates": [ { "content": { "role": "model", "parts": [ { "text": "A single red maple leaf rests on a plain white background, its edges sharp and its color deep." } ] }, "finishReason": "STOP" } ], "usageMetadata": { "promptTokenCount": 18, "candidatesTokenCount": 24 }}