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-3.1-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 3.1 Pro is Google DeepMind's most capable reasoning model, designed for complex, multi-step problem solving across text, image, audio, video, and code. It represents Google's frontier in AI performance — scoring 77.1% on ARC-AGI-2, more than double the score of its predecessor Gemini 3 Pro, making it one of the most capable reasoning models available. Whether you're processing long documents, analyzing visual data, or orchestrating agentic workflows, Gemini 3.1 Pro delivers the depth and accuracy required for high-stakes tasks.
Gemini 3.1 Pro excels in scenarios where reasoning depth and accuracy matter more than speed or cost. Developers use it for document intelligence — extracting insights from dense technical reports or legal filings. It handles complex code generation, debugging, and architecture review with high accuracy. Research and analysis workflows benefit from its ability to synthesize information across modalities. It's also the top choice for agentic pipelines that require multi-step planning, tool orchestration, and adaptive decision-making.
Gemini 3.1 Pro responds best to structured, specific prompts. For complex reasoning tasks, break your prompt into numbered steps or sub-questions. When using image inputs, describe what aspect of the image you want analyzed. For agentic tasks, provide clear role definitions, constraints, and expected output formats (e.g., JSON schema). The model handles long system prompts well — including context, examples, and output templates directly in the prompt significantly improves consistency.
What makes Gemini 3.1 Pro different from Gemini 3.1 Flash? Gemini 3.1 Pro prioritizes reasoning depth and accuracy, while Flash prioritizes speed and cost-efficiency. Pro is the right choice when correctness matters more than latency.
Does Gemini 3.1 Pro support image inputs? Yes. The model accepts image URLs alongside text prompts, enabling visual analysis, OCR, diagram interpretation, and multimodal reasoning.
Is Gemini 3.1 Pro suitable for agentic workflows? Absolutely. It is specifically optimized for complex multi-step agentic tasks including tool use, planning, and long-horizon reasoning.
What is the context window size? Gemini 3.1 Pro supports a very large context window, making it suitable for processing entire codebases, books, or lengthy research documents.
How does it compare to OpenAI GPT or Claude models? On ARC-AGI-2, Gemini 3.1 Pro achieves 77.1%, placing it among the top frontier reasoning models. It is competitive with leading models from OpenAI and Anthropic on complex benchmarks.
What output formats does it support? The model outputs structured text, markdown, JSON, code in multiple languages, and detailed analytical responses based on prompt instructions.