How to get an API endpoint into an agent?

Reynold 0 Reputation points
2025-03-13T05:11:19.8666667+00:00

I created an agent through AI Foundry. How can I get an endpoint for it? Because on the "Models + endpoints" page, I see an endpoint for the base model as far as I understand, but how can I get an endpoint for the agent?
User's image

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,234 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Saideep Anchuri 4,110 Reputation points Microsoft External Staff
    2025-03-13T09:40:08.8833333+00:00

    Hi Reynold

    For Agents, There does not seem to be endpoint and key for authentication.  You can get the agent id with below code from UI containing the agents and use it for thread creation.

    Kindly refer below screenshot:

    User's image

    Here is the code:

    # Create a thread with messages
    thread = project_client.agents.create_thread()
    message = project_client.agents.create_message(
        thread_id=thread.id,
        role="user",
        content="Could you please create a bar chart for the operating profit using the following data and provide the file to me? Company A: $1.2 million, Company B: $2.5 million, Company C: $3.0 million, Company D: $1.8 million",
    )
     
    # Ask the agent to perform work on the thread
    run = project_client.agents.create_and_process_run(thread_id=thread.id, agent_id=agent.id)
     
    # Fetch and log all messages to see the agent's response
    messages = project_client.agents.list_messages(thread_id=thread.id)
    print(f"Messages: {messages}")
    
    
    

    Kindly refer below link: what-is-an-ai-agent

    Hope this helps. Do let us know if you any further queries.

     


    If this answers your query, do click Accept Answer and Yes for was this answer helpful.

    Thank You.

    0 comments No comments

Your answer

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