Gemini 3.1 Pro API: What Can You Actually Do With a 1M-Token Context Window?
When a model's context window reaches 1 million tokens, what changes is not just a number — it is your application architecture. With google/gemini-3.1-pro-preview you can put hundreds of pages of documentation, an entire mid-sized codebase, or hours of meeting transcripts into a single request. Workloads that used to require chunking, summarization chains, and vector search collapse into one plain "prompt + data" call.
This article walks through what 1M tokens means in concrete terms, the usage patterns that actually benefit, the multimodal side of Gemini 3.1 Pro, and a Python quickstart. We will also be honest about when the far cheaper google/gemini-3.5-flash gets you the same result. All examples run through the Onysoft Gemini catalog — one OpenAI-compatible API that fronts 708+ models, so from Turkey or anywhere, you get Gemini alongside Claude, GPT, and DeepSeek with a single key and one billing account.
What Does 1 Million Tokens Actually Mean?
A token is the smallest unit a model processes; in English one token is roughly 0.75 words. At that scale, the 1M-token window of google/gemini-3.1-pro-preview translates into:
- Hundreds of pages of documents: roughly 700,000 English words — on the order of 1,500 pages of technical specs, contracts, or several thick books in a single request.
- An entire codebase: tens of thousands of lines of source code; a mid-sized microservice project in full, including tests and README files.
- Hours of transcripts: weeks of accumulated meeting notes or a whole season of podcast episodes as text.
The practical difference: pipelines you used to design as "split first, summarize each chunk, merge the summaries" collapse into one call. The model can see the definition on page 30 and the exception clause on page 900 at the same time — nothing gets lost between chunks. As a quick sizing heuristic, "file size in bytes divided by 4" gives you a workable first estimate of token count before you send anything.
Real Usage Patterns: Direct Context Instead of RAG
The most tangible payoff of a 1M window is skipping the RAG pipeline entirely in many scenarios. If your corpus fits under 1 million tokens, four separate problems — chunking strategy, embedding model choice, vector database ops, and retrieval quality — reduce to a single one: asking the right question.
- Large-document analysis: API contracts, regulations, technical specifications. Questions like "do these two sections contradict each other?" require seeing the whole document and are only reliable with full context.
- Whole-codebase review: hand over the entire repo and ask about architectural inconsistencies, dead code, or security risks; the model actually sees cross-file dependencies instead of guessing at them.
- Log and transcript querying: paste a day of error logs or a batch of customer-call transcripts and ask for patterns and root causes.
Is RAG dead? No — for archives with millions of documents or frequently changing data, retrieval remains essential. But the era of standing up a vector DB for a 50-file project is ending. You can try this without writing code: paste your content into the Playground and query it directly.
Multimodal Power: Not Just Text
Gemini 3.1 Pro's long context is not limited to text; the model handles multimodal input within the same window. Using the OpenAI-compatible message format, you can send images as content parts and combine them with text in a single request. Paired with 1M tokens of room, this opens up patterns that were previously awkward:
- Diagram plus code: put an architecture diagram image and the relevant source code in one request and ask "does the implementation match this diagram?"
- Screenshot-driven debugging: a screenshot of the broken UI, the component code, and the console logs in one context — the model reasons over all three together.
- Structured data from images: extract JSON from page images containing tables and charts.
- Long-recording analysis: hour-long meeting or support-call transcripts fit comfortably in the window as text.
Note that all of this is the understanding side. The same sk-ony- key also unlocks the generation side — veo3 for video, flux-2 for images — but that is a topic for another post.
Python Quickstart in 5 Minutes
Because Onysoft exposes an OpenAI-compatible API, your existing openai Python package works as-is; the only changes are base_url and the key. The example below sends a codebase dump for review in a single request:
from openai import OpenAI
client = OpenAI(
api_key="sk-ony-...", # your Onysoft key
base_url="https://api.onysoft.com/v1",
)
with open("repo_dump.txt", encoding="utf-8") as f:
codebase = f.read() # e.g. a ~600K-token codebase
stream = client.chat.completions.create(
model="google/gemini-3.1-pro-preview",
messages=[
{"role": "system",
"content": "You are a senior code-review assistant."},
{"role": "user",
"content": "List the security risks in this codebase "
"with file names and line ranges:\n\n" + codebase},
],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")For long-context requests we recommend stream=True: users get feedback the moment the first tokens arrive instead of staring at a spinner. The endpoint is POST /v1/chat/completions; full parameter reference lives in the API documentation.
When Is Flash Enough? The Cost Trade-off
Not every job needs 1M tokens and deep reasoning; defaulting to Pro is the most common budget mistake. A practical decision framework:
google/gemini-3.5-flash: summarization, classification, data extraction, high-volume automation. If your context is modest and the task resolves in one step, Flash usually delivers the same quality at a fraction of the cost.google/gemini-3.1-flash-lite: the most economical choice for micro-tasks like labeling and routing.google/gemini-3.1-pro-preview: full-window long-context work, multi-step reasoning, cross-file code analysis.
A pattern that works well in production: triage with Flash first, escalate only the cases that need deep analysis to Pro. If you want a 1M window with a different model character, the catalog also offers anthropic/claude-fable-5 with the same context size. Current pricing for every model is on the model catalog, and you can project your monthly bill against your own traffic in the cost calculator.
Frequently Asked Questions
How do I get access to the Gemini 3.1 Pro API through Onysoft?
Sign up on Onysoft AI Gateway, generate an sk-ony- key, and top up your balance — it is pure pay-as-you-go with no subscription. The API is OpenAI-compatible, so any existing SDK or tool that speaks the OpenAI format works immediately, and the same key covers 708+ models.
How many pages is 1 million tokens?
Roughly 700,000 English words, or on the order of 1,500 pages of text. For code that means tens of thousands of lines; for speech, hours of transcripts fit in the same window. A quick estimate: divide the file size in bytes by 4 to approximate the token count.
Does a 1M context window make RAG obsolete?
No. If your corpus fits under 1 million tokens, direct context is simpler and often more accurate; but for archives with millions of documents or frequently changing data, retrieval is still essential. In practice, hybrid setups are common: narrow down with retrieval, then analyze deeply with a wide context.
When should I use Gemini 3.5 Flash instead of Pro?
For summarization, classification, and high-volume single-step tasks, google/gemini-3.5-flash is usually sufficient and significantly cheaper. Switch to Pro for full-window long-context analysis and multi-step reasoning. A triage-with-Flash, escalate-to-Pro pattern works well; current pricing is on the /models page.
Will my existing OpenAI SDK code work with Gemini?
Yes. The Onysoft API is OpenAI-compatible: point base_url to https://api.onysoft.com/v1 and swap in your key. Set the model to google/gemini-3.1-pro-preview and chat completions work as before, including streaming — no rewrite needed.
Related pages
Ready to build?
Access 708+ AI models through a single API. Pay as you go — no subscription.