Skip to content

OpenAI

openai is the OpenAI chat model provider. It uses the OPENAI_API_... environment variables.

  1. Upgrade your account to get access to the models. You will get 404s if you do not have a paying account.

  2. Create a new secret key from the OpenAI API Keys portal.

  3. Update the .env file with the secret key.

    .env
    OPENAI_API_KEY=sk_...
  4. Find the model you want to use from the OpenAI API Reference or the OpenAI Chat Playground.

    Screenshot of a user interface with a sidebar on the left and a dropdown menu titled 'Chat' with various options for AI models. The 'gpt-4o' option is highlighted and selected with a checkmark, described as 'High-intelligence flagship model for complex, multi-step tasks'.
  5. Set the model field in script to the model you want to use.

    script({
    model: "openai:gpt-4o",
    ...
    })

You can enable the genaiscript:openai and genaiscript:openai:msg logging namespaces for more information about the requests and responses:

Aliases

The following model aliases are attempted by default in GenAIScript.

AliasModel identifier
largegpt-4.1
smallgpt-4.1-mini
tinygpt-4.1-nano
visiongpt-4.1
vision_smallgpt-4.1-mini
embeddingstext-embedding-3-small
reasoningo1
reasoning_smallo3-mini
transcriptionwhisper-1
speechtts-1
imagedall-e-3
intentgpt-4.1-mini