[Python] Is there a difference of how to use OpenAI Azure API KEY vs actual openAI key?

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

  1. Stack

    Stack Membro Participativo

    I want to use open AI to get embeddings for a recommendation system.

    I used my credentials everything worked. Now I need to use my company's credentials to get embeddings for the whole dataset, however theirs is in azure and using the same hting doesnt work. I don't understand what to do.

    this is the endpoint: openai.azure.com/

    Additionally they didnt provide me with api version and deployment name. Should I ask for this or I can work without. Also my key doesn't start with sk?

    Any help is much appreciated!

    `client = AzureOpenAI( api_key="sk-YOUR_API_KEY", azure_endpoint="https:/smth.openai.azure.com/"

    )

    response = client.embeddings.create(
    input="Your text string goes here",
    model="text-embedding-3-small"
    )`


    I tried this got this error:

    OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

    I expected to get embeddings

    Continue reading...

Compartilhe esta Página