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:
![image](https://private-user-images.githubusercontent.com/63508980/371754110-cff426bd-355e-4c41-87ae-faf96f94ea5c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMTc4MTEsIm5iZiI6MTczOTExNzUxMSwicGF0aCI6Ii82MzUwODk4MC8zNzE3NTQxMTAtY2ZmNDI2YmQtMzU1ZS00YzQxLTg3YWUtZmFmOTZmOTRlYTVjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDE2MTE1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThkZDViODgzYTQwOWM2Y2RjNGNhNmNjMDNlNTk3MDI1MmNmMWY2OTE5ZTk0MjA1ZGI2MDZkZjg3YTBmMTdiZTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.taY4WjeMTTq1Blj77Nc06_P7bGYA_L-z9bhPlK1BKvs)
And then the config file that I have written from whatever I could understand looks like this:
![image](https://private-user-images.githubusercontent.com/63508980/371754184-33630c4f-5824-4daa-a22b-08d260b3dfef.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMTc4MTEsIm5iZiI6MTczOTExNzUxMSwicGF0aCI6Ii82MzUwODk4MC8zNzE3NTQxODQtMzM2MzBjNGYtNTgyNC00ZGFhLWEyMmItMDhkMjYwYjNkZmVmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDE2MTE1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE1NTA0MDE2ZmQxZGFkNmRmY2I1MzBlYmY5Y2M4ZTI5NDdkM2YzNTdiN2MwMDU2YmZmMjhhZGFlM2I5NjAxNmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.DN9WYgLboCzluk9u0QRnBDFF4SAQrchB0gk0DW8ucvo)
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