[bot] Add Azure AI Inference Python SDK integration for ChatCompletionsClient and EmbeddingsClient instrumentation (1,288,823 weekly downloads)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- azure, python
- 领域
- ai, backend-api-design
调研方向
首先查看 py/src/braintrust/integrations/ 和 py/src/braintrust/wrappers/ 下现有的集成和 wrapper 模式,然后检查 py/noxfile.py、pyproject.toml、init.py 和 versioning.py。完成标准是为列出的同步、异步、流式聊天和 embedding 方法提供原生 tracing 覆盖,并为 azure-ai-inference 添加测试以及包/版本注册。
由索引模型根据 Issue 内容生成。
描述
Summary
The Azure AI Inference Python SDK (azure-ai-inference) is Microsoft's official client for accessing AI models through Azure AI Foundry serverless endpoints, GitHub Models, managed compute endpoints, and the Azure OpenAI Service. It exposes ChatCompletionsClient, EmbeddingsClient, and ImageEmbeddingsClient for executing inference against a broad catalog of models (Meta Llama 3.3, Mistral Large, DeepSeek-R1, Microsoft Phi-4, Cohere Command R, and others) that are hosted on Azure but are not accessible through the standard OpenAI Python client.
This repository has zero instrumentation for any azure-ai-inference execution surface — no integration directory, no wrapper, no patcher, no auto_instrument() support. Users who call ChatCompletionsClient.complete() or EmbeddingsClient.embed() directly get no Braintrust spans.
The SDK cannot be wrapped with wrap_openai() because ChatCompletionsClient is a distinct class with its own authentication (Azure API keys or Entra ID) and its own request/response types from the azure.ai.inference.models namespace. wrap_openai() requires an openai.OpenAI instance.
The Braintrust docs list "Azure AI Foundry" as a supported cloud provider, but this coverage is provided through the AI Proxy gateway (using an OpenAI client pointed at the Braintrust gateway URL), not through native azure-ai-inference SDK tracing. Users who follow Microsoft's official documentation for Azure AI Foundry (pip install azure-ai-inference) and call ChatCompletionsClient.complete() directly get zero Braintrust spans.
What needs to be instrumented
The azure-ai-inference package (v1.0.0b9) exposes these execution surfaces, none of which are instrumented:
Chat completions (highest priority)
| SDK Method | Description | Streaming |
|---|---|---|
ChatCompletionsClient.complete(messages, ...) |
Chat completions via Azure AI Foundry / GitHub Models | No |
ChatCompletionsClient.complete(messages, stream=True, ...) |
Streaming chat completions | StreamingChatCompletions iterator |
AsyncChatCompletionsClient.complete(...) |
Async chat completions | No |
AsyncChatCompletionsClient.complete(..., stream=True) |
Async streaming chat completions | AsyncStreamingChatCompletions |
Response shape: ChatCompletions with choices[0].message.content, choices[0].finish_reason, usage.prompt_tokens, usage.completion_tokens, usage.total_tokens, model, id. Mirrors the OpenAI response shape in structure but is a distinct Azure type.
Streaming: StreamingChatCompletions is an iterable of StreamingChatCompletionsUpdate objects with choices[0].delta.content. The integration must accumulate deltas and finalize the span when iteration completes.
Embeddings
| SDK Method | Description |
|---|---|
EmbeddingsClient.embed(input, ...) |
Generate embeddings for a list of texts |
AsyncEmbeddingsClient.embed(input, ...) |
Async embeddings |
Return type: EmbeddingsResult with data[0].embedding (list of floats) and usage.prompt_tokens.
Implementation notes
Authentication: Uses Azure API key (AzureKeyCredential) or Entra ID (DefaultAzureCredential). VCR cassettes need api-key header sanitization.
Endpoint-per-model pattern: Unlike OpenAI where a single client accesses all models, each Azure AI Foundry deployment has its own endpoint URL. The model name is embedded in the endpoint or returned in the response. Span metadata should capture model from ChatCompletions.model.
GitHub Models support: The same ChatCompletionsClient is used for GitHub Models (with endpoint="https://models.inference.ai.azure.com" and a GitHub token). GitHub Models provides free-tier access to GPT-4o, Llama, Mistral, and others for prototyping.
Parameters relevant for span metadata: model (or inferred from endpoint), temperature, max_tokens, top_p, frequency_penalty, presence_penalty, seed, tools, response_format, stop.
No coverage in any instrumentation layer
- No integration directory (
py/src/braintrust/integrations/azure_ai_inference/) - No wrapper function (e.g.
wrap_azure_ai_inference()) - No patcher in any existing integration
- No nox test session (
test_azure_ai_inference) - No version entry in
py/src/braintrust/integrations/versioning.py - No mention in
py/src/braintrust/integrations/__init__.py
A grep for azure.ai, azure-ai-inference, or azure_ai_inference across py/src/braintrust/ returns zero matches.
Braintrust docs status
unclear — The Braintrust AI providers page lists "Azure AI Foundry" as a supported cloud provider, but the integration is through the AI Proxy gateway (routing openai.AzureOpenAI or openai.OpenAI through the Braintrust gateway URL), not through a native azure-ai-inference SDK wrapper. Users following Microsoft's official azure-ai-inference quickstart docs get zero native Braintrust tracing.
Upstream references
- azure-ai-inference on PyPI: https://pypi.org/project/azure-ai-inference/ (v1.0.0b9)
- azure-ai-inference on GitHub: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/ai/azure-ai-inference
- Azure AI Inference Python SDK docs: https://learn.microsoft.com/en-us/azure/ai-studio/reference/reference-model-inference-api
- ChatCompletionsClient reference: https://learn.microsoft.com/en-us/python/api/azure-ai-inference/azure.ai.inference.chatcompletionsclient
- GitHub Models quickstart: https://docs.github.com/en/github-models/use-github-models/getting-started-with-github-models
- Azure AI Foundry model catalog: https://ai.azure.com/explore/models
Local repo files inspected
py/src/braintrust/integrations/— noazure_ai_inference/directory onmainpy/src/braintrust/wrappers/— no Azure AI Inference wrapperpy/noxfile.py— notest_azure_ai_inferencesessionpy/pyproject.toml[tool.braintrust.matrix]— no azure-ai-inference entrypy/src/braintrust/integrations/__init__.py— Azure AI Inference not listedpy/src/braintrust/integrations/versioning.py— no Azure AI Inference version matrix- Full repo grep for
azure.ai,azure-ai-inference,azure_ai_inference— zero matches in SDK source
- 主要语言
- Python
- 星标
- 20
- 派生
- 18
- 平均合并
- 21 小时 8 分钟
- 30 天内合并 PR
- 81
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
braintrustdata/braintrust-sdk-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
braintrustdata/braintrust-sdk-python#797 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
braintrustdata/braintrust-sdk-python#774 ·
维护者通常 1 天内回复
-
Migrate legacy HTTPConnection callers to the policy-aware Transport incrementally可能已有人在做 @AbhiPrasad 于 1 天前认领。 未关闭python
braintrustdata/braintrust-sdk-python#839 · 已指派 1 人 ·
维护者通常 1 天内回复
-
new-integration
难度 4/5 3-5 天 新手友好度 68/100
braintrustdata/braintrust-sdk-python#808 ·
维护者通常 1 天内回复
-
new-integration
难度 4/5 3-5 天 新手友好度 48/100
braintrustdata/braintrust-sdk-python#807 ·
维护者通常 1 天内回复
查看 braintrustdata/braintrust-sdk-python 的全部 Issue
相似的 Issue
-
good first issue hacktoberfest
难度 1/5 1 小时以内 新手友好度 92/100
维护者通常 1 天内回复
-
tool-calling
难度 2/5 1-3 小时 新手友好度 88/100
vllm-project/vllm#59838 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
raullenchai/Rapid-MLX#4042 ·
维护者通常 1 天内回复
-
documentation
难度 1/5 1 小时以内 新手友好度 92/100
transitmatters/mbta-slow-zone-bot#70 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 66/100
open-webui/open-webui#31871 · 1 条评论 ·
维护者通常 1 天内回复