Introduction
OpenAI-compatible chat for Gemini 3.1 Pro Preview. A 1,000,000-token read window, three reasoning-effort levels, 128 tool schemas and JSON output on one synchronous call.
Gemini 3.1 Pro Preview is Google's long-context chat model, published as a single OpenAI-compatible endpoint. It reads up to 1,000,000 tokens and replies in up to 32,768 - about thirty to one, so the whole bible and the full history go in and one consistent turn comes back.
Key features & highlights
Reads a shelf, writes a paragraph
1,000,000 tokens in and 32,768 out is about thirty to one, and the ratio is the instruction manual. Attach the bible, the character sheets and every chapter written so far, then ask for one reply that moves the scene forward. What comes back is short by design and consistent with every page you sent.
The history rides along uncompressed
Long roleplay drifts mostly because the history has to be summarised to fit. A 1,000,000-token window usually deletes that step: re-send the original text every turn and the detail planted thirty chapters ago is still in front of the model instead of buried in a paraphrase of itself.
It can change without notice
A preview model's lifecycle belongs to Google. Behaviour, availability and price can all move, and it can be withdrawn. Before it carries a production thread, decide which model that thread falls back to.
Request parameters
| Parameter | Required | Description |
|---|---|---|
messages | Yes | Ordered conversation turns. Content is a string, or an array of text and |
max_tokens | No | Caps the reply at 32,768 - a thirtieth of the read window. Default 16,384. |
reasoning_effort | No | minimal, low, medium or high. Medium is the default: drop to low for routine turns, raise to high when the model has to weigh the history or hunt for contradictions. |
stop | No | Up to 4 sequences, as a string or an array. The reply ends as soon as the model writes one of them, and the matched text itself is left out. at least 1 characters · at least 1 items · at most 4 items |
seed | No | Any integer. |
temperature | No | 0 to 2, default 1. |
top_p | No | 0.01 to 1. Adjust this or temperature, never both in the same comparison. |
tools | No | Up to 128 function definitions per request. at most 128 items |
tool_choice | No | auto, none, required, or an object naming one function. |
response_format | No | Ask for a JSON object and name every key in the system message. |
Pricing
Input $1.90 / Output $11.40 per 1 million tokens; Prompts over 200K tokens: Input $3.80 / Output $17.10
Above 200,000 input tokens, long-context rates apply to the whole request.
Use cases
Continue a scene inside 300,000 words of context
Send the bible, the relationship map and every chapter written so far, then ask for a single turn. Nothing was retrieved or sampled, so a promise made in the first act is still visible while the model writes the third.
Continuity audit across chapters
Put the world rules and the finished chapters in the same request and ask which passages contradict them. What comes back is a list of conflicts with citations rather than a rewrite - a long read with a short answer, which is exactly this ratio's home ground.
One judgement on a very large document set
Load a full specification set, a quarter's worth of tickets or an entire mailbox into one call and ask what actually changed. A 32,768-token reply is plenty for the finding and the citations behind it.
Character state as JSON for your app
Ask for each character's current position, injuries, relationships and known secrets as a JSON object: response_format set to json_object, with every key named in the system message. Your save file stays in sync with the prose without a rescue parser.
Prompt guide & pro tips
Rules in system, story in user
Put the world rules, the voice you want and the length of this turn in the system message. Put the bible, the relationship map and the history in one user message, oldest first, and finish with the instruction for this turn.
Re-send the whole history, do not summarise it
The window holds 1,000,000 tokens, usually more than a finished novel. Re-sending the original text each turn does cost input tokens, but it is the cheapest continuity you can buy: nothing is lost to a paraphrase.
Limits to plan around
The reply ceiling is 32,768 tokens - about a thirtieth of the read window - so a request that asks for a complete chapter hits the cap before it finishes, and max_tokens above that fails validation outright. Message content is text and images; video and audio parts are rejected. This is a preview model: Google can change its behaviour or withdraw it, so decide which model takes over before it carries production traffic. A JSON response_format shapes the reply but your application still parses and validates it.
API quick start
curl --fail-with-body -sN https://api.spicyapi.ai/v1/chat/completions \
-H "Authorization: Bearer $SPICY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "google/gemini-3.1-pro-preview/chat",
"messages": [
{
"role": "user",
"content": "Summarise the following release notes into three bullet points."
}
],
"stream": true
}' \
| jq --unbuffered -Rrj 'select(startswith("data: ")) | .[6:] | select(. != "[DONE]") | fromjson | if .error then "\n[error] \(.error.message)\n" else (.choices[0].delta.content? // empty) end'
See the API reference for authentication, the complete schema, polling, and error handling.












