Why is OpenAI capitalised and works in the beginner tutorial

“openai” is the name of the library package.

“OpenAI” for the client object class, and others that are capitalized, are python classes.

__init__.py:

from ._utils import file_from_path
from ._client import (
    Client,
    OpenAI,
    Stream,
    Timeout,
    Transport,
    AsyncClient,
    AsyncOpenAI,
    AsyncStream,
    RequestOptions,
)
from ._version import __title__, __version__
...

_client:

class OpenAI(SyncAPIClient):
    completions: resources.Completions
    chat: resources.Chat
    edits: resources.Edits
    embeddings: resources.Embeddings
    files: resources.Files
    images: resources.Images
    audio: resources.Audio
    moderations: resources.Moderations
    models: resources.Models
    fine_tuning: resources.FineTuning
    fine_tunes: resources.FineTunes
    beta: resources.Beta
    with_raw_response: OpenAIWithRawResponse

etc…

1 Like