agent-framework-openai 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-framework-openai
3
+ Version: 1.0.0
4
+ Summary: OpenAI integrations for Microsoft Agent Framework.
5
+ Author-email: Microsoft <af-support@microsoft.com>
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Typing :: Typed
18
+ License-File: LICENSE
19
+ Requires-Dist: agent-framework-core>=1.0.0,<2
20
+ Requires-Dist: openai>=1.99.0,<3
21
+ Project-URL: homepage, https://aka.ms/agent-framework
22
+ Project-URL: issues, https://github.com/microsoft/agent-framework/issues
23
+ Project-URL: release_notes, https://github.com/microsoft/agent-framework/releases?q=tag%3Apython-1&expanded=true
24
+ Project-URL: source, https://github.com/microsoft/agent-framework/tree/main/python
25
+
26
+ # agent-framework-openai
27
+
28
+ OpenAI integration for Microsoft Agent Framework.
29
+
30
+ This package provides:
31
+
32
+ - `OpenAIChatClient` for the OpenAI Responses API
33
+ - `OpenAIChatCompletionClient` for the Chat Completions API
34
+ - `OpenAIEmbeddingClient` for embeddings
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install agent-framework-openai
40
+ ```
41
+
42
+ ## Which chat client should I use?
43
+
44
+ Use `OpenAIChatClient` for new work unless you specifically need the Chat Completions API.
45
+
46
+ - `OpenAIChatClient` uses the Responses API and is the preferred general-purpose chat client.
47
+ - `OpenAIChatCompletionClient` uses the Chat Completions API and is mainly for compatibility with
48
+ existing Chat Completions-based integrations.
49
+
50
+ The previous deprecated Responses alias has been removed. Use `OpenAIChatClient` directly.
51
+
52
+ ## Environment variables
53
+
54
+ ### OpenAI
55
+
56
+ These variables are used when the client is configured for OpenAI:
57
+
58
+ | Variable | Purpose |
59
+ | --- | --- |
60
+ | `OPENAI_API_KEY` | OpenAI API key |
61
+ | `OPENAI_ORG_ID` | OpenAI organization ID |
62
+ | `OPENAI_BASE_URL` | Custom OpenAI-compatible base URL |
63
+ | `OPENAI_MODEL` | Generic fallback model |
64
+ | `OPENAI_CHAT_MODEL` | Preferred model for `OpenAIChatClient` |
65
+ | `OPENAI_CHAT_COMPLETION_MODEL` | Preferred model for `OpenAIChatCompletionClient` |
66
+ | `OPENAI_EMBEDDING_MODEL` | Preferred model for `OpenAIEmbeddingClient` |
67
+
68
+ Model lookup order:
69
+
70
+ - `OpenAIChatClient`: `OPENAI_CHAT_MODEL` -> `OPENAI_MODEL`
71
+ - `OpenAIChatCompletionClient`: `OPENAI_CHAT_COMPLETION_MODEL` -> `OPENAI_MODEL`
72
+ - `OpenAIEmbeddingClient`: `OPENAI_EMBEDDING_MODEL` -> `OPENAI_MODEL`
73
+
74
+ These model variables are only consulted when you do not pass `model=` directly. In other words,
75
+ `OpenAIChatClient(model="...")` ignores `OPENAI_CHAT_MODEL`, and
76
+ `OpenAIChatCompletionClient(model="...")` ignores `OPENAI_CHAT_COMPLETION_MODEL`.
77
+
78
+ ### Azure OpenAI
79
+
80
+ These variables are used when the client is configured for Azure OpenAI:
81
+
82
+ | Variable | Purpose |
83
+ | --- | --- |
84
+ | `AZURE_OPENAI_ENDPOINT` | Azure OpenAI resource endpoint |
85
+ | `AZURE_OPENAI_BASE_URL` | Full Azure OpenAI base URL (`.../openai/v1`) |
86
+ | `AZURE_OPENAI_API_KEY` | Azure OpenAI API key |
87
+ | `AZURE_OPENAI_API_VERSION` | Azure OpenAI API version |
88
+ | `AZURE_OPENAI_MODEL` | Generic fallback deployment |
89
+ | `AZURE_OPENAI_CHAT_MODEL` | Preferred deployment for `OpenAIChatClient` |
90
+ | `AZURE_OPENAI_CHAT_COMPLETION_MODEL` | Preferred deployment for `OpenAIChatCompletionClient` |
91
+ | `AZURE_OPENAI_EMBEDDING_MODEL` | Preferred deployment for `OpenAIEmbeddingClient` |
92
+
93
+ Deployment lookup order:
94
+
95
+ - `OpenAIChatClient`: `AZURE_OPENAI_CHAT_MODEL` -> `AZURE_OPENAI_MODEL`
96
+ - `OpenAIChatCompletionClient`: `AZURE_OPENAI_CHAT_COMPLETION_MODEL` -> `AZURE_OPENAI_MODEL`
97
+ - `OpenAIEmbeddingClient`: `AZURE_OPENAI_EMBEDDING_MODEL` -> `AZURE_OPENAI_MODEL`
98
+
99
+ For Azure routing, the same rule applies: the client-specific deployment variable is checked first,
100
+ then the generic `AZURE_OPENAI_MODEL` fallback. Passing `model=` overrides both environment variables.
101
+
102
+ When both OpenAI and Azure environment variables are present, the generic clients prefer OpenAI
103
+ when `OPENAI_API_KEY` is configured. To use Azure explicitly, pass `azure_endpoint` or
104
+ `credential`.
105
+
106
+ ## OpenAI example
107
+
108
+ ```python
109
+ from agent_framework.openai import OpenAIChatClient
110
+
111
+ client = OpenAIChatClient(model="gpt-4.1")
112
+ ```
113
+
114
+ ## Azure OpenAI example
115
+
116
+ ```python
117
+ from azure.identity.aio import AzureCliCredential
118
+
119
+ from agent_framework.openai import OpenAIChatClient
120
+
121
+ client = OpenAIChatClient(
122
+ model="my-responses-deployment",
123
+ azure_endpoint="https://my-resource.openai.azure.com",
124
+ credential=AzureCliCredential(),
125
+ )
126
+ ```
127
+
128
+ ## ChatClient vs ChatCompletionClient
129
+
130
+ Use `OpenAIChatClient` when you want the Responses API as your default chat surface.
131
+
132
+ Use `OpenAIChatCompletionClient` when you specifically need the Chat Completions API:
133
+
134
+ ```python
135
+ from agent_framework.openai import OpenAIChatCompletionClient
136
+
137
+ client = OpenAIChatCompletionClient(model="gpt-4o-mini")
138
+ ```
139
+
@@ -0,0 +1,113 @@
1
+ # agent-framework-openai
2
+
3
+ OpenAI integration for Microsoft Agent Framework.
4
+
5
+ This package provides:
6
+
7
+ - `OpenAIChatClient` for the OpenAI Responses API
8
+ - `OpenAIChatCompletionClient` for the Chat Completions API
9
+ - `OpenAIEmbeddingClient` for embeddings
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pip install agent-framework-openai
15
+ ```
16
+
17
+ ## Which chat client should I use?
18
+
19
+ Use `OpenAIChatClient` for new work unless you specifically need the Chat Completions API.
20
+
21
+ - `OpenAIChatClient` uses the Responses API and is the preferred general-purpose chat client.
22
+ - `OpenAIChatCompletionClient` uses the Chat Completions API and is mainly for compatibility with
23
+ existing Chat Completions-based integrations.
24
+
25
+ The previous deprecated Responses alias has been removed. Use `OpenAIChatClient` directly.
26
+
27
+ ## Environment variables
28
+
29
+ ### OpenAI
30
+
31
+ These variables are used when the client is configured for OpenAI:
32
+
33
+ | Variable | Purpose |
34
+ | --- | --- |
35
+ | `OPENAI_API_KEY` | OpenAI API key |
36
+ | `OPENAI_ORG_ID` | OpenAI organization ID |
37
+ | `OPENAI_BASE_URL` | Custom OpenAI-compatible base URL |
38
+ | `OPENAI_MODEL` | Generic fallback model |
39
+ | `OPENAI_CHAT_MODEL` | Preferred model for `OpenAIChatClient` |
40
+ | `OPENAI_CHAT_COMPLETION_MODEL` | Preferred model for `OpenAIChatCompletionClient` |
41
+ | `OPENAI_EMBEDDING_MODEL` | Preferred model for `OpenAIEmbeddingClient` |
42
+
43
+ Model lookup order:
44
+
45
+ - `OpenAIChatClient`: `OPENAI_CHAT_MODEL` -> `OPENAI_MODEL`
46
+ - `OpenAIChatCompletionClient`: `OPENAI_CHAT_COMPLETION_MODEL` -> `OPENAI_MODEL`
47
+ - `OpenAIEmbeddingClient`: `OPENAI_EMBEDDING_MODEL` -> `OPENAI_MODEL`
48
+
49
+ These model variables are only consulted when you do not pass `model=` directly. In other words,
50
+ `OpenAIChatClient(model="...")` ignores `OPENAI_CHAT_MODEL`, and
51
+ `OpenAIChatCompletionClient(model="...")` ignores `OPENAI_CHAT_COMPLETION_MODEL`.
52
+
53
+ ### Azure OpenAI
54
+
55
+ These variables are used when the client is configured for Azure OpenAI:
56
+
57
+ | Variable | Purpose |
58
+ | --- | --- |
59
+ | `AZURE_OPENAI_ENDPOINT` | Azure OpenAI resource endpoint |
60
+ | `AZURE_OPENAI_BASE_URL` | Full Azure OpenAI base URL (`.../openai/v1`) |
61
+ | `AZURE_OPENAI_API_KEY` | Azure OpenAI API key |
62
+ | `AZURE_OPENAI_API_VERSION` | Azure OpenAI API version |
63
+ | `AZURE_OPENAI_MODEL` | Generic fallback deployment |
64
+ | `AZURE_OPENAI_CHAT_MODEL` | Preferred deployment for `OpenAIChatClient` |
65
+ | `AZURE_OPENAI_CHAT_COMPLETION_MODEL` | Preferred deployment for `OpenAIChatCompletionClient` |
66
+ | `AZURE_OPENAI_EMBEDDING_MODEL` | Preferred deployment for `OpenAIEmbeddingClient` |
67
+
68
+ Deployment lookup order:
69
+
70
+ - `OpenAIChatClient`: `AZURE_OPENAI_CHAT_MODEL` -> `AZURE_OPENAI_MODEL`
71
+ - `OpenAIChatCompletionClient`: `AZURE_OPENAI_CHAT_COMPLETION_MODEL` -> `AZURE_OPENAI_MODEL`
72
+ - `OpenAIEmbeddingClient`: `AZURE_OPENAI_EMBEDDING_MODEL` -> `AZURE_OPENAI_MODEL`
73
+
74
+ For Azure routing, the same rule applies: the client-specific deployment variable is checked first,
75
+ then the generic `AZURE_OPENAI_MODEL` fallback. Passing `model=` overrides both environment variables.
76
+
77
+ When both OpenAI and Azure environment variables are present, the generic clients prefer OpenAI
78
+ when `OPENAI_API_KEY` is configured. To use Azure explicitly, pass `azure_endpoint` or
79
+ `credential`.
80
+
81
+ ## OpenAI example
82
+
83
+ ```python
84
+ from agent_framework.openai import OpenAIChatClient
85
+
86
+ client = OpenAIChatClient(model="gpt-4.1")
87
+ ```
88
+
89
+ ## Azure OpenAI example
90
+
91
+ ```python
92
+ from azure.identity.aio import AzureCliCredential
93
+
94
+ from agent_framework.openai import OpenAIChatClient
95
+
96
+ client = OpenAIChatClient(
97
+ model="my-responses-deployment",
98
+ azure_endpoint="https://my-resource.openai.azure.com",
99
+ credential=AzureCliCredential(),
100
+ )
101
+ ```
102
+
103
+ ## ChatClient vs ChatCompletionClient
104
+
105
+ Use `OpenAIChatClient` when you want the Responses API as your default chat surface.
106
+
107
+ Use `OpenAIChatCompletionClient` when you specifically need the Chat Completions API:
108
+
109
+ ```python
110
+ from agent_framework.openai import OpenAIChatCompletionClient
111
+
112
+ client = OpenAIChatCompletionClient(model="gpt-4o-mini")
113
+ ```
@@ -0,0 +1,45 @@
1
+ # Copyright (c) Microsoft. All rights reserved.
2
+
3
+ """OpenAI integration for Microsoft Agent Framework.
4
+
5
+ This package provides OpenAI client implementations for the Agent Framework,
6
+ including clients for the Responses API and Chat Completions API.
7
+ """
8
+
9
+ import importlib.metadata
10
+
11
+ from ._chat_client import (
12
+ OpenAIChatClient,
13
+ OpenAIChatOptions,
14
+ OpenAIContinuationToken,
15
+ RawOpenAIChatClient,
16
+ )
17
+ from ._chat_completion_client import (
18
+ OpenAIChatCompletionClient,
19
+ OpenAIChatCompletionOptions,
20
+ RawOpenAIChatCompletionClient,
21
+ )
22
+ from ._embedding_client import OpenAIEmbeddingClient, OpenAIEmbeddingOptions
23
+ from ._exceptions import ContentFilterResultSeverity, OpenAIContentFilterException
24
+ from ._shared import OpenAISettings
25
+
26
+ try:
27
+ __version__ = importlib.metadata.version("agent-framework-openai")
28
+ except importlib.metadata.PackageNotFoundError:
29
+ __version__ = "0.0.0" # Fallback for development mode
30
+
31
+ __all__ = [
32
+ "ContentFilterResultSeverity",
33
+ "OpenAIChatClient",
34
+ "OpenAIChatCompletionClient",
35
+ "OpenAIChatCompletionOptions",
36
+ "OpenAIChatOptions",
37
+ "OpenAIContentFilterException",
38
+ "OpenAIContinuationToken",
39
+ "OpenAIEmbeddingClient",
40
+ "OpenAIEmbeddingOptions",
41
+ "OpenAISettings",
42
+ "RawOpenAIChatClient",
43
+ "RawOpenAIChatCompletionClient",
44
+ "__version__",
45
+ ]