GPT-6.1 Terra API: Python and JavaScript Code, Flex Pricing
Run GPT-6.1 Terra through the API with Python or JavaScript. See invoice extraction code, pricing for Standard, Flex and Fast, and my benchmark results.
👁 113 reads
GPT-6.1 Terra is available through the OpenAI API as gpt-6.1-terra and on OpenRouter as openai/gpt-6.1-terra. Below is Python and JavaScript code I ran on October 26, 2026, to extract invoice data into a fixed JSON schema and generate a short email text. I also measured three OpenAI modes on OpenRouter. In my test, processing one invoice cost $0.00097 in Standard mode and $0.00049 with Flex, which was also faster in that run.
At a glance (as of October 26, 2026)
- Model names:
gpt-6.1-terra(OpenAI),openai/gpt-6.1-terra(OpenRouter). - OpenAI endpoints: Responses, Chat Completions and Batch. Tools (computer use, search and files) are available only in Responses.
- Pricing: $1 / $5 per million tokens; Flex and Batch $0.50 / $2.50; Fast $2 / $10.
- My test (invoice to JSON, 5 calls per mode): Standard 2.79 s, Flex 1.76 s, Fast 1.91 s - all 15 responses were correct.
What GPT-6.1 Terra can do through the API
| Parameter | Value |
|---|---|
| Context window | 1,050,000 tokens (maximum 922,000 input tokens) |
| Maximum output | 128,000 tokens |
| Input / output | Text and images / text |
| Knowledge cutoff | June 1, 2026 |
| Reasoning levels | none, low, medium (default), high, xhigh, max |
| Not available | Realtime, Assistants, fine-tuning, audio |
| Limits (Build) | 5,000 requests and 1 million tokens per minute |
Details from the model page in OpenAI’s documentation, checked October 26, 2026. Tools available through the Responses API include web_search, file_search, code_interpreter, computer_use, mcp and apply_patch. If you’re setting up an API account for the first time, see my guide to the OpenAI API key, pricing and your first request.
Python: extract invoice data to JSON
OpenAI lists invoice reading as one use case for Terra, so I started there. The input was a Polish-language invoice from a print shop to a clinic, with an invoice number, dates, tax identifiers containing hyphens, three line items and amounts. The output must match a JSON schema: with "strict": True, the model cannot add or omit fields. I use the requests library and OpenRouter for all my tests. The code and displayed test material below are in English; the test itself was run in Polish, and the translated examples are not a new English-language test:
import os, json, requests
URL = ("https://openrouter.ai/api/v1"
"/chat/completions")
KEY = os.environ["OPENROUTER_API_KEY"]
schema = {
"type": "object",
"properties": {
"number": {"type": "string"},
"date": {"type": "string"},
"seller_tax_id": {"type": "string"},
"items": {"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"net": {"type": "number"}},
"required": ["name", "net"],
"additionalProperties": False}},
"gross": {"type": "number"},
"due_date": {"type": "string"}},
"required": ["number", "date",
"seller_tax_id", "items",
"gross", "due_date"],
"additionalProperties": False}
def invoice(text, mode="openai"):
body = {
"model": "openai/gpt-6.1-terra",
"messages": [
{"role": "system", "content":
"Extract data from invoices. Dates"
" must use YYYY-MM-DD format; remove"
" hyphens from the seller tax ID."},
{"role": "user",
"content": text}],
"reasoning": {"effort": "low"},
"response_format": {
"type": "json_schema",
"json_schema": {"name": "invoice",
"strict": True,
"schema": schema}},
"provider": {"only": [mode]},
"usage": {"include": True}}
r = requests.post(URL, json=body,
timeout=120, headers={
"Authorization": f"Bearer {KEY}"})
r.raise_for_status()
j = r.json()
msg = j["choices"][0]["message"]
data = json.loads(msg["content"])
return data, j["usage"]
Translated excerpt from the original Polish test invoice: “Seller: Lipa Print Studio LLC (…) Tax ID 946-27-18-305,” “Issue date: 2026-10-26,” and “Payment due: 2026-11-09.” This is a translation of the Polish test material, not a separately run English test. Terra’s response, shortened by omitting two line items:
{
"number": "FV/10/2026/118",
"date": "2026-10-26",
"seller_tax_id": "9462718305",
"items": [
{"name": "A5 flyers, 170 gsm",
"net": 950.0}, ...],
"gross": 1923.72,
"due_date": "2026-11-09"
}
The model converted the dates to ISO format, removed the hyphens from the tax ID, and took the gross amount from the “amount due: 1,923.72” line, converting the decimal comma to a decimal point. Usage: 384 input tokens, 120 output tokens, $0.000984. Processing 1,000 such invoices would cost about $0.98.
Three parameters worth copying:
"reasoning": {"effort": "low"}- low is enough for extracting fields. Medium would use more reasoning tokens, which are billed at the output rate. See my comparison of GPT-6.1 Terra reasoning levels: low, medium or max."provider": {"only": ["openai"]}- without this, OpenRouter may route the request to another endpoint. Here, you can selectopenai,openai/flexoropenai/fast."usage": {"include": True}- the response includes the cost in dollars, so you don’t have to calculate it yourself.
Standard vs. Flex vs. Fast: benchmark results
On OpenRouter, Terra has three OpenAI endpoints. I sent the same invoice five times to each, sequentially, on October 26, 2026, at around 21:45:
| Mode | Price (USD per 1 million tokens) | Median time | Cost per invoice |
|---|---|---|---|
Standard (openai) |
$1 / $5 | 2.79 s | $0.000972 |
Flex (openai/flex) |
$0.50 / $2.50 | 1.76 s | $0.000492 |
Fast (openai/fast) |
$2 / $10 | 1.91 s | $0.001944 |
All 15 responses had the correct tax ID and gross amount. Flex was fastest, but this was just five calls on the evening of October 26; the ranking could change with different workloads. Fast costs twice as much as Standard and wasn’t faster than Flex in my test. For background processing, I’d choose Flex or Batch (the same $0.50 / $2.50 price); for live responses, Standard.
JavaScript: generate email subject lines
Here’s the same model in Node.js (version 18 or later includes fetch), this time using Flex and the medium reasoning level. The prompt below is a translation of the Polish test prompt, not a new English-language test:
const URL = "https://openrouter.ai" +
"/api/v1/chat/completions";
const KEY =
process.env.OPENROUTER_API_KEY;
const r = await fetch(URL, {
method: "POST",
headers: {
"Authorization": `Bearer ${KEY}`,
"Content-Type": "application/json"},
body: JSON.stringify({
model: "openai/gpt-6.1-terra",
reasoning: { effort: "medium" },
provider: { only: ["openai/flex"] },
usage: { include: true },
messages: [{ role: "user", content:
"Write 3 email subject lines " +
"reminding the recipient to pay " +
"invoice FV/10/2026/118 for " +
"$489.57. No exclamation marks." }]
})});
const j = await r.json();
const msg = j.choices[0].message;
console.log(msg.content);
Terra’s response, translated from the Polish-language test:
1. Reminder: invoice FV/10/2026/118
for $489.57
2. Please pay invoice
FV/10/2026/118
3. Payment of $489.57 - invoice
FV/10/2026/118
47 input tokens, 77 output tokens, $0.000216. The response had no exclamation marks, and every subject line included the invoice number and amount.
What to watch for in your API bill
- The 272,000-token threshold. If a request has more input tokens than this, the whole request is billed at $2 for input and $7.50 for output. Consider splitting long documents.
- Prompt caching. Repeated prompt prefixes (for example, the same schema and instructions) cost $0.05 per million tokens instead of $1.
- Regional processing (keeping data in a selected region) adds 10% to the price.
For Terra’s pricing, see GPT-6.1 Terra pricing. My guide to GPT-6.1 Terra includes results from tasks tested in Polish.
Frequently asked questions
What is the GPT-6.1 Terra API model name?
It’s gpt-6.1-terra in the OpenAI API and openai/gpt-6.1-terra on OpenRouter. The dated version on OpenRouter is openai/gpt-6.1-terra-20261026.
Does Terra work with Chat Completions?
Yes, as well as Responses and Batch. Tools, including computer use and web search, require the Responses API.
How much does it cost to process one invoice with Terra?
In my test, it cost $0.000972 in Standard mode and $0.000492 with Flex, with about 380 input tokens and 120 output tokens at the low reasoning level.
Google · Your sourcesQuantslant higher in your Google - one clickAdd to preferred sources →Sources and test date
- OpenAI API: GPT-6.1 Terra model - endpoints, tools, context, limits and pricing (checked October 26, 2026)
- OpenAI: Introducing GPT-6.1 Terra - invoice reading as a use case (checked October 26, 2026)
- OpenRouter: GPT-6.1 Terra endpoints - openai, openai/flex and openai/fast modes and pricing (checked October 26, 2026)
- My test: Python 3.13 + requests, Node.js 26, OpenRouter, October 26, 2026, around 21:40-21:50


