Astra 输入超过 272K:加价门槛怎么记进三列
gpt-6-astra 的 272K 是加价门槛,不是上下文窗口(窗口 1,050,000)。prompt 超过 272K:输入/缓存 2×,输出 1.5×。只打印官方 usage;倍率写备注,不改表头三列。
本页不发起请求;不收 Key;中转 curl 不在本站。
← 计费示例 · Token 主表 · 官方 usage 文档
输入usage.prompt_tokens
输出usage.completion_tokens
缓存usage.prompt_tokens_details.cached_tokens
surcharge_threshold · 272_000 是加价线,不是窗口。上下文 1,050,000。门槛写备注,不要覆盖三列。
import os
from openai import OpenAI
# 272_000 is a PRICE threshold, not the context window.
# gpt-6-astra context is 1,050,000 tokens (max output 128,000).
# Prompt >272K: input and cache 2×, output 1.5× for the FULL request.
# Table header stays $10 / $50; write the multiplier in a note.
THRESHOLD = 272_000
CONTEXT_WINDOW = 1_050_000
# Key from env only. Never paste a key here.
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
completion = client.chat.completions.create(
model="gpt-6-astra",
messages=[{"role": "user", "content": "Reply with one word: ok"}],
)
usage = completion.usage
prompt = usage.prompt_tokens if usage else 0 # 输入
out = usage.completion_tokens if usage else 0 # 输出
details = usage.prompt_tokens_details if usage else None
cached = (details.cached_tokens or 0) if details else 0 # 缓存
surcharge = prompt > THRESHOLD
input_mult = 2.0 if surcharge else 1.0
cache_mult = 2.0 if surcharge else 1.0
output_mult = 1.5 if surcharge else 1.0
print("输入", prompt)
print("输出", out)
print("缓存", cached)
print("context_window", CONTEXT_WINDOW) # not 272K
print("surcharge_threshold", THRESHOLD)
print("input_mult", input_mult)
print("cache_mult", cache_mult)
print("output_mult", output_mult)
| 字段 | 对上列 | 说明 |
|---|---|---|
usage.prompt_tokens | 输入 | 对账乘本站 Astra「输入」$/M。超过 272K 时整单输入 2×,不改表头 $10。 |
usage.completion_tokens | 输出 | 对账乘「输出」$/M。超过 272K 时整单输出 1.5×,不改表头 $50。 |
usage.prompt_tokens_details.cached_tokens | 缓存 | 缓存读跟输入一起加价:超过 272K 时 2×。没有 details 就当 0。 |
surcharge_threshold | — | 272_000 是加价线,不是窗口。上下文 1,050,000。门槛写备注,不要覆盖三列。 |