livekit-plugins-atmee 0.1.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,12 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ venv*/
5
+ dist/
6
+ build/
7
+ *.egg-info/
8
+ .mypy_cache/
9
+ .pytest_cache/
10
+ .ruff_cache/
11
+ .env
12
+ uv.lock
@@ -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,195 @@
1
+ Metadata-Version: 2.5
2
+ Name: livekit-plugins-atmee
3
+ Version: 0.1.0
4
+ Summary: LiveKit Agents plugin for Atmee avatars: render a talking-head avatar from a single portrait into your agent's room
5
+ Project-URL: Documentation, https://github.com/Atmanity/atmee_livekit_plugin#readme
6
+ Project-URL: Website, https://atmee.ai
7
+ Project-URL: Source, https://github.com/Atmanity/atmee_livekit_plugin
8
+ Author-email: Atmanity <hello@atmee.ai>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: atmee,audio,avatar,livekit,realtime,video,webrtc
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 :: Only
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Multimedia :: Sound/Audio
21
+ Classifier: Topic :: Multimedia :: Video
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: aiohttp>=3.9
25
+ Requires-Dist: livekit-agents<2,>=1.6.8
26
+ Requires-Dist: livekit-api>=1.0
27
+ Description-Content-Type: text/markdown
28
+
29
+ # Atmee avatar plugin for LiveKit Agents
30
+
31
+ Bring your own LiveKit voice agent; Atmee renders a talking-head avatar from a
32
+ single portrait into your room and bills per minute. Works like the other
33
+ avatar plugins for [LiveKit Agents](https://docs.livekit.io/agents/): the
34
+ avatar joins your room as its own participant, your agent's speech drives its
35
+ video.
36
+
37
+ ```python
38
+ from livekit.plugins import atmee
39
+
40
+ avatar_id = await atmee.AtmeeAPI().create_avatar(name="Val", image="portrait.jpg")
41
+
42
+ avatar = atmee.AvatarSession(avatar_id=avatar_id) # ATMEE_API_KEY in the environment
43
+ await avatar.start(session, room=ctx.room)
44
+ await session.start(agent=..., room=ctx.room) # the agent's TTS drives the avatar's video
45
+ ```
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ pip install livekit-plugins-atmee
51
+ ```
52
+
53
+ Python 3.10+, `livekit-agents` 1.6.8 or newer.
54
+
55
+ ## Prerequisites
56
+
57
+ - An **Atmee API key** (`sk_atmee_...`) from your Atmee developer settings, in
58
+ `ATMEE_API_KEY`. Keep it on your agent's side; it never goes to a browser.
59
+ - Your **own LiveKit project** (LiveKit Cloud or self-hosted): `LIVEKIT_URL`,
60
+ `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET` — the same variables your agent
61
+ already uses. Atmee never sees your LiveKit secret: the plugin mints a token
62
+ for the avatar participant locally and hands only that token to Atmee.
63
+
64
+ ## Usage
65
+
66
+ ### 1. Create an avatar from a portrait
67
+
68
+ Once, from a script or your backend (see `examples/create_avatar.py`):
69
+
70
+ ```python
71
+ async with atmee.AtmeeAPI() as api:
72
+ avatar_id = await api.create_avatar(name="Val", image="portrait.jpg") # path, bytes, or https URL
73
+ ```
74
+
75
+ A portrait-only avatar is ready immediately. You can also create and manage
76
+ avatars in the Atmee studio; any avatar of your account with a portrait works.
77
+
78
+ ### 2. Render it in your agent
79
+
80
+ ```python
81
+ async def entrypoint(ctx: agents.JobContext):
82
+ await ctx.connect()
83
+ session = AgentSession(stt=..., llm=..., tts=..., vad=...)
84
+
85
+ avatar = atmee.AvatarSession(avatar_id=os.environ["ATMEE_AVATAR_ID"])
86
+ await avatar.start(session, room=ctx.room) # before session.start
87
+
88
+ await session.start(agent=MyAgent(), room=ctx.room)
89
+ ```
90
+
91
+ `start()` returns as soon as Atmee's rendering worker acknowledged the start
92
+ (about a second); the avatar's video and audio tracks appear in the room a few
93
+ seconds later, published by the participant `atmee-avatar-agent`. Your agent
94
+ publishes no audio of its own — the avatar speaks for it, lips in sync.
95
+
96
+ Options on `AvatarSession`:
97
+
98
+ | Argument | Default | Meaning |
99
+ |---|---|---|
100
+ | `avatar_id` | required | The Atmee avatar to render. |
101
+ | `api_key`, `api_url` | `ATMEE_API_KEY`, `ATMEE_API_URL` | Credentials and API base. |
102
+ | `avatar_participant_identity` | `atmee-avatar-agent` | Identity the avatar joins with; set it when one room hosts several avatars. |
103
+ | `max_duration_seconds` | `3600` | Hard ceiling of the session; also the most it can bill if your agent dies without a trace. |
104
+ | `wait_for` | `"initializing"` | `"avatar_joined"` makes `start()` block until the avatar is in the room. |
105
+ | `metadata` | `None` | Free-form JSON stored with the session on the Atmee side. |
106
+
107
+ `avatar.session_id` and `avatar.session_info` hold the Atmee session after
108
+ `start()`; `avatar.on("avatar_disconnected", ...)` fires if the avatar
109
+ participant leaves while your agent is still running.
110
+
111
+ ### Lifecycle and billing
112
+
113
+ Billing starts when the avatar sees your agent in the room and runs by the
114
+ minute. It stops when
115
+
116
+ - your agent leaves the room or the room closes (the rendering worker notices
117
+ and reports the end itself — a crashed agent stops being billed within
118
+ seconds),
119
+ - `aclose()` runs — registered automatically as a job shutdown callback; it
120
+ ends the session and removes the avatar participant from your room,
121
+ - the rendering worker itself dies or loses contact: it proves it is alive
122
+ once a minute, and a session silent for a few minutes is closed and billed
123
+ only up to the last proof,
124
+ - or the session reaches `max_duration_seconds`.
125
+
126
+ ### Errors
127
+
128
+ All API failures raise `atmee.AtmeeException` with `status_code`, `code`
129
+ (the API's error code, e.g. `insufficient_credits`, `avatar_not_renderable`,
130
+ `missing_publish_on_behalf`) and `message`. Two subclasses are worth
131
+ handling: `AtmeeNoCapacityError` (every rendering worker is busy; check
132
+ `retry_after` and try again later) and `AtmeeAvatarNotReadyError` (the avatar
133
+ has no portrait yet).
134
+
135
+ ## Examples
136
+
137
+ - [`examples/agent.py`](examples/agent.py) — a Deepgram + OpenAI + Silero agent
138
+ with an Atmee avatar; run with `python examples/agent.py dev` and open the
139
+ LiveKit Agents Playground.
140
+ - [`examples/create_avatar.py`](examples/create_avatar.py) — create an avatar
141
+ from a portrait and print its id.
142
+ - [`tests/test_live_agent.py`](tests/test_live_agent.py) — a manual live
143
+ smoke test: a real GPT voice agent (OpenAI LLM + TTS, silero VAD) with an
144
+ Atmee avatar in a real LiveKit room, asserting the avatar joins, publishes
145
+ video, and that its agent-driven audio flows. Skipped unless
146
+ `RUN_LIVE_ATMEE_AGENT=1` and the credentials are set:
147
+
148
+ ```bash
149
+ RUN_LIVE_ATMEE_AGENT=1 ATMEE_API_KEY=… ATMEE_AVATAR_ID=… \
150
+ LIVEKIT_URL=… LIVEKIT_API_KEY=… LIVEKIT_API_SECRET=… OPENAI_API_KEY=… \
151
+ uv run --group dev --with "livekit-agents[openai,silero]" \
152
+ pytest tests/test_live_agent.py -m live -s
153
+ ```
154
+
155
+ ## How it works
156
+
157
+ ```
158
+ your agent (livekit-agents) ── plugin ──► Atmee API (X-Api-Key, https)
159
+ │ │
160
+ │ audio over lk.audio_stream ▼
161
+ └──────────────► your LiveKit room ◄── Atmee rendering worker
162
+ joins as atmee-avatar-agent,
163
+ publishes video + audio
164
+ ```
165
+
166
+ 1. `AvatarSession.start()` mints a LiveKit access token for the avatar
167
+ participant with **your** LiveKit credentials: identity
168
+ `atmee-avatar-agent`, `kind: agent`, a `roomJoin` grant for your room,
169
+ and the attribute `lk.publish_on_behalf` set to your agent's identity.
170
+ Atmee receives only that token, never your secret.
171
+ 2. It calls `POST /v1/avatars/{avatarId}/avatar_sessions` with your LiveKit
172
+ URL and the token. Atmee reserves a session, starts a rendering worker,
173
+ and answers as soon as the worker acknowledged the start.
174
+ 3. The worker joins your room with the token, waits for your agent, receives
175
+ its audio over the LiveKit data stream (`lk.audio_stream`, 16 kHz PCM, the
176
+ standard `DataStreamAudioOutput`), and publishes lip-synced video and
177
+ audio on behalf of your agent.
178
+ 4. When your agent leaves or the room closes, the worker notices from inside
179
+ the room and reports the end to Atmee, which stops billing. `aclose()`
180
+ removes the avatar participant and ends the session explicitly as well.
181
+
182
+ ## Development
183
+
184
+ ```bash
185
+ uv venv && uv pip install -e . --group dev
186
+ uv run pytest -q
187
+ uv run ruff check . && uv run ruff format --check . && uv run mypy
188
+ ```
189
+
190
+ Releases are published to PyPI from `v*` tags by `.github/workflows/publish.yml`
191
+ (PyPI trusted publishing).
192
+
193
+ ## License
194
+
195
+ Apache-2.0.
@@ -0,0 +1,167 @@
1
+ # Atmee avatar plugin for LiveKit Agents
2
+
3
+ Bring your own LiveKit voice agent; Atmee renders a talking-head avatar from a
4
+ single portrait into your room and bills per minute. Works like the other
5
+ avatar plugins for [LiveKit Agents](https://docs.livekit.io/agents/): the
6
+ avatar joins your room as its own participant, your agent's speech drives its
7
+ video.
8
+
9
+ ```python
10
+ from livekit.plugins import atmee
11
+
12
+ avatar_id = await atmee.AtmeeAPI().create_avatar(name="Val", image="portrait.jpg")
13
+
14
+ avatar = atmee.AvatarSession(avatar_id=avatar_id) # ATMEE_API_KEY in the environment
15
+ await avatar.start(session, room=ctx.room)
16
+ await session.start(agent=..., room=ctx.room) # the agent's TTS drives the avatar's video
17
+ ```
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install livekit-plugins-atmee
23
+ ```
24
+
25
+ Python 3.10+, `livekit-agents` 1.6.8 or newer.
26
+
27
+ ## Prerequisites
28
+
29
+ - An **Atmee API key** (`sk_atmee_...`) from your Atmee developer settings, in
30
+ `ATMEE_API_KEY`. Keep it on your agent's side; it never goes to a browser.
31
+ - Your **own LiveKit project** (LiveKit Cloud or self-hosted): `LIVEKIT_URL`,
32
+ `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET` — the same variables your agent
33
+ already uses. Atmee never sees your LiveKit secret: the plugin mints a token
34
+ for the avatar participant locally and hands only that token to Atmee.
35
+
36
+ ## Usage
37
+
38
+ ### 1. Create an avatar from a portrait
39
+
40
+ Once, from a script or your backend (see `examples/create_avatar.py`):
41
+
42
+ ```python
43
+ async with atmee.AtmeeAPI() as api:
44
+ avatar_id = await api.create_avatar(name="Val", image="portrait.jpg") # path, bytes, or https URL
45
+ ```
46
+
47
+ A portrait-only avatar is ready immediately. You can also create and manage
48
+ avatars in the Atmee studio; any avatar of your account with a portrait works.
49
+
50
+ ### 2. Render it in your agent
51
+
52
+ ```python
53
+ async def entrypoint(ctx: agents.JobContext):
54
+ await ctx.connect()
55
+ session = AgentSession(stt=..., llm=..., tts=..., vad=...)
56
+
57
+ avatar = atmee.AvatarSession(avatar_id=os.environ["ATMEE_AVATAR_ID"])
58
+ await avatar.start(session, room=ctx.room) # before session.start
59
+
60
+ await session.start(agent=MyAgent(), room=ctx.room)
61
+ ```
62
+
63
+ `start()` returns as soon as Atmee's rendering worker acknowledged the start
64
+ (about a second); the avatar's video and audio tracks appear in the room a few
65
+ seconds later, published by the participant `atmee-avatar-agent`. Your agent
66
+ publishes no audio of its own — the avatar speaks for it, lips in sync.
67
+
68
+ Options on `AvatarSession`:
69
+
70
+ | Argument | Default | Meaning |
71
+ |---|---|---|
72
+ | `avatar_id` | required | The Atmee avatar to render. |
73
+ | `api_key`, `api_url` | `ATMEE_API_KEY`, `ATMEE_API_URL` | Credentials and API base. |
74
+ | `avatar_participant_identity` | `atmee-avatar-agent` | Identity the avatar joins with; set it when one room hosts several avatars. |
75
+ | `max_duration_seconds` | `3600` | Hard ceiling of the session; also the most it can bill if your agent dies without a trace. |
76
+ | `wait_for` | `"initializing"` | `"avatar_joined"` makes `start()` block until the avatar is in the room. |
77
+ | `metadata` | `None` | Free-form JSON stored with the session on the Atmee side. |
78
+
79
+ `avatar.session_id` and `avatar.session_info` hold the Atmee session after
80
+ `start()`; `avatar.on("avatar_disconnected", ...)` fires if the avatar
81
+ participant leaves while your agent is still running.
82
+
83
+ ### Lifecycle and billing
84
+
85
+ Billing starts when the avatar sees your agent in the room and runs by the
86
+ minute. It stops when
87
+
88
+ - your agent leaves the room or the room closes (the rendering worker notices
89
+ and reports the end itself — a crashed agent stops being billed within
90
+ seconds),
91
+ - `aclose()` runs — registered automatically as a job shutdown callback; it
92
+ ends the session and removes the avatar participant from your room,
93
+ - the rendering worker itself dies or loses contact: it proves it is alive
94
+ once a minute, and a session silent for a few minutes is closed and billed
95
+ only up to the last proof,
96
+ - or the session reaches `max_duration_seconds`.
97
+
98
+ ### Errors
99
+
100
+ All API failures raise `atmee.AtmeeException` with `status_code`, `code`
101
+ (the API's error code, e.g. `insufficient_credits`, `avatar_not_renderable`,
102
+ `missing_publish_on_behalf`) and `message`. Two subclasses are worth
103
+ handling: `AtmeeNoCapacityError` (every rendering worker is busy; check
104
+ `retry_after` and try again later) and `AtmeeAvatarNotReadyError` (the avatar
105
+ has no portrait yet).
106
+
107
+ ## Examples
108
+
109
+ - [`examples/agent.py`](examples/agent.py) — a Deepgram + OpenAI + Silero agent
110
+ with an Atmee avatar; run with `python examples/agent.py dev` and open the
111
+ LiveKit Agents Playground.
112
+ - [`examples/create_avatar.py`](examples/create_avatar.py) — create an avatar
113
+ from a portrait and print its id.
114
+ - [`tests/test_live_agent.py`](tests/test_live_agent.py) — a manual live
115
+ smoke test: a real GPT voice agent (OpenAI LLM + TTS, silero VAD) with an
116
+ Atmee avatar in a real LiveKit room, asserting the avatar joins, publishes
117
+ video, and that its agent-driven audio flows. Skipped unless
118
+ `RUN_LIVE_ATMEE_AGENT=1` and the credentials are set:
119
+
120
+ ```bash
121
+ RUN_LIVE_ATMEE_AGENT=1 ATMEE_API_KEY=… ATMEE_AVATAR_ID=… \
122
+ LIVEKIT_URL=… LIVEKIT_API_KEY=… LIVEKIT_API_SECRET=… OPENAI_API_KEY=… \
123
+ uv run --group dev --with "livekit-agents[openai,silero]" \
124
+ pytest tests/test_live_agent.py -m live -s
125
+ ```
126
+
127
+ ## How it works
128
+
129
+ ```
130
+ your agent (livekit-agents) ── plugin ──► Atmee API (X-Api-Key, https)
131
+ │ │
132
+ │ audio over lk.audio_stream ▼
133
+ └──────────────► your LiveKit room ◄── Atmee rendering worker
134
+ joins as atmee-avatar-agent,
135
+ publishes video + audio
136
+ ```
137
+
138
+ 1. `AvatarSession.start()` mints a LiveKit access token for the avatar
139
+ participant with **your** LiveKit credentials: identity
140
+ `atmee-avatar-agent`, `kind: agent`, a `roomJoin` grant for your room,
141
+ and the attribute `lk.publish_on_behalf` set to your agent's identity.
142
+ Atmee receives only that token, never your secret.
143
+ 2. It calls `POST /v1/avatars/{avatarId}/avatar_sessions` with your LiveKit
144
+ URL and the token. Atmee reserves a session, starts a rendering worker,
145
+ and answers as soon as the worker acknowledged the start.
146
+ 3. The worker joins your room with the token, waits for your agent, receives
147
+ its audio over the LiveKit data stream (`lk.audio_stream`, 16 kHz PCM, the
148
+ standard `DataStreamAudioOutput`), and publishes lip-synced video and
149
+ audio on behalf of your agent.
150
+ 4. When your agent leaves or the room closes, the worker notices from inside
151
+ the room and reports the end to Atmee, which stops billing. `aclose()`
152
+ removes the avatar participant and ends the session explicitly as well.
153
+
154
+ ## Development
155
+
156
+ ```bash
157
+ uv venv && uv pip install -e . --group dev
158
+ uv run pytest -q
159
+ uv run ruff check . && uv run ruff format --check . && uv run mypy
160
+ ```
161
+
162
+ Releases are published to PyPI from `v*` tags by `.github/workflows/publish.yml`
163
+ (PyPI trusted publishing).
164
+
165
+ ## License
166
+
167
+ Apache-2.0.
@@ -0,0 +1,63 @@
1
+ # Copyright 2026 Atmanity
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Atmee avatar plugin for LiveKit Agents.
16
+
17
+ Bring your own LiveKit voice agent; Atmee renders a talking-head avatar from a
18
+ single portrait into your room and bills per minute::
19
+
20
+ from livekit.plugins import atmee
21
+
22
+ avatar_id = await atmee.AtmeeAPI().create_avatar(name="Val", image="portrait.jpg")
23
+
24
+ avatar = atmee.AvatarSession(avatar_id=avatar_id) # ATMEE_API_KEY in the environment
25
+ await avatar.start(session, room=ctx.room)
26
+ await session.start(agent=..., room=ctx.room) # the agent's TTS drives the avatar's video
27
+
28
+ See https://github.com/Atmanity/atmee_livekit_plugin for the architecture notes.
29
+ """
30
+
31
+ from .api import (
32
+ AtmeeAPI,
33
+ AtmeeAvatarNotReadyError,
34
+ AtmeeException,
35
+ AtmeeNoCapacityError,
36
+ AvatarInfo,
37
+ AvatarSessionInfo,
38
+ )
39
+ from .avatar import AvatarSession
40
+ from .version import __version__
41
+
42
+ __all__ = [
43
+ "AtmeeAPI",
44
+ "AtmeeAvatarNotReadyError",
45
+ "AtmeeException",
46
+ "AtmeeNoCapacityError",
47
+ "AvatarInfo",
48
+ "AvatarSession",
49
+ "AvatarSessionInfo",
50
+ "__version__",
51
+ ]
52
+
53
+ from livekit.agents import Plugin
54
+
55
+ from .log import logger
56
+
57
+
58
+ class AtmeePlugin(Plugin):
59
+ def __init__(self) -> None:
60
+ super().__init__(__name__, __version__, __package__, logger)
61
+
62
+
63
+ Plugin.register_plugin(AtmeePlugin())