openai api - Azure Open AI from SPA apps without backends - Stack Overflow

admin2025-05-01  0

I am building a ReactJS app without a backend. I am using Azure Open AI service via LangChainJS/LangGraphJS.

Though I can ground model/provide system prompts using Javascript and LagChain making sure the model only answers questions related to my Web App, anyone with a network inspector could access the chat completion endpoint and directly invoke the endpoint and get answers to any generic question.

I am not worried about the Azure OpenAI API key being exposed as I can use URL Rewrite and Akamai to hide the actual Azure Open AI endpoint.

I would like to add meta/system prompts to the model at the Azure AI Foundry Deployment level, instead of LangChain based system prompts. This will ensure that the chat completion API will adhere to the system prompts provided in Foundry and only answer based on specific knowledge of my web app rather than answering generic questions like "Who is Tom Cruise?"

I am building a ReactJS app without a backend. I am using Azure Open AI service via LangChainJS/LangGraphJS.

Though I can ground model/provide system prompts using Javascript and LagChain making sure the model only answers questions related to my Web App, anyone with a network inspector could access the chat completion endpoint and directly invoke the endpoint and get answers to any generic question.

I am not worried about the Azure OpenAI API key being exposed as I can use URL Rewrite and Akamai to hide the actual Azure Open AI endpoint.

I would like to add meta/system prompts to the model at the Azure AI Foundry Deployment level, instead of LangChain based system prompts. This will ensure that the chat completion API will adhere to the system prompts provided in Foundry and only answer based on specific knowledge of my web app rather than answering generic questions like "Who is Tom Cruise?"

Share Improve this question edited Jan 2 at 16:50 CommunityBot 11 silver badge asked Jan 2 at 16:25 Aneesh GopalakrishnanAneesh Gopalakrishnan 7121 gold badge13 silver badges31 bronze badges 1
  • you either store it anywhere or get by calling an api. this will restrict it to only those prompts you are getting. – JayashankarGS Commented Jan 6 at 3:43
Add a comment  | 

1 Answer 1

Reset to default 0

limited options that i can think of...

1- write a logic in akamai to add system prompt (add or overwrite the system prompt from client side). similar to this example, just add some js logics to change request body json. https://techdocs.akamai.com/edgeworkers/docs/transform-response-content

2- if akamai can't do that, Azure API Management can definitely change request body. but some extra $$$

转载请注明原文地址:http://anycun.com/QandA/1746107767a91777.html