1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const axios = require('axios');
const fs = require('fs');
const path = require('path');
// helper function to help you convert your local images into base64 format
async function toB64(imgPath) {
const data = fs.readFileSync(path.resolve(imgPath));
return Buffer.from(data).toString('base64');
}
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/gemini-1.5-pro";
const data = {
"messages": [
{
"role": "user",
"content" : "tell me a joke on cats"
},
{
"role": "assistant",
"content" : "here is a joke about cats..."
},
{
"role": "user",
"content" : "now a joke on dogs"
},
]
};
(async function() {
try {
const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } });
console.log(response.data);
} catch (error) {
console.error('Error:', error.response.data);
}
})();
An array of objects containing the role and content
Could be "user", "assistant" or "system".
A string containing the user's query or the assistant's response.
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.
Gemini 1.5 Pro is a powerful multimodal large language model from Google DeepMind. It's known for its long-context understanding capability across different formats like text, images, audio and video. Here's a breakdown of its key features:
Long context understanding: Unlike previous models, Gemini 1.5 Pro boasts a massive context window of up to two million tokens, allowing it to process and understand vast amounts of information at once. This could be text documents containing over 700,000 words, hours of audio or video, or codebases with tens of thousands of lines.
Mulitmodal capabilities: It can handle complex reasoning tasks using various data types, including text, images, audio, and video. Imagine showing it a hand-drawn sketch and asking it to identify the scene from a specific movie!
Scalability: Gemini 1.5 Pro is a mid-sized model that excels at handling a wide range of tasks, similar to Google's previous, larger model, 1.0 Ultra. This makes it a versatile tool for various applications.
Overall, Gemini 1.5 Pro represents a significant leap in large language model technology, offering exceptional understanding and performance across different modalities and contexts.