POST
javascript
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); } })();
RESPONSE
application/json
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


messagesArray

An array of objects containing the role and content


rolestr

Could be "user", "assistant" or "system".


contentstr

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 — Advanced Multimodal Reasoning Model

What is Gemini 3.1 Pro?

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.

Key Features

  • Natively multimodal: accepts and reasons over text, images, audio, video, and entire code repositories in a single prompt
  • Massive context window: handles large documents and complex conversations without losing context
  • Advanced reasoning: state-of-the-art performance on PhD-level benchmarks including GPQA Diamond and Humanity's Last Exam
  • Agentic-ready: optimized for multi-step tool use, planning, and autonomous task execution
  • Multimodal output: produces structured text, code, and analysis from mixed-media inputs

Best Use Cases

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.

Prompt Tips and Output Quality

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.

FAQs

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.