Have an issuse but can't find the solution. (https://platform.openai.com/docs/guides/error-codes/api-errors)

I have an issue here:
"Run failed: OpenAI API hits BadRequestError: Error code: 400 - {‘error’: {‘code’: ‘OperationNotSupported’, ‘message’: 'The chatCompletion operation does not work with the specified model, gpt-4o. Please choose different model and try again. You can learn more about which models can be used with each operation here:

It gives me a link, but it’s not specific and so much information.
Can anyone guide me where is it?

Welcome to the dev community @Trong_Trobui

Can you please share the API call code that’s leading to this issue?

The API SDK method chatCompletion.create(), which might have been produced by asking an AI with obsolete knowledge, is indeed obsolete. The API SDK must also be updated in order to not block unknown models.

  1. Assuming Python 3.9 - Python 3.13 is being used
  2. Update the openai library module. At a command shell with rights to direct the installation to your current Python environment:
    pip install --upgrade openai tiktoken
  3. Use API reference code for making API calls, examples from “API reference” on the sidebar of this forum.

Or begin with a better example: a pattern you’ll want for making a responsive application:

import asyncio
from openai import AsyncOpenAI

async def stream_chat(prompt):
    '''example chat completions - only parses text response content
       directly employs environment variable OPENAI_API_KEY'''
    client = AsyncOpenAI(timeout=240)
    kwargs = {
        "model": "gpt-4.1-mini",
        "messages": [
          {"role": "developer", "content": "You are ChatAPI, an AI assistant."},
          {"role": "user", "content": prompt},
        ],
        "max_completion_tokens": 2000,
        "stream": True,
    }
    reply = ""

    async for chunk in await client.chat.completions.create(**kwargs):
        delta = chunk.choices[0].delta
        if delta.content:
            print(delta.content, end="", flush=True)  # streaming print function
            reply += delta.content  # gatherer for later
    return reply

if __name__ == "__main__":
    print("Chat Completions API call response:")
    try:
        asyncio.run(stream_chat("Write a haiki poem: AI friends"))
    except Exception as e:
        # real code would capture error type and branch
        raise