Text Generation (Vision)
Last updated
curl -X POST "https://inference.nebulablock.com/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $NEBULA_API_KEY" \
--data-raw '{
"messages": [
{"role":"user","content":[
{"type":"image_url","image_url":
{"url":"https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"}},
{"type":"text","text":"What is this image?"}
]}],
"model": "Qwen/Qwen2.5-VL-7B-Instruct",
"max_tokens": null,
"temperature": 1,
"top_p": 0.9,
"stream": false
}'import requests
import os
url = "https://inference.nebulablock.com/v1/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.environ.get('NEBULA_API_KEY')}"
}
data = {
"messages":[
{"role":"user","content":[
{"type":"image_url","image_url":
{"url":"https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"}},
{"type":"text","text":"What is this image?"}
]}],
"model":"Qwen/Qwen2.5-VL-7B-Instruct",
"max_tokens":None,
"temperature":1,
"top_p":0.9,
"stream":False
}
response = requests.post(url, headers=headers, json=data)
print(response.json())const url = "https://inference.nebulablock.com/v1/chat/completions";
const headers = {
"Content-Type": "application/json",
"Authorization": `Bearer sk-kmlKFCXGBZl-PS0MLnpzAw`
};
const data = {
messages: [
{"role":"user","content":[
{"type":"image_url","image_url":
{"url":"https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"}},
{"type":"text","text":"What is this image?"}
]}],
model: 'Qwen/Qwen2.5-VL-7B-Instruct',
max_tokens: null,
temperature: 1,
top_p: 0.9,
stream: false
};
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
console.log(JSON.stringify(data, null, 2));
})
.catch(error => console.error('Error:', error)); {
"id": "chatcmpl-7ba48f119a564f4ea02b6a41386a3e40",
"created": 1740689977,
"model": "Qwen/Qwen2.5-VL-7B-Instruct",
"object": "chat.completion",
"system_fingerprint": null,
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "This image shows ....",
"role": "assistant",
"tool_calls": null,
"function_call": null
}
}
],
"usage": {
"completion_tokens": 91,
"prompt_tokens": 3604,
"total_tokens": 3695,
"completion_tokens_details": null,
"prompt_tokens_details": null
},
"service_tier": null,
"prompt_logprobs": null
}{
"id": "chatcmpl-3812731562554b23a32dd80fbb7d0d09",
"created": 1740692435,
"model": "Qwen/Qwen2.5-VL-7B-Instruct",
"object": "chat.completion.chunk",
"choices": [
{
"index": 0,
"delta": {
"content": " setting"
}
}
]
}
{
...
}
...