Metadata-Version: 2.4
Name: swarmauri_llm_azureopenai
Version: 0.11.0.dev3
Summary: Provider-native Swarmauri chat and tool-calling adapters for Azure OpenAI.
License-Expression: Apache-2.0
Keywords: swarmauri,llm,azure openai,microsoft foundry,entra id,tool calling,streaming
Author: Jacob Stewart
Author-email: jacob@swarmauri.com
Requires-Python: >=3.10,<3.13
Classifier: Development Status :: 1 - Planning
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: swarmauri_base (>=0.11.0.dev5)
Requires-Dist: swarmauri_core (>=0.11.0.dev5)
Requires-Dist: swarmauri_standard (>=0.11.0.dev6)
Requires-Dist: swarmauri_transport_httpx (>=0.1.0.dev5)
Requires-Dist: swarmauri_transport_retry (>=0.1.0.dev1)
Description-Content-Type: text/markdown

![Swarmauri](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)

<p align="center">
  <a href="https://pepy.tech/project/swarmauri_llm_azureopenai"><img src="https://static.pepy.tech/badge/swarmauri_llm_azureopenai/month" alt="Downloads"></a>
  <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_llm_azureopenai/"><img src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_llm_azureopenai.svg" alt="Hits"></a>
  <a href="https://pypi.org/project/swarmauri_llm_azureopenai/"><img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue" alt="Python"></a>
  <a href="https://pypi.org/project/swarmauri_llm_azureopenai/"><img src="https://img.shields.io/pypi/l/swarmauri_llm_azureopenai" alt="License"></a>
  <a href="https://pypi.org/project/swarmauri_llm_azureopenai/"><img src="https://img.shields.io/pypi/v/swarmauri_llm_azureopenai" alt="Release"></a>
</p>

# Swarmauri Azure OpenAI LLM

`swarmauri_llm_azureopenai` provides provider-native Swarmauri adapters for Azure OpenAI and Microsoft Foundry chat-completions deployments.

## Features

- `AzureOpenAIModel` directly implements the Swarmauri LLM base contract.
- `AzureOpenAIToolModel` directly implements the tool-LLM base contract.
- API-key authentication with Azure's `api-key` header.
- Refreshable Microsoft Entra bearer-token providers kept outside serialized state.
- Sync, async, streaming, and batch workflows against the current `/openai/v1` API.
- Persistent, injectable Swarmauri HTTP clients with conservative rate-limit retries.

## Installation

```bash
uv add swarmauri_llm_azureopenai
```

```bash
pip install swarmauri_llm_azureopenai
```

## Usage

```python
import os

from swarmauri_llm_azureopenai import AzureOpenAIModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage

conversation = Conversation(messages=[HumanMessage(content="Summarize this release.")])
model = AzureOpenAIModel(
    endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
    api_key=os.environ["AZURE_OPENAI_API_KEY"],
    name="my-gpt-deployment",
)
model.predict(conversation)
print(conversation.get_last().content)
```

For keyless authentication, omit `api_key` and pass a callable as `token_provider`; it is invoked for every request so refreshed Entra tokens are used. Use `AzureOpenAIToolModel` with a Swarmauri `Toolkit` for function calling.

Pass an `IHttpClient` as `http_client` to integrate a custom transport or to test without network access. Pass an `IHttpRetryPolicy` as `retry_policy` to replace the default policy, which retries safe reads and rate-limited chat submissions without replaying failed POST requests for generic server errors.

See the [Azure OpenAI chat REST reference](https://learn.microsoft.com/en-us/rest/api/microsoft-foundry/azureopenai/chat) and [Entra authentication guide](https://learn.microsoft.com/en-us/azure/foundry/foundry-models/how-to/configure-entra-id).

