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-flash-lite"; 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 Flash Lite — High-Volume, Low-Latency Multimodal Model

What is Gemini 3.1 Flash Lite?

Gemini 3.1 Flash Lite is Google DeepMind's fastest and most cost-efficient model in the Gemini 3 series — engineered for developers who need to run millions of AI requests at scale without breaking the budget. Launched in March 2026, it delivers 2.5x faster Time to First Token versus Gemini 2.5 Flash and a 45% increase in output speed, while matching Gemini 2.5 Flash on quality across key benchmarks. With a 1 million token context window and full multimodal support, Flash Lite punches well above its price point.

Key Features

  • Ultra-low cost: $0.313 per million input tokens — ideal for high-throughput pipelines
  • Blazing speed: 2.5x faster Time to First Answer Token than Gemini 2.5 Flash, with 45% faster output generation
  • 1M token context window: process entire books, large codebases, or long conversation histories in a single call
  • Multimodal: accepts text and image inputs natively
  • Thinking levels: supports minimal, low, medium, and high thinking budgets for fine-grained cost/quality control
  • Structured output: ~97% compliance in structured output benchmarks, ideal for extraction and classification pipelines
  • Strong benchmarks: 86.9% on GPQA Diamond, 76.8% on MMMU Pro

Best Use Cases

Flash Lite is the go-to model for high-volume, latency-sensitive applications. Content moderation pipelines that process millions of user-generated posts per day benefit from its speed and low cost. Translation services requiring near-real-time throughput are a natural fit. Classification tasks — sentiment analysis, intent routing, topic tagging — run efficiently at scale. It also handles customer service summarization, form extraction, and RAG-based Q&A over large document sets. Teams building agentic systems use it as an orchestration layer, where it achieves ~94% intent routing accuracy with sub-10 second completions.

Prompt Tips and Output Quality

Flash Lite responds best to direct, clear prompts. For classification or extraction tasks, provide a schema or list of expected labels directly in the prompt. Use the model's thinking levels to tune cost vs. quality: for simple tasks like keyword extraction, use "minimal" thinking; for nuanced reasoning like intent classification, use "medium." When processing images, specify the exact output format — "Return a JSON object with: detected_objects, confidence_scores" — to maximize the ~97% structured output compliance rate.

FAQs

How does Gemini 3.1 Flash Lite compare to 2.5 Flash? Flash Lite is 2.5x faster in TFAT and 45% faster in output speed while matching or exceeding 2.5 Flash quality on key benchmarks — at a lower price point.

Does it support image inputs? Yes. You can send an image URL alongside your text prompt for multimodal tasks like OCR, visual classification, and image-based Q&A.

What is the context window size? 1 million tokens — enough to process entire books, large codebases, or months of chat history in a single request.

Is it suitable for real-time applications? Yes. Its sub-10 second completion times and near-instant streaming make it well suited for real-time chat, live moderation, and interactive applications.

What are thinking levels? Thinking levels (minimal, low, medium, high) control how much internal reasoning the model performs before responding — letting you tune cost and latency vs. output quality per request.

When should I use Flash Lite vs. Flash vs. Pro? Flash Lite: high-volume, cost-sensitive tasks where speed matters most. Flash: balanced speed/quality for general developer use. Pro: complex reasoning where accuracy is paramount.