openai / openai/openai-python

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

Open
#2,919 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
31.6k
Forks
5.7k
Avg merge
1d 6h
Merged PRs (30d)
96

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal WebSocket reproduction against /v1/responses with temperatures 1.2, 1, and "1.2", recording close codes and received events. Trace the Python Responses WebSocket request path to find where decimal sampling values are handled; done means a decimal value produces the expected response events instead of an immediate empty close.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.