Text Completion
Simple text-based chat completion:Copy
Ask AI
import createRvencClient from "./index";
const client = await createRvencClient({
apiKey: "your-api-key",
});
const response = await client.chat.completions.create({
model: "openai/gpt-oss-120b",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Explain quantum computing in simple terms" }
],
});
console.log(response.choices[0].message.content);
Image Analysis
Analyze and describe images in detail:Copy
Ask AI
const response = await client.chat.completions.create({
model: "OpenGVLab/InternVL3-38B",
messages: [{
role: "user",
content: [
{ type: "text", text: "Describe this image in detail" },
{
type: "image_url",
image_url: {
url: "https://docs.cci.prem.io/docs/images/examples/basic.jpg",
},
},
],
}],
});
console.log(response.choices[0].message.content);
Document & Chart Intelligence with JSON Output
Extract structured data from charts, invoices, or reports:Copy
Ask AI
const response = await client.chat.completions.create({
model: "OpenGVLab/InternVL3-38B",
messages: [{
role: "user",
content: [
{
type: "text",
text: `Analyze this sales chart and return the data in JSON format:
{
"chart_type": "...",
"key_findings": ["...", "..."],
"data_points": [{"label": "...", "value": "..."}],
"trends": "..."
}`
},
{
type: "image_url",
image_url: {
url: "https://docs.cci.prem.io/docs/images/examples/sales-chart.png",
},
},
],
}],
response_format: { type: "json_object" },
});
const data = JSON.parse(response.choices[0].message.content || "{}");
console.log(data);
Receipt & Invoice Processing
Extract and structure financial information from receipts:Copy
Ask AI
const response = await client.chat.completions.create({
model: "OpenGVLab/InternVL3-38B",
messages: [{
role: "user",
content: [
{
type: "text",
text: `Extract all information from this receipt and format as JSON:
{
"merchant_name": "...",
"date": "YYYY-MM-DD",
"items": [{"name": "...", "quantity": 1, "price": 0.00}],
"subtotal": 0.00,
"tax": 0.00,
"total": 0.00,
"payment_method": "..."
}`
},
{
type: "image_url",
image_url: { url: "https://docs.cci.prem.io/docs/images/examples/invoice.png" },
},
],
}],
response_format: { type: "json_object" },
});
const data = JSON.parse(response.choices[0].message.content || "{}");
console.log(data);
Product Catalog Automation
Generate structured product information from images:Copy
Ask AI
const response = await client.chat.completions.create({
model: "OpenGVLab/InternVL3-38B",
messages: [{
role: "user",
content: [
{
type: "text",
text: `Analyze this product image and generate catalog data in JSON:
{
"product_category": "...",
"attributes": {"color": "...", "material": "...", "style": "..."},
"target_audience": "...",
"suggested_tags": ["...", "..."],
"description": "..."
}`
},
{
type: "image_url",
image_url: { url: "https://docs.cci.prem.io/docs/images/examples/tshirt.png" },
},
],
}],
response_format: { type: "json_object" },
});
const data = JSON.parse(response.choices[0].message.content || "{}");
console.log(data);
Image-Based Question Answering
Ask specific questions about any image:Copy
Ask AI
import fs from "fs";
const imagePath = "./scene.jpg";
const base64Image = fs.readFileSync(imagePath, "base64");
const response = await client.chat.completions.create({
model: "OpenGVLab/InternVL3-38B",
messages: [{
role: "user",
content: [
{
type: "text",
text: "How many people are in this image and what are they doing?"
},
{
type: "image_url",
image_url: { url: `data:image/jpeg;base64,${base64Image}` },
},
],
}],
});
console.log(response.choices[0].message.content);
Multi-Image Comparison Analysis
Compare multiple images for quality control or change detection:Copy
Ask AI
const response = await client.chat.completions.create({
model: "OpenGVLab/InternVL3-38B",
messages: [{
role: "user",
content: [
{
type: "text",
text: "Compare these before/after images and identify all changes."
},
{
type: "image_url",
image_url: { url: "https://docs.cci.prem.io/docs/images/examples/before.png" },
},
{
type: "image_url",
image_url: { url: "https://docs.cci.prem.io/docs/images/examples/after.png" },
},
],
}],
});
console.log(response.choices[0].message.content);
Streaming Vision Analysis
Stream responses for real-time creative content generation:Copy
Ask AI
const stream = await client.chat.completions.create({
model: "OpenGVLab/InternVL3-38B",
messages: [{
role: "user",
content: [
{
type: "text",
text: "Create an engaging social media caption for this image"
},
{
type: "image_url",
image_url: { url: "https://example.com/image.jpg" },
},
],
}],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}

