OpenAI

gpt-realtime-2.1-mini API 价格与接入

实时语音对话

Model ID: gpt-realtime-2.1-mini · 目录更新: 2026-11-04

目录基础价格

文本输入
$0.60
/ 1M tokens
音频输入
$10.00
/ 1M tokens
图片输入
$0.80
/ 1M tokens
文本输出
$2.40
/ 1M tokens
音频输出
$20.00
/ 1M tokens
-

账户折扣与最终结算以控制台为准。

模型参数与协议

上下文窗口
128,000 tokens
最大输出
32,000 tokens
计费类型
composite
公开协议
/v1/realtime

调用限制与工具支持

协议出现在目录中不代表所有参数和托管工具都受支持。图片输入、推理强度、结构化输出及工具执行能力随模型和渠道变化;应先以小请求验证。多轮工具调用需保留正确的历史和会话上下文。

工具调用与会话指南

调用示例

完整调用示例

按模型公开能力生成代码。切换协议、语言或 Provider 后,代码会同步更新。

仅展示已支持协议
协议
语言
pip install websockets
Realtime · VoicePython默认 Provider
Realtime · Voice · Python
import asyncio, base64, json, os
from websockets.asyncio.client import connect

async def main():
    headers = {"Authorization": "Bearer " + os.environ["GR_API_KEY"]}
    async with connect("wss://endpoint.greatrouter.com/v1/realtime?model=gpt-realtime-2.1-mini", additional_headers=headers) as ws:
        async def send(event):
            await ws.send(json.dumps(event))
        async for raw in ws:
            event = json.loads(raw)
            if event["type"] == "session.created":
                await ws.send("{\"type\":\"session.update\",\"session\":{\"type\":\"realtime\",\"output_modalities\":[\"text\"]}}")
            elif event["type"] == "session.updated":
                await send({"type": "conversation.item.create", "item": {"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Say hello."}]}})
                await send({"type": "response.create"})
            if event["type"] == "error":
                raise RuntimeError(event["error"].get("message", "Realtime error"))
            print(event)
            if event["type"] == "response.done":
                break

asyncio.run(main())