litellm - 💡(How to fix) Fix [Bug]: Invoking Azure AI Foundry Agent with Open AI SDK [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#24818Fetched 2026-04-08 01:53:50
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Error Message

I correctly used a2a/<agent-name> prefix to call my agent and I got a ressource not found error: InternalServerError: Error code: 500 - {'error': {'message': 'litellm.APIConnectionError: A2aException - {"error":{"code":"404","message": "Resource not found"}}', 'type': None, 'param': None, 'code': '500'}} InternalServerError: Error code: 500 - {'error': {'message': 'litellm.APIConnectionError: A2aException - {"error":{"code":"404","message": "Resource not found"}}', 'type': None, 'param': None, 'code': '500'}}

Code Example

import httpx
import uuid

response = httpx.post(
    "https://xxxxxxxx:4000/a2a/cc09aab5-85e2-44e5-9d7b-323a8cb0e08c",
    headers={
        "Authorization": "Bearer sk-xxxxxxxx",
        "Content-Type": "application/json",
    },
    json={
        "jsonrpc": "2.0",
        "id": str(uuid.uuid4()),
        "method": "message/send",
        "params": {
            "message": {
                "role": "user",
                "parts": [{"kind": "text", "text": "Bonjour !"}],
                "messageId": uuid.uuid4().hex,
            }
        },
    },
)

print(response.json())

---

import openai

client = openai.OpenAI(
    api_key="sk-xxxxxx", 
    base_url="https://xxxxxxxx:4000"
)

stream = client.chat.completions.create(
    model="a2a/snowflake-agent",  # Use a2a/ prefix with your agent name
    messages=[
        {"role": "user", "content": "Tell me a short story"}
    ],
)

---

import openai

client = openai.OpenAI(
    api_key="sk-xxxxxx", 
    base_url="https://xxxxxxxx:4000"
)

stream = client.chat.completions.create(
    model="a2a/snowflake-agent",  # Use a2a/ prefix with your agent name
    messages=[
        {"role": "user", "content": "Tell me a short story"}
    ],
)
``

### Relevant log output
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

Hello,

I'm trying to call an azure agent registered on my litellm proxy server and I would like to call it throught open ai sdk.

I can call it correctly by using directly a2a protcol:

import httpx
import uuid

response = httpx.post(
    "https://xxxxxxxx:4000/a2a/cc09aab5-85e2-44e5-9d7b-323a8cb0e08c",
    headers={
        "Authorization": "Bearer sk-xxxxxxxx",
        "Content-Type": "application/json",
    },
    json={
        "jsonrpc": "2.0",
        "id": str(uuid.uuid4()),
        "method": "message/send",
        "params": {
            "message": {
                "role": "user",
                "parts": [{"kind": "text", "text": "Bonjour !"}],
                "messageId": uuid.uuid4().hex,
            }
        },
    },
)

print(response.json())

I got a correct answer but when i'm using open ai sdk way to call my agent through litellm (https://docs.litellm.ai/docs/a2a_invoking_agents#chatcompletions-api-openai-sdk):

import openai

client = openai.OpenAI(
    api_key="sk-xxxxxx", 
    base_url="https://xxxxxxxx:4000"
)

stream = client.chat.completions.create(
    model="a2a/snowflake-agent",  # Use a2a/ prefix with your agent name
    messages=[
        {"role": "user", "content": "Tell me a short story"}
    ],
)

I correctly used a2a/<agent-name> prefix to call my agent and I got a ressource not found error:

InternalServerError: Error code: 500 - {'error': {'message': 'litellm.APIConnectionError: A2aException - {"error":{"code":"404","message": "Resource not found"}}', 'type': None, 'param': None, 'code': '500'}}

It seems the server doesn't find my agent even if I'm using a2a prefix in open ai sdk invocation.

Thanks

Steps to Reproduce

  1. Create an Azure AI Agent in ancient microsoft foundry portal
  2. Register this agent through litellm proxy
  3. Trying to call this agent with correct virtual key and prefix using
import openai

client = openai.OpenAI(
    api_key="sk-xxxxxx", 
    base_url="https://xxxxxxxx:4000"
)

stream = client.chat.completions.create(
    model="a2a/snowflake-agent",  # Use a2a/ prefix with your agent name
    messages=[
        {"role": "user", "content": "Tell me a short story"}
    ],
)
``

### Relevant log output

```shell
InternalServerError: Error code: 500 - {'error': {'message': 'litellm.APIConnectionError: A2aException - {"error":{"code":"404","message": "Resource not found"}}', 'type': None, 'param': None, 'code': '500'}}

What part of LiteLLM is this about?

Agent Gateway

What LiteLLM version are you on ?

v1.82.6

Twitter / LinkedIn details

https://www.linkedin.com/in/cl%C3%A9ment-parsy-907bb0108/

extent analysis

Fix Plan

To resolve the issue, we need to ensure that the agent is correctly registered and the OpenAI SDK is properly configured. Here are the steps:

  • Verify that the agent is registered with the correct name and prefix (a2a/<agent-name>) in the Litellm proxy server.
  • Check that the base_url in the OpenAI SDK configuration matches the URL of the Litellm proxy server.
  • Ensure that the api_key used in the OpenAI SDK is valid and has the necessary permissions to access the agent.

Example code to verify the agent registration:

import httpx

response = httpx.get(
    "https://xxxxxxxx:4000/a2a/agents",
    headers={
        "Authorization": "Bearer sk-xxxxxxxx",
    }
)

print(response.json())

This should return a list of registered agents, including the one with the name a2a/snowflake-agent.

Example code to create a chat completion using the OpenAI SDK:

import openai

client = openai.OpenAI(
    api_key="sk-xxxxxx", 
    base_url="https://xxxxxxxx:4000"
)

stream = client.chat.completions.create(
    model="a2a/snowflake-agent", 
    messages=[
        {"role": "user", "content": "Tell me a short story"}
    ],
    stream=True
)

for message in stream:
    print(message)

Note that we've added the stream=True parameter to enable streaming of the response.

Verification

To verify that the fix worked, run the example code to create a chat completion using the OpenAI SDK. If the agent is correctly registered and the OpenAI SDK is properly configured, you should receive a response from the agent.

Extra Tips

  • Ensure that the Litellm proxy server is running and accessible.
  • Check the Litellm documentation for any specific requirements or restrictions on agent registration and OpenAI SDK usage.
  • If you're still experiencing issues, try enabling debug logging in the OpenAI SDK to get more detailed error messages.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING