Share via

Created prompt agent in Azure Foundry (model GPT5.4). Trying to call this agent in our frontend mobile app (JS) to create user conversation & generate response. Failed to get response. Unsure if the credentials work to fetch response successfully.

GenixPRO 206 Reputation points
2026-05-18T07:40:13.0333333+00:00

Hi Team,

We're trying to migrate from using Assistants API to using foundry prompt agents. However getting stuck & unable to get response from agent. Appreciate your help.

Our setup:

  1. Created a prompt agent in Azure Foundry (model GPT5.4). Got -> endpoint, agentName, agentVersion
  2. Trying the JS quickstart/code to call this agent in our frontend mobile app -> to create user conversation & generate response.
    1. Failed to get response -> Unsure if the credentials (API KEY for testing) work to fetch response successfully
      1. Is there any JS code / QS on how to create a conversation with a foundry agent using API Key?
    2. We notice there's RESPONSES_ENDPOINT. Are we supposed to call this endpoint to get response?
      1. Is there any JS code / QS on how to get response for a conversation (using API Key)? Are we supposed to call a specific responses endpoint?
      2. The JS code preview in playground doesn't call any specific endpoint to get response. only uses conversation.id to get

Thanks

Azure OpenAI in Foundry Models
0 comments No comments

2 answers

Sort by: Most helpful
  1. SAI JAGADEESH KUDIPUDI 3,385 Reputation points Microsoft External Staff Moderator
    2026-05-20T00:12:58.8433333+00:00

    Hi GenixPRO,

    Thanks for sharing the details — I understand how this can be confusing, especially when transitioning from the Assistants API to Foundry prompt agents.

    In Azure AI Foundry Agent Service, creating a conversation alone will not generate a reply. A conversation simply holds context and history — it does not execute the model.

    To actually get a response from your agent, you must explicitly create a response. This is the step where the model runs and produces output.

    The expected flow is:

    • Create agent
    • Create (or use) conversation
    • Create response (this triggers execution)
    • Retrieve the response

    There’s no need to manually call a separate “responses endpoint” from your frontend code.

    When using Foundry:

    • All operations (agents, conversations, responses) are invoked through the project endpoint
    • The SDK or REST API internally handles the correct routes
    • The key requirement is calling responses.create()

    Based on your scenario, the issue is most likely that the response creation step is missing.

    You can update your implementation as follows:

    // Create a conversation
    const conversation = await client.conversations.create();
    
    // Trigger the agent by creating a response
    const response = await client.responses.create({
      agent_reference: {
        name: "your-agent-name",
        version: "your-agent-version"
      },
      conversation_id: conversation.id,
      input: "Hello"
    });
    
    // Retrieve the generated output
    const result = await client.responses.get(response.id);
    console.log(result.output_text);
    

    For production scenarios, it is recommended to route requests through a backend service rather than calling Foundry directly from a mobile frontend. This helps with:

    • Secure credential management
    • Better control and observability
    • Alignment with recommended authentication methods (such as Microsoft Entra ID)
    • A conversation only stores context — it does not run the model
    • You must call responses.create() to generate output
    • There is no need to manually call a separate “responses endpoint”
    • Using a backend layer is the preferred integration pattern

    Build with agents, conversations, and responses

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.

    Was this answer helpful?


  2. AI answer

    2026-05-18T07:40:47.6233333+00:00

    Foundry prompt agents are invoked through the Foundry Agent Service (agents, conversations, responses) using the project endpoint and the Foundry SDKs or REST, not by calling a separate “responses endpoint” directly from a mobile frontend with an API key.

    Key points from the current Foundry model/agent guidance:

    1. How agents and conversations are called
    • Agents are created and versioned via the project client (for example, AIProjectClient / project.agents.create_version with a PromptAgentDefinition).
    • Conversations and responses are then created via the same project client (for example, conversations.create() and responses.create()), passing an agent_reference that includes the agent name and version.
    • The quickstarts and how-to articles show this pattern for all supported languages (Python, C#, TypeScript/JavaScript, Java, REST) and do not introduce a separate “responses endpoint” that must be called manually; the SDK handles the correct API paths when given the project endpoint and credentials.
    1. Endpoint and deployment naming
    • For Foundry models, the endpoint must include the project path, for example:
      • https://<your-ai-services-account>.services.ai.azure.com/api/projects/<project-name>
    • When using a model behind an AI Gateway connection, the model deployment name must be in the form:
      • <connection-name>/<model-name>
    • If a model not found or 404 Not Found error occurs, confirm:
      • The endpoint includes /api/projects/YOUR_PROJECT_NAME.
      • The deployment name matches what is configured in Foundry.
    1. Authentication and common errors
    • The documented quickstarts and how-to guides use DefaultAzureCredential (for example, managed identity, developer identity) rather than an API key for Foundry Agent Service.
    • Common issues when calling models/agents include:
      • 401 Unauthorized: invalid or expired credential; ensure the identity used has the Cognitive Services OpenAI User role on the resource.
      • 404 Not Found: wrong endpoint or deployment name; ensure the project endpoint and deployment name are correct.
      • 400 Model not supported: the chosen model does not support the Responses API.
    1. JavaScript/TypeScript usage
    • The JavaScript/TypeScript path uses @azure/ai-projects with the project endpoint and DefaultAzureCredential:
      • Install: npm install @azure/ai-projects@2.0.0 and @azure/identity.
      • Initialize the project client with the project endpoint.
      • Create an agent (or use an existing prompt agent), then:
        • Create a conversation.
        • Call responses.create() with the conversation and agent_reference.
    • The playground’s JS preview follows this pattern: it uses the conversation ID and agent reference via the SDK; it does not show a separate manual HTTP call to a “responses endpoint”.
    1. API key from a mobile frontend
    • The provided documentation and quickstarts focus on using DefaultAzureCredential and server-side SDKs/REST for calling Foundry models and agents.
    • There is no documented JavaScript quickstart that calls Foundry prompt agents directly from a mobile frontend using an API key.
    • The recommended pattern is to call Foundry from a backend (for example, Node.js service) using the official SDK and supported credentials, then expose a secure API to the mobile app.

    To unblock the scenario:

    • Ensure the project endpoint is in the /api/projects/<project-name> form.
    • Use the JavaScript @azure/ai-projects SDK with DefaultAzureCredential in a backend service to:
      • Reference the existing prompt agent (by name and version).
      • Create a conversation and then a response using responses.create() with agent_reference.
    • Verify that the identity used has the Cognitive Services OpenAI User role and that the model deployment name matches the Foundry configuration.

    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.