[Python] OpenAI API: openai.api_key = os.getenv() not working

Discussão em 'Python' iniciado por Stack, Maio 11, 2025.

  1. Stack

    Stack Membro Participativo

    I am just trying some simple functions in Python with OpenAI APIs but running into an error:

    I have a valid API secret key which I am using.

    Code:

    >>> import os
    >>> import openai
    >>> openai.api_key = os.getenv("I have placed the key here")
    >>> response = openai.Completion.create(model="text-davinci-003", prompt="Say this is a test", temperature=0, max_tokens=7)


    [​IMG]

    Continue reading...

Compartilhe esta Página