Azure / Azure/azure-sdk-for-python

Incorrect `unresolved-attribute` for Azure AI Inference's `ChatCompletionsClient`

Open
#45,339 2 comments 0 reactions 1 assignee Claimed by @dargilco View on GitHub
AI Model Inference customer-reported needs-team-attention question Service Attention
Dominant language
Python
Stars
5.6k
Forks
3.4k
Avg merge
1d 21h
Merged PRs (30d)
193

Description

- **Package Name**: `azure-ai-inference`
- **Package Version**: `1.0.0b9`
- **Operating System**: Windows
- **Python Version**: `3.13`

**Describe the bug**

As stated [in this issue](https://github.com/astral-sh/ty/issues/2898), `ty` complains that `ChatCompletionsClient` does not have a `complete` attribute.

**To Reproduce**

Here's a minimal example that should show the problem in VS Code, or when doing `ty check`:

```python
from azure.ai.inference.aio import ChatCompletionsClient
from azure.ai.inference.models import UserMessage
from azure.core.credentials import AzureKeyCredential

async def mcp_client(token: str, prompt: str):
client = ChatCompletionsClient(
endpoint="https://models.github.ai/inference",
credential=AzureKeyCredential(token),
)
messages = [UserMessage(content=prompt)]
response = await client.complete(model="openai/gpt-4o-mini", messages=messages)
return response

if __name__ == "__main__":
import asyncio

token = "github_pat_###"
response = asyncio.run(mcp_client(token, "What is the capital of France?"))
print(response.choices[0].message.content)
```

**Expected behavior**

Since the class `ChatCompletionsClient` does have the `complete` attribute (and indeed, the code runs fine), this error should not happen. As mentioned in the referenced issue, it seems that this might be due to the particular implementation of the class.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.