Python

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。门槛写备注,不要覆盖三列。

Python
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)
这段打印对上哪一列 · Python · 输入 / 输出 / 缓存
字段对上列说明
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。门槛写备注,不要覆盖三列。

其它片段

语言片段对上列打开
PythonChat Completions 的 usage 怎么对上输入 / 输出 / 缓存输入 / 输出 / 缓存打开
JavaScriptResponses API 的 usage 怎么对上输入 / 输出列输入 / 输出 / 缓存打开
PythonPrompt Cache 片段:命中率不够就别指望折扣输入 / 输出 / 缓存打开
PythonAnthropic 缓存读:cache_read 对上缓存列输入 / 输出 / 缓存打开
JavaScriptAzure 部署名不是 OpenAI model id:usage 仍按部署背后的型号输入 / 输出 / 缓存打开

本页拒绝 zip 安装包与 API Key 表单。片段只从环境变量读 Key(OPENAI_API_KEY / ANTHROPIC_API_KEY / AZURE_OPENAI_API_KEY),页面不发请求、不收密钥;中转 curl、测速和请求构造器不在本站。

Astra 输入超过 272K:加价门槛怎么记进三列 · OpenAICN