Not able to run my org's Azure OpenAI API #483
Unanswered
viradgupta
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all, I am trying to run spacy-llm with my organization's azure openai api that they have provided me.
But since I am pretty beginner in Python, I guess I am not writing the config file correctly, and hence getting the 403 Forbidden error.
I am not able to understand how to introduce the default_headers parameter in spacy-llm because I know that this is one of the security parts in authenticating the api.
The .env file that my org's IT has provided looks like this:
And then the config file that I have written from whatever I could understand looks like this:
And below is the code I am running:
import os
from spacy_llm.util import assemble
from openai import AzureOpenAI
from dotenv import load_dotenv
load_dotenv()
AZURE_OPENAI_KEY = os.getenv("AZURE_OPENAI_KEY")
base_url = os.getenv("base_url")
api_version = os.getenv("api_version")
model = os.getenv("Model")
auth_headers = {
"200137912-Subscription-Key": AZURE_OPENAI_KEY
}
client = AzureOpenAI(
api_key = AZURE_OPENAI_KEY,
api_version = api_version,
default_headers=auth_headers,
azure_endpoint = base_url
)
nlp = assemble("config.cfg")
And after running this last command I get HTTPError: 403 Client Error: Forbidden
Beta Was this translation helpful? Give feedback.
All reactions