Skip to content

Responses WebSocket (/v1/responses) closes with code 1000 and no events when temperature is a decimal (e.g., 1.2) #2919

@seongho-park-playmore

Description

@seongho-park-playmore

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

response.create over Responses WebSocket (wss://api.openai.com/v1/responses) closes immediately with code 1000 and no events when temperature is a decimal (e.g. 1.2).

Expected: decimal numeric sampling values should be accepted (docs say temperature is numeric).
Actual: connection closes with 1000, empty reason, and no events.

To Reproduce

  1. Open a WebSocket connection to wss://api.openai.com/v1/responses
  2. Send this payload:
    • type: "response.create"
    • model: "gpt-4.1-mini"
    • input: one simple user message ("hello")
    • temperature: 1.2
  3. Observe connection close behavior.

Minimal script:

import asyncio
import json
import websockets

API_KEY = "YOUR_API_KEY"
URL = "wss://api.openai.com/v1/responses"
MODEL = "gpt-4.1-mini"

async def run(temp):
async with websockets.connect(
URL,
additional_headers={"Authorization": f"Bearer {API_KEY}"},
) as ws:
payload = {
"type": "response.create",
"model": MODEL,
"input": [{
"type": "message",
"role": "user",
"content": [{"type": "input_text", "text": "hello"}],
}],
"temperature": temp,
}
await ws.send(json.dumps(payload))

      events = []
      try:
          async for raw in ws:
              ev = json.loads(raw)
              events.append(ev.get("type"))
              if ev.get("type") in {"response.completed", "response.incomplete", "response.failed", "error"}:
                  break
      except websockets.ConnectionClosed:
          pass

      print("temp:", repr(temp))
      print("close_code:", ws.close_code)
      print("close_reason:", repr(ws.close_reason))
      print("events:", events)

asyncio.run(run(1.2)) # closes 1000, events=[]
asyncio.run(run(1)) # works
asyncio.run(run("1.2")) # error event: invalid_type

Code snippets

OS

masOS

Python version

3.12.12

Library version

openai==2.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions