请求示例
curl
curl --fail-with-body --max-time 300 'https://api.juhenextvip.com/v1/chat/completions' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-bs",
"messages": [
{
"role": "user",
"content": "A yellow ceramic bowl on a white background. No text."
}
],
"size": "1024x1024",
"stream": false
}'
javascript
const response = await fetch("https://api.juhenextvip.com/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer <YOUR_API_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
"model": "gemini-nano-banana-2.1-bs",
"messages": [
{
"role": "user",
"content": "A yellow ceramic bowl on a white background. No text."
}
],
"size": "1024x1024",
"stream": false
}),
signal: AbortSignal.timeout(300_000),
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
console.log(data);
python
import json
import requests
payload = json.loads("{\n \"model\": \"gemini-nano-banana-2.1-bs\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"A yellow ceramic bowl on a white background. No text.\"\n }\n ],\n \"size\": \"1024x1024\",\n \"stream\": false\n}")
response = requests.post(
"https://api.juhenextvip.com/v1/chat/completions",
headers={"Authorization": "Bearer <YOUR_API_KEY>"},
json=payload,
timeout=(10, 300),
)
response.raise_for_status()
print(response.json())
curl
curl --fail-with-body --max-time 300 --no-buffer 'https://api.juhenextvip.com/v1/chat/completions' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-bs",
"messages": [
{
"role": "user",
"content": "A yellow ceramic bowl on a white background. No text."
}
],
"size": "1024x1024",
"stream": true
}'
javascript
const response = await fetch("https://api.juhenextvip.com/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer <YOUR_API_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
"model": "gemini-nano-banana-2.1-bs",
"messages": [
{
"role": "user",
"content": "A yellow ceramic bowl on a white background. No text."
}
],
"size": "1024x1024",
"stream": true
}),
signal: AbortSignal.timeout(300_000),
});
if (!response.ok) throw new Error(await response.text());
const decoder = new TextDecoder();
for await (const chunk of response.body) {
process.stdout.write(decoder.decode(chunk, { stream: true }));
}
// SSE may split across chunks. Parse complete data: events through [DONE].
python
import json
import requests
payload = json.loads("{\n \"model\": \"gemini-nano-banana-2.1-bs\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"A yellow ceramic bowl on a white background. No text.\"\n }\n ],\n \"size\": \"1024x1024\",\n \"stream\": true\n}")
with requests.post(
"https://api.juhenextvip.com/v1/chat/completions",
headers={"Authorization": "Bearer <YOUR_API_KEY>"},
json=payload,
timeout=(10, 300),
stream=True,
) as response:
response.raise_for_status()
for line in response.iter_lines():
if line:
print(line.decode("utf-8"), flush=True)
curl
curl --fail-with-body --max-time 300 'https://api.juhenextvip.com/v1/chat/completions' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-bs",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Change the cup to green; keep the white background."
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/reference.jpg"
}
}
]
}
],
"size": "auto",
"stream": false
}'
javascript
const response = await fetch("https://api.juhenextvip.com/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer <YOUR_API_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
"model": "gemini-nano-banana-2.1-bs",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Change the cup to green; keep the white background."
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/reference.jpg"
}
}
]
}
],
"size": "auto",
"stream": false
}),
signal: AbortSignal.timeout(300_000),
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
console.log(data);
python
import json
import requests
payload = json.loads("{\n \"model\": \"gemini-nano-banana-2.1-bs\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Change the cup to green; keep the white background.\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://example.com/reference.jpg\"\n }\n }\n ]\n }\n ],\n \"size\": \"auto\",\n \"stream\": false\n}")
response = requests.post(
"https://api.juhenextvip.com/v1/chat/completions",
headers={"Authorization": "Bearer <YOUR_API_KEY>"},
json=payload,
timeout=(10, 300),
)
response.raise_for_status()
print(response.json())
响应示例
json
{
"id": "chatcmpl-gemini-example",
"object": "chat.completion",
"created": 1795730000,
"model": "gemini-nano-banana-2.1-bs",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": ""
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 1120,
"total_tokens": 1148
}
}
sse
data: {"id":"chatcmpl-gemini-example","object":"chat.completion.chunk","model":"gemini-nano-banana-2.1-bs","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
data: {"id":"chatcmpl-gemini-example","object":"chat.completion.chunk","model":"gemini-nano-banana-2.1-bs","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":28,"completion_tokens":1120,"total_tokens":1148}}
data: [DONE]