An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
Hello GenixPRO,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are creating prompt agents in Foundry (using Azure portal). Having authentication issues trying to connect to these agents (create response) from our frontend iOS app.
The issue is that the request is being sent to the wrong runtime surface, which is why you receive the aml-user-token header is required error. In the new Microsoft Foundry architecture, Prompt Agents are not meant to be called directly from a frontend using API key only through that endpoint. Check the associated links below for more reading and implementation steps.
Most of all, things change fast:
- A Prompt Agent in the new Microsoft Foundry must not be called through the raw endpoint the you're currently using. The supported Foundry project endpoint is
https://<resource>.services.ai.azure.com/api/projects/<project-name>, and published agent applications use.../applications/<app-name>/protocols/openai. Those are the documented runtime surfaces for agents in the new experience. - https://learn.microsoft.com/en-us/azure/foundry/how-to/develop/sdk-overview, https://learn.microsoft.com/azure/foundry/agents/how-to/publish-responses - In the official JavaScript Foundry SDK, Microsoft Entra ID is the only authentication method currently supported for the project client. By contrast, API keys are explicitly documented for the
/openai/v1endpoint, which is for Azure OpenAI / Foundry Models APIs, not for Foundry-specific agent/project operations. - https://learn.microsoft.com/en-us/javascript/api/overview/azure/ai-projects-readme?view=azure-node-latest - Therefore, your requested testing pattern “connect to Prompt Agents from frontend using API key only, without Entra ID” is not the supported solution. The supported options are:
- Use the Foundry project endpoint from a trusted backend with Entra ID for stateful agent operations, or
- Publish the agent as an Agent Application and invoke the published application endpoint with Azure credentials, this path is currently stateless Responses API only. - https://learn.microsoft.com/en-us/javascript/api/overview/azure/ai-projects-readme?view=azure-node-latest, https://learn.microsoft.com/azure/foundry/agents/how-to/publish-responses
Regarding your questions:
“For initial testing purposes, how can we connect to the agent from frontend and generate response using API Key only?”
By best practices, you cannot do that as a supported JS/TS Prompt Agent integration path in the new Foundry project model. Use a backend with Entra ID, or publish the agent and call the application endpoint with Azure credentials. - https://learn.microsoft.com/en-us/javascript/api/overview/azure/ai-projects-readme?view=azure-node-latest, https://learn.microsoft.com/azure/foundry/agents/how-to/publish-responses
We don’t want to set up Entra ID / other authentication methods for this testing.
Then do not test Prompt Agents directly from the frontend. Either use a lightweight backend/broker now, or switch the test to plain /openai/v1/responses model inference with API key, but that is not equivalent to Prompt Agent runtime testing. - https://learn.microsoft.com/en-us/azure/foundry/how-to/develop/sdk-overview, https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/responses
Can’t we do the same as Assistants using API key?
Not in the same way. The new platform’s documented JS project-agent path requires Entra ID, and published agent apps also use Azure credentials. The architecture changed from Assistants API to Responses API + projects/agent versions/applications. https://learn.microsoft.com/en-us/azure/foundry/what-is-foundry, https://learn.microsoft.com/en-us/javascript/api/overview/azure/ai-projects-readme?view=azure-node-latest, https://learn.microsoft.com/azure/foundry/agents/how-to/publish-responses
I hope this is helpful! Do not hesitate to let me know if you have any other questions, steps or clarifications.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.