Playground gives unusable code examples for typescript api

The openai-node package validation blocks such requests:

export interface ChatCompletionSystemMessageParam {
/**

  • The contents of the system message.
    */
    content: string;

/**

  • The role of the messages author, in this case system.
    */
    role: ‘system’;

/**

  • An optional name for the participant. Provides the model information to
  • differentiate between participants of the same role.
    */
    name?: string;
    }

Better to just avoid constantly inferior and instantly out-of-date request-blocking code, and write your own request, which is successful.

import os, httpx, json

apikey = os.environ.get("OPENAI_API_KEY")
url = "https://api.openai.com/v1/chat/completions"
headers = {
    "OpenAI-Beta": "assistants=v2",
    "Authorization": f"Bearer {apikey}"
}
body = {
    "model": "gpt-4o-2024-05-13", "max_tokens": 25, "top_p": 0.8,
    "messages": [
        {"role": "system",
         "content": [{"type": "text", "text": "Hello robot"}]
        }
    ]}

try:
    response = httpx.post(url, headers=headers, json=body)
    response = response.json()
    print(json.dumps(response, indent=3))
except Exception as e:
    print(e)
    raise