dialgem 0.1.0b1__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.
Files changed (61) hide show
  1. dialgem-0.1.0b1/.gitignore +11 -0
  2. dialgem-0.1.0b1/CHANGELOG.md +24 -0
  3. dialgem-0.1.0b1/LICENSE +202 -0
  4. dialgem-0.1.0b1/PKG-INFO +281 -0
  5. dialgem-0.1.0b1/README.md +248 -0
  6. dialgem-0.1.0b1/docs/api-surface.md +79 -0
  7. dialgem-0.1.0b1/examples/provision_agent.py +28 -0
  8. dialgem-0.1.0b1/examples/webhook_fastapi.py +29 -0
  9. dialgem-0.1.0b1/pyproject.toml +68 -0
  10. dialgem-0.1.0b1/src/dialgem/__init__.py +70 -0
  11. dialgem-0.1.0b1/src/dialgem/_base_client.py +493 -0
  12. dialgem-0.1.0b1/src/dialgem/_client.py +153 -0
  13. dialgem-0.1.0b1/src/dialgem/_errors.py +102 -0
  14. dialgem-0.1.0b1/src/dialgem/_pagination.py +128 -0
  15. dialgem-0.1.0b1/src/dialgem/_resource.py +30 -0
  16. dialgem-0.1.0b1/src/dialgem/_version.py +1 -0
  17. dialgem-0.1.0b1/src/dialgem/_webhooks.py +164 -0
  18. dialgem-0.1.0b1/src/dialgem/aresources/__init__.py +15 -0
  19. dialgem-0.1.0b1/src/dialgem/aresources/account.py +91 -0
  20. dialgem-0.1.0b1/src/dialgem/aresources/agents.py +234 -0
  21. dialgem-0.1.0b1/src/dialgem/aresources/calls.py +129 -0
  22. dialgem-0.1.0b1/src/dialgem/aresources/catalog.py +135 -0
  23. dialgem-0.1.0b1/src/dialgem/aresources/chats.py +101 -0
  24. dialgem-0.1.0b1/src/dialgem/aresources/contacts.py +207 -0
  25. dialgem-0.1.0b1/src/dialgem/aresources/flows.py +72 -0
  26. dialgem-0.1.0b1/src/dialgem/aresources/llms.py +59 -0
  27. dialgem-0.1.0b1/src/dialgem/aresources/phone_numbers.py +82 -0
  28. dialgem-0.1.0b1/src/dialgem/aresources/simulations.py +123 -0
  29. dialgem-0.1.0b1/src/dialgem/aresources/web_calls.py +44 -0
  30. dialgem-0.1.0b1/src/dialgem/py.typed +0 -0
  31. dialgem-0.1.0b1/src/dialgem/resources/__init__.py +15 -0
  32. dialgem-0.1.0b1/src/dialgem/resources/account.py +89 -0
  33. dialgem-0.1.0b1/src/dialgem/resources/agents.py +232 -0
  34. dialgem-0.1.0b1/src/dialgem/resources/calls.py +127 -0
  35. dialgem-0.1.0b1/src/dialgem/resources/catalog.py +133 -0
  36. dialgem-0.1.0b1/src/dialgem/resources/chats.py +99 -0
  37. dialgem-0.1.0b1/src/dialgem/resources/contacts.py +205 -0
  38. dialgem-0.1.0b1/src/dialgem/resources/flows.py +70 -0
  39. dialgem-0.1.0b1/src/dialgem/resources/llms.py +57 -0
  40. dialgem-0.1.0b1/src/dialgem/resources/phone_numbers.py +80 -0
  41. dialgem-0.1.0b1/src/dialgem/resources/simulations.py +121 -0
  42. dialgem-0.1.0b1/src/dialgem/resources/web_calls.py +42 -0
  43. dialgem-0.1.0b1/src/dialgem/types/__init__.py +0 -0
  44. dialgem-0.1.0b1/src/dialgem/types/_base.py +26 -0
  45. dialgem-0.1.0b1/src/dialgem/types/_shared.py +21 -0
  46. dialgem-0.1.0b1/src/dialgem/types/agent.py +115 -0
  47. dialgem-0.1.0b1/src/dialgem/types/agent_resources.py +91 -0
  48. dialgem-0.1.0b1/src/dialgem/types/agent_version.py +64 -0
  49. dialgem-0.1.0b1/src/dialgem/types/api_key.py +36 -0
  50. dialgem-0.1.0b1/src/dialgem/types/call.py +159 -0
  51. dialgem-0.1.0b1/src/dialgem/types/catalog.py +93 -0
  52. dialgem-0.1.0b1/src/dialgem/types/chat.py +68 -0
  53. dialgem-0.1.0b1/src/dialgem/types/contact.py +139 -0
  54. dialgem-0.1.0b1/src/dialgem/types/flow.py +30 -0
  55. dialgem-0.1.0b1/src/dialgem/types/llm.py +32 -0
  56. dialgem-0.1.0b1/src/dialgem/types/params.py +452 -0
  57. dialgem-0.1.0b1/src/dialgem/types/phone_number.py +80 -0
  58. dialgem-0.1.0b1/src/dialgem/types/session.py +51 -0
  59. dialgem-0.1.0b1/src/dialgem/types/simulation.py +132 -0
  60. dialgem-0.1.0b1/src/dialgem/types/web_call.py +31 -0
  61. dialgem-0.1.0b1/src/dialgem/types/webhook.py +145 -0
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ .mypy_cache/
8
+ .ruff_cache/
9
+ .pytest_cache/
10
+ .env
11
+ .env.*
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0b1 (unreleased)
4
+
5
+ First release. Sync and asyncio clients covering the customer API: agents (functions, knowledge, MCP
6
+ servers, versions), calls, web calls, phone numbers, voices, templates, contacts and lists, simulations and
7
+ sessions; plus webhook signature verification. Campaigns, webhook endpoint management, usage, billing,
8
+ analytics, and contact erasure / do-not-call are deliberately not in the SDK (see `docs/api-surface.md`).
9
+
10
+ `chats` (create, list, retrieve, update, delete, send_message, end, rerun_analysis), `calls.rerun_analysis`, `contacts.retrieve_by_phone` and `api_key.retrieve` need the matching routes in the service.
11
+
12
+ ``sessions.say(session_id, text=..., interrupt=...)`` and ``sessions.release(session_id)`` make the agent speak a line on a live call, and hand a taken-over call back. Off unless the deployment enables live control (``live_control_disabled``). Listening in and taking over run over a WebSocket this SDK does not wrap. ``sessions.update`` now reaches a call on any service instance.
13
+
14
+ `sessions.update(session_id, system_prompt=..., dynamic_variables=...)` changes a live call's prompt and/or variables from the agent's next turn. ``session_id`` is the session's id or the call's ``call_id``. Only that call changes and it is not saved.
15
+
16
+ `llms` (create, list, retrieve, update, delete) saves a prompt and model once; attach it with ``llm_id`` on ``agents.create`` / ``agents.update``. Attaching copies the values; later edits or deletion do not change the agent, and ``llm_id`` cannot be sent with the fields it carries.
17
+
18
+ `agents.mcp_servers.list_tools(agent_id, server_id)` returns the server's tools with descriptions and argument schemas, from a live connection; it stores nothing.
19
+
20
+ `flows` (create, list, retrieve, update, delete) saves a conversation flow once; attach it with ``flow_id`` on ``agents.create`` / ``agents.update``. Attaching copies the flow, so later edits or deletion do not change the agent.
21
+
22
+ Chats are billed per agent reply (a spent balance is a 402 `insufficient_credit`) and `Chat.chat_cost` shows the spend (`None` for a team-member session). `chat_started`, `chat_ended` and `chat_analyzed` webhook events parse to `ChatStartedEvent`, `ChatEndedEvent` and `ChatAnalyzedEvent` (they carry `chat_id` and `chat`, not `call_id`).
23
+
24
+ Mirrors the surface and the safety rules of `@dialgem/sdk` 0.1.0-beta.1 (see `docs/api-surface.md`).
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,281 @@
1
+ Metadata-Version: 2.5
2
+ Name: dialgem
3
+ Version: 0.1.0b1
4
+ Summary: Official Python SDK for the Dialgem voice AI API: agents, calls, phone numbers and webhook verification from your backend.
5
+ Project-URL: Homepage, https://github.com/DialgemAI/dialgem-sdk-python
6
+ Project-URL: Issues, https://github.com/DialgemAI/dialgem-sdk-python/issues
7
+ Author: Dialgem
8
+ License: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: dialgem,sdk,telephony,voice-agent,voice-ai
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: httpx<1,>=0.27
22
+ Requires-Dist: pydantic<3,>=2.6
23
+ Requires-Dist: typing-extensions>=4.7
24
+ Provides-Extra: dev
25
+ Requires-Dist: build; extra == 'dev'
26
+ Requires-Dist: mypy>=1.10; extra == 'dev'
27
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
28
+ Requires-Dist: pytest>=8; extra == 'dev'
29
+ Requires-Dist: respx>=0.21; extra == 'dev'
30
+ Requires-Dist: ruff>=0.5; extra == 'dev'
31
+ Requires-Dist: twine; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ <div align="center">
35
+
36
+ # dialgem
37
+
38
+ **The official Python SDK for the [Dialgem](https://dialgem.com) voice AI API.**
39
+
40
+ Build voice agents, put them on phone numbers, place calls, steer them live, and read transcripts, all from your backend.
41
+
42
+ [![PyPI](https://img.shields.io/pypi/v/dialgem?color=3775A9&logo=pypi&logoColor=white)](https://pypi.org/project/dialgem/)
43
+ [![Python](https://img.shields.io/pypi/pyversions/dialgem?logo=python&logoColor=white)](https://pypi.org/project/dialgem/)
44
+ [![CI](https://img.shields.io/github/actions/workflow/status/DialgemAI/dialgem-sdk-python/ci.yml?branch=main&label=CI&logo=github)](https://github.com/DialgemAI/dialgem-sdk-python/actions/workflows/ci.yml)
45
+ [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
46
+ [![Typed](https://img.shields.io/badge/typing-typed-2a6db2)](https://peps.python.org/pep-0561/)
47
+ [![Stars](https://img.shields.io/github/stars/DialgemAI/dialgem-sdk-python?style=flat&logo=github)](https://github.com/DialgemAI/dialgem-sdk-python/stargazers)
48
+
49
+ [Website](https://dialgem.com) · [Issues](https://github.com/DialgemAI/dialgem-sdk-python/issues) · [Changelog](CHANGELOG.md) · [API surface](docs/api-surface.md)
50
+
51
+ </div>
52
+
53
+ ---
54
+
55
+ ```python
56
+ from dialgem import Dialgem
57
+
58
+ dialgem = Dialgem() # reads DIALGEM_API_KEY
59
+
60
+ agent = dialgem.agents.create(name="Front desk", system_prompt="You answer for Acme Dental.")
61
+ call = dialgem.calls.create_phone_call(to="+14155550123", from_="+14155550100", agent_id=agent.id)
62
+ ```
63
+
64
+ ## Why this SDK
65
+
66
+ - **Sync and async, one surface.** `Dialgem` and `AsyncDialgem` expose the same methods.
67
+ - **Typed end to end.** Request bodies are `TypedDict`s generated from the API schema; responses are pydantic v2 models, so your editor and `mypy` know every field.
68
+ - **Safe by default.** `POST` is never retried (a retry could ring someone twice), `GET`/`PUT`/`PATCH`/`DELETE` retry with backoff and `Retry-After`, and an API change never crashes your integration: unknown or mismatched fields come back as-is with one warning.
69
+ - **Everything a backend needs.** Agents (with tools, knowledge and MCP servers), phone numbers, calls and chats, saved flows and LLMs, contacts, simulations, web calls, live call control, and webhook signature verification.
70
+ - **Small.** Python 3.10+, three dependencies: `httpx`, `pydantic`, `typing_extensions`.
71
+ - **Server-side only.** An organization API key grants full access to your organization. To let a visitor talk to an agent from a web page, see [Web calls](#web-calls).
72
+
73
+ ## Contents
74
+
75
+ [Install](#install) · [Quickstart](#quickstart) · [Async](#async) · [Recipes](#recipes) · [Live call control](#live-call-control) · [Errors](#errors) · [Retries](#retries) · [Responses](#responses) · [Development](#development) · [License](#license)
76
+
77
+ > Which routes this SDK can and cannot reach, and why: [docs/api-surface.md](docs/api-surface.md).
78
+
79
+ ## Install
80
+
81
+ ```sh
82
+ pip install dialgem
83
+ ```
84
+
85
+ ## Quickstart
86
+
87
+ Create an organization API key (`zk_…`) in the Dialgem dashboard and keep it in your server's environment.
88
+
89
+ ```python
90
+ from dialgem import Dialgem
91
+
92
+ dialgem = Dialgem() # reads DIALGEM_API_KEY
93
+
94
+ agent = dialgem.agents.create(
95
+ name="Front desk",
96
+ system_prompt="You are the front desk for {{business_name}}.",
97
+ first_message="Thanks for calling, how can I help?",
98
+ default_dynamic_variables={"business_name": "Acme Dental"},
99
+ )
100
+ ```
101
+
102
+ | Option | Default | |
103
+ |---|---|---|
104
+ | `api_key` | `$DIALGEM_API_KEY` | Organization API key. |
105
+ | `timeout` | `60` | Seconds per attempt. |
106
+ | `max_retries` | `2` | See [Retries](#retries). |
107
+ | `default_headers` | `{}` | Sent with every request. |
108
+ | `http_client` | a new `httpx.Client` | Your own client (proxy, mTLS, instrumentation). You close it. |
109
+
110
+ Every method also takes `request_options={"timeout": 10, "max_retries": 0, "headers": {...}}` for that one request.
111
+
112
+ Field names are the API's own snake_case, passed as keyword arguments and sent exactly as written.
113
+
114
+ ## Async
115
+
116
+ ```python
117
+ import asyncio
118
+ from dialgem import AsyncDialgem
119
+
120
+ async def main():
121
+ async with AsyncDialgem() as dialgem:
122
+ agent = await dialgem.agents.create(name="Front desk")
123
+ async for call in dialgem.calls.list(limit=50): # walks every page
124
+ print(call.id, call.call_status)
125
+
126
+ asyncio.run(main())
127
+ ```
128
+
129
+ ## Recipes
130
+
131
+ ### Provision an agent on a phone number
132
+
133
+ ```python
134
+ agent = dialgem.agents.create(name="Front desk", system_prompt="…")
135
+ number = dialgem.phone_numbers.create(phone_number="+14155550100")
136
+
137
+ dialgem.phone_numbers.update(
138
+ number.id,
139
+ inbound_agent_id=agent.id,
140
+ set_inbound_agent=True, # inbound_agent_id is ignored without this
141
+ )
142
+ ```
143
+
144
+ Agents also have tools, knowledge and MCP servers:
145
+
146
+ ```python
147
+ dialgem.agents.functions.create(
148
+ agent.id,
149
+ name="lookup_order",
150
+ url="https://example.com/api/orders/lookup",
151
+ parameters={"type": "object", "properties": {"order_id": {"type": "string"}}},
152
+ )
153
+ dialgem.agents.knowledge.create(agent.id, filename="faq.txt", content=faq_text)
154
+ ```
155
+
156
+ ### Place an outbound call
157
+
158
+ ```python
159
+ call = dialgem.calls.create_phone_call(
160
+ to="+14155550123",
161
+ from_="+14155550100", # `from_`: the wire name; must be a number on your organization
162
+ agent_id=agent.id,
163
+ metadata={"order": "A-1042"},
164
+ dialgem_llm_dynamic_variables={"customer_name": "Ada"},
165
+ )
166
+ ```
167
+
168
+ `create_phone_call` is a POST and is **not retried**. A retry after an ambiguous 502 could ring the person twice.
169
+
170
+ ### List calls
171
+
172
+ ```python
173
+ for call in dialgem.calls.list(agent_id=agent.id, start_after=1730000000000, limit=50):
174
+ print(call.id, call.transcript_text)
175
+
176
+ page = dialgem.calls.list(limit=50) # or one page at a time
177
+ page.data, page.has_next_page(), page.get_next_page()
178
+ ```
179
+
180
+ ### Web calls
181
+
182
+ Your **server** mints a one-use token; the page connects with `@dialgem/client` using that token alone, so your API key never reaches the browser.
183
+
184
+ ```python
185
+ # once: allow the page's origin
186
+ dialgem.web_calls.update_settings(allowed_origins=["https://app.example.com"])
187
+
188
+ # per visitor, from your own endpoint
189
+ web_call = dialgem.web_calls.create(agent_id="AGENT_ID", metadata={"visitor": "v_123"})
190
+ return {"access_token": web_call.access_token} # 60 seconds, single use
191
+ ```
192
+
193
+ ### Verify webhooks
194
+
195
+ Verify against the **raw request body** exactly as received. A body parsed and re-serialized no longer matches.
196
+
197
+ ```python
198
+ from dialgem import webhooks, WebhookVerificationError
199
+
200
+ # FastAPI
201
+ @app.post("/dialgem")
202
+ async def hook(request: Request):
203
+ body = await request.body()
204
+ try:
205
+ event = webhooks.construct_event(body, request.headers.get("x-dialgem-signature"), SECRET)
206
+ except WebhookVerificationError:
207
+ return Response(status_code=400)
208
+ if event.event == "call_ended":
209
+ print(event.call.id, event.call.duration_ms)
210
+ return Response(status_code=204)
211
+ ```
212
+
213
+ `construct_function_call` does the same for the requests Dialgem sends to your agent's custom functions. Signatures carry a timestamp and are rejected after five minutes (`tolerance_ms=`).
214
+
215
+ ## Live call control
216
+
217
+ Steer a call while it is happening. `session_id` is the session's id from `sessions.list()` or the call's own `call_id`, and the call can be on any service instance.
218
+
219
+ ```python
220
+ # Change this call's prompt or variables from the agent's next turn (not saved, only this call).
221
+ dialgem.sessions.update(call.id, dynamic_variables={"plan": "pro"})
222
+
223
+ # Make the agent say a line in its own voice; interrupt=True cuts in now.
224
+ dialgem.sessions.say(call.id, text="One moment while I check that.")
225
+
226
+ # Give a taken-over call back to the agent.
227
+ dialgem.sessions.release(call.id)
228
+ ```
229
+
230
+ `say` and `release` are **off unless your deployment enables live control** (`PermissionDeniedError` with `err_code == "live_control_disabled"`), and are for owners, admins and API keys only. Listening in and taking a call over run over a WebSocket (`/v1/agent/sessions/{id}/live`), which this SDK does not wrap.
231
+
232
+ ## Errors
233
+
234
+ ```python
235
+ from dialgem import NotFoundError, APIError, APIConnectionError
236
+
237
+ try:
238
+ dialgem.agents.retrieve("nope")
239
+ except NotFoundError as e:
240
+ print(e.status, e.err_code, e.request_id) # quote request_id to support
241
+ except APIError as e:
242
+ print(e.status, e.issues) # e.g. 422 validation issues
243
+ except APIConnectionError:
244
+ ... # no response (APITimeoutError is a subclass)
245
+ ```
246
+
247
+ `400 BadRequestError`, `401 AuthenticationError`, `403 PermissionDeniedError`, `404 NotFoundError`, `409 ConflictError`, `422 UnprocessableEntityError`, `429 RateLimitError`, `5xx InternalServerError`. All derive from `APIError` → `DialgemError`.
248
+
249
+ ## Retries
250
+
251
+ GET, PUT, PATCH and DELETE retry up to `max_retries` times on 408, 429, 5xx and connection errors, with exponential backoff and jitter, honouring `Retry-After` / `Retry-After-Ms` (capped at 60 s). **POST is never retried** unless you pass `request_options={"max_retries": n}`. 409 is never retried. File uploads are never retried.
252
+
253
+ ## Responses
254
+
255
+ Responses are pydantic models. Unknown fields are kept (as attributes and in `model.model_extra`), and `model.to_dict()` returns the JSON as the API sent it. If the API returns something that does not fit the SDK's model (a field changed type or went missing), the SDK returns it **unvalidated** and issues one `UserWarning` per model instead of raising, so an API change never takes your integration down. Upgrade the SDK when you see it.
256
+
257
+ ## Development
258
+
259
+ ```sh
260
+ python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
261
+ pip install -e ".[dev]"
262
+ pytest
263
+ mypy src && ruff check .
264
+ python scripts/unasync.py # regenerate src/dialgem/aresources from src/dialgem/resources
265
+ python scripts/gen_params.py # regenerate request types from openapi/openapi.json
266
+ python scripts/mutate.py # mutation spot-check of the safety rules
267
+ ```
268
+
269
+ `src/dialgem/aresources/` and `src/dialgem/types/params.py` are generated; edit the sync resources and the OpenAPI snapshot, never the generated files. CI fails if they are stale.
270
+
271
+ ## License
272
+
273
+ Apache-2.0
274
+
275
+ ---
276
+
277
+ <div align="center">
278
+
279
+ If this SDK saves you time, a ⭐ on [GitHub](https://github.com/DialgemAI/dialgem-sdk-python) helps other developers find it.
280
+
281
+ </div>