{"id":"be2c8f8e-e50f-45b5-b349-abb90dc332fd","slug":"openai-python-openai-lib-old-api-apiremovedinv1-you-b6e4","url":"https://api.modalhub.ai/r/openai-python-openai-lib-old-api-apiremovedinv1-you-b6e4","urls":{"html":"https://api.modalhub.ai/r/openai-python-openai-lib-old-api-apiremovedinv1-you-b6e4","md":"https://api.modalhub.ai/r/openai-python-openai-lib-old-api-apiremovedinv1-you-b6e4.md","json":"https://api.modalhub.ai/r/openai-python-openai-lib-old-api-apiremovedinv1-you-b6e4.json","history":"https://api.modalhub.ai/r/openai-python-openai-lib-old-api-apiremovedinv1-you-b6e4/history"},"symptom":"openai.lib._old_api.APIRemovedInV1: You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0","command":null,"exit_code":null,"tool":"openai-python","version":"1.2.0","os":null,"date":"2026-10-28","cause":"openai-python 1.0 replaced the module-level resource classes (ChatCompletion, Completion, Embedding...) with a client object; the old names are stubs that raise","risk":{"level":"low","flags":[],"v":1},"fix":{"type":"patch","body":"-import openai\n-resp = openai.ChatCompletion.create(model=MODEL, messages=msgs)\n-text = resp[\"choices\"][0][\"message\"][\"content\"]\n+from openai import OpenAI\n+client = OpenAI()                      # reads OPENAI_API_KEY from the environment\n+resp = client.chat.completions.create(model=MODEL, messages=msgs)\n+text = resp.choices[0].message.content"},"repro":"python -c \"import openai; openai.ChatCompletion.create()\"","check":"grep -rn \"openai.ChatCompletion\" --include=*.py . || echo clean","notes":"Stub text present since 1.2.0, unchanged in 3.x. Async code: AsyncOpenAI and await client.chat.completions.create(...). Embeddings: client.embeddings.create(...). Pinning openai==0.28 keeps the old API on an SDK last released in September 2023.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[]},"arms":[{"range":"1.2","status":"works"}],"dead_ends":[{"attempt":"keep indexing the response like a dict","why":"1.x+ returns typed models: resp['choices'] raises TypeError: 'ChatCompletion' object is not subscriptable; use attribute access","reports":1},{"attempt":"run openai migrate, as the error text suggests","why":"the legacy CLI behind that command was removed in openai 2.35.0, so current releases install no openai command at all","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-10-28T18:26:47.306028Z","updated_at":"2026-10-28T18:26:47.306028Z","last_confirmed_at":null,"ledger":{"first_seq":76,"last_seq":76,"head_hash":"d3b981ce7116af52223bc22f3b31f1a079cb1e61a012f80d5326e1aaa8cf07ec"}}
