livekit-plugins-satham 0.1.1__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,3 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ dist/
@@ -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,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: livekit-plugins-satham
3
+ Version: 0.1.1
4
+ Summary: Satham realtime speech-to-speech for LiveKit Agents
5
+ Project-URL: Homepage, https://satham.ai
6
+ Author: Satham
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Keywords: livekit,livekit-agents,plugin,realtime,satham,speech-to-speech,voice-agent
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Framework :: AsyncIO
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: livekit-agents~=1.8.12
24
+ Requires-Dist: satham~=0.1.1
25
+ Description-Content-Type: text/markdown
26
+
27
+ # livekit-plugins-satham
28
+
29
+ Satham's realtime speech-to-speech model (satham-1) as a `RealtimeModel` for LiveKit Agents. Your
30
+ LiveKit agent keeps its own instructions and tools; Satham hears the caller, ends turns, replies in
31
+ speech and handles barge-in, so the `AgentSession` needs no STT, LLM, TTS or VAD. The parameters
32
+ follow LiveKit's OpenAI `RealtimeModel`, so moving an agent from OpenAI to Satham is mostly a one-line
33
+ change.
34
+
35
+ LiveKit Agents 1.8; Python 3.11+.
36
+
37
+ ```sh
38
+ pip install livekit-plugins-satham
39
+ ```
40
+
41
+ ## Use
42
+
43
+ You pass your Satham endpoint and API key (or set `SATHAM_URL` and `SATHAM_API_KEY`); there is no
44
+ default server.
45
+
46
+ ```python
47
+ import os
48
+
49
+ from livekit.agents import (
50
+ Agent,
51
+ AgentServer,
52
+ AgentSession,
53
+ JobContext,
54
+ RunContext,
55
+ cli,
56
+ function_tool,
57
+ llm,
58
+ )
59
+ from livekit.plugins import satham
60
+
61
+
62
+ class SiteVisit(Agent):
63
+ def __init__(self) -> None:
64
+ # The agent's role and tools are Satham's instructions and tools, as they stand.
65
+ super().__init__(instructions="You are Asha, who books site visits for Example Homes.")
66
+
67
+ @function_tool
68
+ async def end_call(self, context: RunContext, reason: str = "done") -> llm.ToolResult:
69
+ """End the call when the conversation is over. Say a short goodbye in the same turn."""
70
+ await context.wait_for_playout() # let the goodbye finish
71
+ ... # hang up, e.g. delete the room
72
+ return llm.ToolResult("ended", reply_required=False)
73
+
74
+
75
+ server = AgentServer()
76
+
77
+
78
+ @server.rtc_session()
79
+ async def entrypoint(ctx: JobContext) -> None:
80
+ await ctx.connect()
81
+ session = AgentSession(
82
+ llm=satham.RealtimeModel( # was: openai.realtime.RealtimeModel(voice=...)
83
+ url=os.environ["SATHAM_URL"],
84
+ api_key=os.environ["SATHAM_API_KEY"],
85
+ greeting="Hello, this is Asha from Example Homes. Is this a good time?",
86
+ language="en",
87
+ language_switch="auto",
88
+ )
89
+ )
90
+ await session.start(agent=SiteVisit(), room=ctx.room)
91
+
92
+
93
+ if __name__ == "__main__":
94
+ cli.run_app(server)
95
+ ```
96
+
97
+ - **Instructions and tools.** The LiveKit agent's `instructions` become the call's instructions and
98
+ its `@function_tool`s the call's tools, with nothing else to set. Both can change mid-call
99
+ (`agent.update_instructions()`, `agent.update_tools()`).
100
+ - **The opening and fixed words.** With `greeting`, the agent says it first. Otherwise
101
+ `session.generate_reply(instructions=...)` asks for a reply now (Satham's `response.create`; use it in
102
+ `on_enter` to open the call), and `session.say(text)` speaks fixed words in the call's voice
103
+ (`response.say`) with no TTS. With neither, the caller speaks first.
104
+ - **Mid-call changes.** `model.update_options(...)` changes any control on every live call;
105
+ `session.current_agent.realtime_llm_session.update_options(...)` changes one call.
106
+ - **Language changes** are emitted as `session_updated` (a `satham.SessionUpdated`: the language, and
107
+ the reason `caller`, `reply` or `client`).
108
+
109
+ ## From OpenAI RealtimeModel to Satham
110
+
111
+ <!-- openai -->
112
+ | OpenAI `RealtimeModel` | Satham `RealtimeModel` | Supported | Notes |
113
+ | --- | --- | --- | --- |
114
+ | `model` | `model` | yes | default `"satham-1"` |
115
+ | `voice` | `voice` | yes | a Satham voice name, or a cloned voice's id |
116
+ | `modalities` | `modalities` | yes | `["audio", "text"]`, `["audio"]`, or `["text"]`, which hands the words to the session's TTS as OpenAI's text mode does |
117
+ | `temperature` | `temperature` | yes | |
118
+ | `turn_detection` | `turn_detection` | yes | `server_vad` and `semantic_vad` are both Satham's endpointing; `None`/`null` leaves turns to LiveKit; Satham adds `barge_in`, `continue_within_ms`, ... |
119
+ | `input_audio_noise_reduction` | `input_audio_noise_reduction` | yes | `near_field` or `far_field`; `"none"` turns it off, and null keeps the server's default (on); Satham adds `strength_db` and `apply_to_transcription` |
120
+ | `input_audio_transcription` | `input_audio_transcription` | partly | `enabled` and `code_mixed`; Satham transcribes with its own models, so OpenAI's `model` and `prompt` are ignored |
121
+ | `max_response_output_tokens` | `max_response_output_tokens` | yes | or `"inf"` |
122
+ | `speed` | `speed` | yes | |
123
+ | `tool_choice` | `tool_choice` | yes | preview: needs a server with tool support |
124
+ | `api_key` | `api_key` | yes | your Satham key |
125
+ | `base_url` | `url` | yes | your Satham endpoint |
126
+ | Agent instructions | Agent instructions | yes | can change mid-call |
127
+ | `generate_reply()` | `generate_reply()` | yes | `response.create`; `instructions` guide that reply alone |
128
+ | `session.say()` | `session.say()` | yes | `response.say`, no TTS needed (agents-js: call it on the realtime session) |
129
+ | tracing, truncation, reasoning | - | no | not applicable |
130
+ | azure_deployment, entra_token, api_version | - | no | not applicable |
131
+ | max_session_duration, conn_options | - | no | `connect_timeout` / `connectTimeoutMs` instead |
132
+ <!-- /openai -->
133
+
134
+ ## Controls
135
+
136
+ Every keyword of `RealtimeModel(...)` and `update_options(...)` besides `url`, `api_key` and
137
+ `connect_timeout`. `modalities`, `turn_detection` and `input_audio_transcription` also decide what the
138
+ model tells LiveKit it does, so they are fixed for a model once made. Controls you leave out are not
139
+ sent; values are checked against these ranges, or the server's from `GET /v1/info`.
140
+
141
+ The controls marked "needs session controls" need a Satham server with session controls (its
142
+ `GET /v1/info` lists `controls`, as the server does since 2026-11-16); an older server refuses them
143
+ when the call starts. `greeting` and `agent` belong to the start of a call. Setting
144
+ `input_audio_noise_reduction`'s `mode` alone resets `strength_db` to that mode's preset, so send both
145
+ to keep a custom strength; `None` leaves noise reduction at the server's default (on), and `"none"`
146
+ turns it off. `agent` is an optional
147
+ preset on the server and is not needed.
148
+
149
+ <!-- controls -->
150
+ | Option | Range | Default | OpenAI equivalent | Notes |
151
+ | --- | --- | --- | --- | --- |
152
+ | `instructions` | text, up to 16000 characters | none | - | the agent's role; from the LiveKit agent or Pipecat context in the adapters |
153
+ | `greeting` | text, up to 1000 characters | none | - | said first; without one the caller speaks first |
154
+ | `tools` | up to 128 functions | none | - | preview: needs a server with tool support |
155
+ | `tool_choice` | see notes | "auto" | `tool_choice` | "auto", "none", "required" or one function |
156
+ | `agent` | text, up to 64 characters | none | - | optional: a preset agent on the server, such as a demo's |
157
+ | `model` | text, up to 64 characters | "satham-1" | `model` | "satham-1" only today; needs session controls |
158
+ | `modalities` | list | ["audio", "text"] | `modalities` | ["audio", "text"], ["audio"], or ["text"]: words only, for your own TTS; needs session controls |
159
+ | `language` | `auto`, `hi`, `ta`, `te`, `kn`, `bn`, `pa`, `en` | "auto" | - | |
160
+ | `language_switch` | `auto`, `off`, or `None` | "auto" | - | |
161
+ | `voice_on_language_switch` | `keep`, `native`, or `None` | "keep" | - | |
162
+ | `turn_detection.enabled` | `True` / `False` | true | `turn_detection=None` | false (or turn_detection=None): the client ends each turn; needs session controls |
163
+ | `turn_detection.type` | `server_vad`, `semantic_vad` | "server_vad" | `turn_detection.type` | needs session controls |
164
+ | `turn_detection.threshold` | 0.1 to 0.95 | 0.5 | `turn_detection.threshold` | the speech detector's threshold; needs session controls |
165
+ | `turn_detection.eagerness` | `auto`, `low`, `medium`, `high` | "auto" | `turn_detection.eagerness` | semantic_vad's end-of-turn wait; needs session controls |
166
+ | `turn_detection.prefix_padding_ms` | 0 to 1000 | 300 | `turn_detection.prefix_padding_ms` | needs session controls |
167
+ | `turn_detection.min_speech_ms` | 50 to 1000 | 100 | - | needs session controls |
168
+ | `turn_detection.silence_duration_ms` | 150 to 2000 | 350 | `turn_detection.silence_duration_ms` | server_vad's end-of-turn wait; needs session controls |
169
+ | `turn_detection.create_response` | `True` / `False` | true | `turn_detection.create_response` | answer each turn at once; needs session controls |
170
+ | `turn_detection.interrupt_response` | `True` / `False` | true | `turn_detection.interrupt_response` | barge-in on or off; needs session controls |
171
+ | `turn_detection.barge_in.min_speech_ms` | 0 to 2000 | 400 | - | needs session controls |
172
+ | `turn_detection.barge_in.min_probability` | 0 to 1 | 0.8 | - | needs session controls |
173
+ | `turn_detection.barge_in.min_dbfs` | -90 to 0, or `None` | -40 | - | needs session controls |
174
+ | `turn_detection.continue_within_ms` | 0 to 5000, or `None` | 2000 | - | the caller carrying on in the same turn; null: off; needs session controls |
175
+ | `turn_detection.continue_max_heard_ms` | 0 to 5000 | 1000 | - | needs session controls |
176
+ | `input_audio_noise_reduction.enabled` | `True` / `False` | true | `input_audio_noise_reduction={"type": "none"}` | false, "none" or {"type": "none"}: off; needs session controls |
177
+ | `input_audio_noise_reduction.mode` | `near_field`, `far_field` | "near_field" | `input_audio_noise_reduction.type` | resets strength_db to the mode's preset (12 or 30 dB) unless both are sent; needs session controls |
178
+ | `input_audio_noise_reduction.strength_db` | 0 to 100 | 12 | - | needs session controls |
179
+ | `input_audio_noise_reduction.apply_to_transcription` | `True` / `False` | false | - | needs session controls |
180
+ | `input_audio_transcription.enabled` | `True` / `False` | true | `input_audio_transcription=None` | transcript events to the client; needs session controls |
181
+ | `input_audio_transcription.code_mixed` | `True` / `False` | true | - | English words in Latin script, and digits; needs session controls |
182
+ | `voice` | text, up to 64 characters | the language's | `voice` | |
183
+ | `breaths` | `True` / `False`, or `None` | off | - | |
184
+ | `natural_pauses` | `True` / `False`, or `None` | off | - | |
185
+ | `continuation` | `True` / `False`, or `None` | true | - | each phrase carries on from the one before; needs session controls |
186
+ | `speed` | 1 to 1 | 1.0 | `speed` | 1.0 only today; needs session controls |
187
+ | `phrasing.first_phrase_max_chars` | 1 to 120 | 120 | - | at least min_phrase_chars; needs session controls |
188
+ | `phrasing.min_phrase_chars` | 1 to 120 | 20 | - | needs session controls |
189
+ | `normalise_numbers` | `True` / `False` | true | - | numbers and amounts said as words; needs session controls |
190
+ | `pronunciations` | word to respelling | none | - | {word: respelling}, up to 200; needs session controls |
191
+ | `temperature` | 0.6 to 1.2 | 0.7 | `temperature` | needs session controls |
192
+ | `top_p` | 0.05 to 1 | 0.8 | - | needs session controls |
193
+ | `max_response_output_tokens` | 1 to 4096 | 320 | `max_response_output_tokens` | or "inf"; never above the server's; needs session controls |
194
+ | `tone` | `auto`, `conversational`, `happy`, `sad`, `excited`, `professional` | "auto" | - | "auto": the model picks; needs session controls |
195
+ | `repeat_guard` | `True` / `False` | true | - | re-asks a reply that repeats a recent one; needs session controls |
196
+ | `drift_guard` | `True` / `False` | true | - | keeps replies in the call's language; needs session controls |
197
+ <!-- /controls -->
198
+
199
+ ## Text mode, manual turns, tools, interruptions
200
+
201
+ - **`modalities=["text"]`.** The agent's words go to the `AgentSession`'s TTS, as with OpenAI's text
202
+ mode; give the session a `tts`.
203
+ - **`turn_detection=None`.** LiveKit's own turn detection (the session's VAD and turn detector) ends
204
+ each turn: the plugin commits the caller's audio, and `generate_reply()` returns the reply.
205
+ - **Tools (preview: they need a Satham server with tool support).** Each call the agent makes runs
206
+ your tool; its result goes back to the server, which replies unless the tool returns
207
+ `llm.ToolResult(..., reply_required=False)`.
208
+ - **Interruptions.** The caller speaking over the agent interrupts it and the playout stops at once.
209
+ LiveKit mutes the caller for the first 3 s of agent speech by default (`AgentSession(
210
+ aec_warmup_duration=3.0)`, off for SIP calls); set it to `None` where echo cancellation is good.
211
+ - **Not supported:** video, and reconnection (a dropped connection ends the call with an
212
+ unrecoverable error).
@@ -0,0 +1,186 @@
1
+ # livekit-plugins-satham
2
+
3
+ Satham's realtime speech-to-speech model (satham-1) as a `RealtimeModel` for LiveKit Agents. Your
4
+ LiveKit agent keeps its own instructions and tools; Satham hears the caller, ends turns, replies in
5
+ speech and handles barge-in, so the `AgentSession` needs no STT, LLM, TTS or VAD. The parameters
6
+ follow LiveKit's OpenAI `RealtimeModel`, so moving an agent from OpenAI to Satham is mostly a one-line
7
+ change.
8
+
9
+ LiveKit Agents 1.8; Python 3.11+.
10
+
11
+ ```sh
12
+ pip install livekit-plugins-satham
13
+ ```
14
+
15
+ ## Use
16
+
17
+ You pass your Satham endpoint and API key (or set `SATHAM_URL` and `SATHAM_API_KEY`); there is no
18
+ default server.
19
+
20
+ ```python
21
+ import os
22
+
23
+ from livekit.agents import (
24
+ Agent,
25
+ AgentServer,
26
+ AgentSession,
27
+ JobContext,
28
+ RunContext,
29
+ cli,
30
+ function_tool,
31
+ llm,
32
+ )
33
+ from livekit.plugins import satham
34
+
35
+
36
+ class SiteVisit(Agent):
37
+ def __init__(self) -> None:
38
+ # The agent's role and tools are Satham's instructions and tools, as they stand.
39
+ super().__init__(instructions="You are Asha, who books site visits for Example Homes.")
40
+
41
+ @function_tool
42
+ async def end_call(self, context: RunContext, reason: str = "done") -> llm.ToolResult:
43
+ """End the call when the conversation is over. Say a short goodbye in the same turn."""
44
+ await context.wait_for_playout() # let the goodbye finish
45
+ ... # hang up, e.g. delete the room
46
+ return llm.ToolResult("ended", reply_required=False)
47
+
48
+
49
+ server = AgentServer()
50
+
51
+
52
+ @server.rtc_session()
53
+ async def entrypoint(ctx: JobContext) -> None:
54
+ await ctx.connect()
55
+ session = AgentSession(
56
+ llm=satham.RealtimeModel( # was: openai.realtime.RealtimeModel(voice=...)
57
+ url=os.environ["SATHAM_URL"],
58
+ api_key=os.environ["SATHAM_API_KEY"],
59
+ greeting="Hello, this is Asha from Example Homes. Is this a good time?",
60
+ language="en",
61
+ language_switch="auto",
62
+ )
63
+ )
64
+ await session.start(agent=SiteVisit(), room=ctx.room)
65
+
66
+
67
+ if __name__ == "__main__":
68
+ cli.run_app(server)
69
+ ```
70
+
71
+ - **Instructions and tools.** The LiveKit agent's `instructions` become the call's instructions and
72
+ its `@function_tool`s the call's tools, with nothing else to set. Both can change mid-call
73
+ (`agent.update_instructions()`, `agent.update_tools()`).
74
+ - **The opening and fixed words.** With `greeting`, the agent says it first. Otherwise
75
+ `session.generate_reply(instructions=...)` asks for a reply now (Satham's `response.create`; use it in
76
+ `on_enter` to open the call), and `session.say(text)` speaks fixed words in the call's voice
77
+ (`response.say`) with no TTS. With neither, the caller speaks first.
78
+ - **Mid-call changes.** `model.update_options(...)` changes any control on every live call;
79
+ `session.current_agent.realtime_llm_session.update_options(...)` changes one call.
80
+ - **Language changes** are emitted as `session_updated` (a `satham.SessionUpdated`: the language, and
81
+ the reason `caller`, `reply` or `client`).
82
+
83
+ ## From OpenAI RealtimeModel to Satham
84
+
85
+ <!-- openai -->
86
+ | OpenAI `RealtimeModel` | Satham `RealtimeModel` | Supported | Notes |
87
+ | --- | --- | --- | --- |
88
+ | `model` | `model` | yes | default `"satham-1"` |
89
+ | `voice` | `voice` | yes | a Satham voice name, or a cloned voice's id |
90
+ | `modalities` | `modalities` | yes | `["audio", "text"]`, `["audio"]`, or `["text"]`, which hands the words to the session's TTS as OpenAI's text mode does |
91
+ | `temperature` | `temperature` | yes | |
92
+ | `turn_detection` | `turn_detection` | yes | `server_vad` and `semantic_vad` are both Satham's endpointing; `None`/`null` leaves turns to LiveKit; Satham adds `barge_in`, `continue_within_ms`, ... |
93
+ | `input_audio_noise_reduction` | `input_audio_noise_reduction` | yes | `near_field` or `far_field`; `"none"` turns it off, and null keeps the server's default (on); Satham adds `strength_db` and `apply_to_transcription` |
94
+ | `input_audio_transcription` | `input_audio_transcription` | partly | `enabled` and `code_mixed`; Satham transcribes with its own models, so OpenAI's `model` and `prompt` are ignored |
95
+ | `max_response_output_tokens` | `max_response_output_tokens` | yes | or `"inf"` |
96
+ | `speed` | `speed` | yes | |
97
+ | `tool_choice` | `tool_choice` | yes | preview: needs a server with tool support |
98
+ | `api_key` | `api_key` | yes | your Satham key |
99
+ | `base_url` | `url` | yes | your Satham endpoint |
100
+ | Agent instructions | Agent instructions | yes | can change mid-call |
101
+ | `generate_reply()` | `generate_reply()` | yes | `response.create`; `instructions` guide that reply alone |
102
+ | `session.say()` | `session.say()` | yes | `response.say`, no TTS needed (agents-js: call it on the realtime session) |
103
+ | tracing, truncation, reasoning | - | no | not applicable |
104
+ | azure_deployment, entra_token, api_version | - | no | not applicable |
105
+ | max_session_duration, conn_options | - | no | `connect_timeout` / `connectTimeoutMs` instead |
106
+ <!-- /openai -->
107
+
108
+ ## Controls
109
+
110
+ Every keyword of `RealtimeModel(...)` and `update_options(...)` besides `url`, `api_key` and
111
+ `connect_timeout`. `modalities`, `turn_detection` and `input_audio_transcription` also decide what the
112
+ model tells LiveKit it does, so they are fixed for a model once made. Controls you leave out are not
113
+ sent; values are checked against these ranges, or the server's from `GET /v1/info`.
114
+
115
+ The controls marked "needs session controls" need a Satham server with session controls (its
116
+ `GET /v1/info` lists `controls`, as the server does since 2026-11-16); an older server refuses them
117
+ when the call starts. `greeting` and `agent` belong to the start of a call. Setting
118
+ `input_audio_noise_reduction`'s `mode` alone resets `strength_db` to that mode's preset, so send both
119
+ to keep a custom strength; `None` leaves noise reduction at the server's default (on), and `"none"`
120
+ turns it off. `agent` is an optional
121
+ preset on the server and is not needed.
122
+
123
+ <!-- controls -->
124
+ | Option | Range | Default | OpenAI equivalent | Notes |
125
+ | --- | --- | --- | --- | --- |
126
+ | `instructions` | text, up to 16000 characters | none | - | the agent's role; from the LiveKit agent or Pipecat context in the adapters |
127
+ | `greeting` | text, up to 1000 characters | none | - | said first; without one the caller speaks first |
128
+ | `tools` | up to 128 functions | none | - | preview: needs a server with tool support |
129
+ | `tool_choice` | see notes | "auto" | `tool_choice` | "auto", "none", "required" or one function |
130
+ | `agent` | text, up to 64 characters | none | - | optional: a preset agent on the server, such as a demo's |
131
+ | `model` | text, up to 64 characters | "satham-1" | `model` | "satham-1" only today; needs session controls |
132
+ | `modalities` | list | ["audio", "text"] | `modalities` | ["audio", "text"], ["audio"], or ["text"]: words only, for your own TTS; needs session controls |
133
+ | `language` | `auto`, `hi`, `ta`, `te`, `kn`, `bn`, `pa`, `en` | "auto" | - | |
134
+ | `language_switch` | `auto`, `off`, or `None` | "auto" | - | |
135
+ | `voice_on_language_switch` | `keep`, `native`, or `None` | "keep" | - | |
136
+ | `turn_detection.enabled` | `True` / `False` | true | `turn_detection=None` | false (or turn_detection=None): the client ends each turn; needs session controls |
137
+ | `turn_detection.type` | `server_vad`, `semantic_vad` | "server_vad" | `turn_detection.type` | needs session controls |
138
+ | `turn_detection.threshold` | 0.1 to 0.95 | 0.5 | `turn_detection.threshold` | the speech detector's threshold; needs session controls |
139
+ | `turn_detection.eagerness` | `auto`, `low`, `medium`, `high` | "auto" | `turn_detection.eagerness` | semantic_vad's end-of-turn wait; needs session controls |
140
+ | `turn_detection.prefix_padding_ms` | 0 to 1000 | 300 | `turn_detection.prefix_padding_ms` | needs session controls |
141
+ | `turn_detection.min_speech_ms` | 50 to 1000 | 100 | - | needs session controls |
142
+ | `turn_detection.silence_duration_ms` | 150 to 2000 | 350 | `turn_detection.silence_duration_ms` | server_vad's end-of-turn wait; needs session controls |
143
+ | `turn_detection.create_response` | `True` / `False` | true | `turn_detection.create_response` | answer each turn at once; needs session controls |
144
+ | `turn_detection.interrupt_response` | `True` / `False` | true | `turn_detection.interrupt_response` | barge-in on or off; needs session controls |
145
+ | `turn_detection.barge_in.min_speech_ms` | 0 to 2000 | 400 | - | needs session controls |
146
+ | `turn_detection.barge_in.min_probability` | 0 to 1 | 0.8 | - | needs session controls |
147
+ | `turn_detection.barge_in.min_dbfs` | -90 to 0, or `None` | -40 | - | needs session controls |
148
+ | `turn_detection.continue_within_ms` | 0 to 5000, or `None` | 2000 | - | the caller carrying on in the same turn; null: off; needs session controls |
149
+ | `turn_detection.continue_max_heard_ms` | 0 to 5000 | 1000 | - | needs session controls |
150
+ | `input_audio_noise_reduction.enabled` | `True` / `False` | true | `input_audio_noise_reduction={"type": "none"}` | false, "none" or {"type": "none"}: off; needs session controls |
151
+ | `input_audio_noise_reduction.mode` | `near_field`, `far_field` | "near_field" | `input_audio_noise_reduction.type` | resets strength_db to the mode's preset (12 or 30 dB) unless both are sent; needs session controls |
152
+ | `input_audio_noise_reduction.strength_db` | 0 to 100 | 12 | - | needs session controls |
153
+ | `input_audio_noise_reduction.apply_to_transcription` | `True` / `False` | false | - | needs session controls |
154
+ | `input_audio_transcription.enabled` | `True` / `False` | true | `input_audio_transcription=None` | transcript events to the client; needs session controls |
155
+ | `input_audio_transcription.code_mixed` | `True` / `False` | true | - | English words in Latin script, and digits; needs session controls |
156
+ | `voice` | text, up to 64 characters | the language's | `voice` | |
157
+ | `breaths` | `True` / `False`, or `None` | off | - | |
158
+ | `natural_pauses` | `True` / `False`, or `None` | off | - | |
159
+ | `continuation` | `True` / `False`, or `None` | true | - | each phrase carries on from the one before; needs session controls |
160
+ | `speed` | 1 to 1 | 1.0 | `speed` | 1.0 only today; needs session controls |
161
+ | `phrasing.first_phrase_max_chars` | 1 to 120 | 120 | - | at least min_phrase_chars; needs session controls |
162
+ | `phrasing.min_phrase_chars` | 1 to 120 | 20 | - | needs session controls |
163
+ | `normalise_numbers` | `True` / `False` | true | - | numbers and amounts said as words; needs session controls |
164
+ | `pronunciations` | word to respelling | none | - | {word: respelling}, up to 200; needs session controls |
165
+ | `temperature` | 0.6 to 1.2 | 0.7 | `temperature` | needs session controls |
166
+ | `top_p` | 0.05 to 1 | 0.8 | - | needs session controls |
167
+ | `max_response_output_tokens` | 1 to 4096 | 320 | `max_response_output_tokens` | or "inf"; never above the server's; needs session controls |
168
+ | `tone` | `auto`, `conversational`, `happy`, `sad`, `excited`, `professional` | "auto" | - | "auto": the model picks; needs session controls |
169
+ | `repeat_guard` | `True` / `False` | true | - | re-asks a reply that repeats a recent one; needs session controls |
170
+ | `drift_guard` | `True` / `False` | true | - | keeps replies in the call's language; needs session controls |
171
+ <!-- /controls -->
172
+
173
+ ## Text mode, manual turns, tools, interruptions
174
+
175
+ - **`modalities=["text"]`.** The agent's words go to the `AgentSession`'s TTS, as with OpenAI's text
176
+ mode; give the session a `tts`.
177
+ - **`turn_detection=None`.** LiveKit's own turn detection (the session's VAD and turn detector) ends
178
+ each turn: the plugin commits the caller's audio, and `generate_reply()` returns the reply.
179
+ - **Tools (preview: they need a Satham server with tool support).** Each call the agent makes runs
180
+ your tool; its result goes back to the server, which replies unless the tool returns
181
+ `llm.ToolResult(..., reply_required=False)`.
182
+ - **Interruptions.** The caller speaking over the agent interrupts it and the playout stops at once.
183
+ LiveKit mutes the caller for the first 3 s of agent speech by default (`AgentSession(
184
+ aec_warmup_duration=3.0)`, off for SIP calls); set it to `None` where echo cancellation is good.
185
+ - **Not supported:** video, and reconnection (a dropped connection ends the call with an
186
+ unrecoverable error).
@@ -0,0 +1,24 @@
1
+ """Satham speech-to-speech (satham-1) for LiveKit Agents.
2
+
3
+ from livekit.agents import AgentSession
4
+ from livekit.plugins import satham
5
+
6
+ session = AgentSession(llm=satham.RealtimeModel(greeting="Hello!", language="en"))
7
+ await session.start(agent=Agent(instructions=role, tools=[...]), room=ctx.room)
8
+ """
9
+
10
+ from livekit.agents import Plugin
11
+
12
+ from .log import logger
13
+ from .realtime import INPUT_SAMPLE_RATE, RealtimeModel, RealtimeSession
14
+ from .version import __version__
15
+
16
+ __all__ = ["INPUT_SAMPLE_RATE", "RealtimeModel", "RealtimeSession", "__version__"]
17
+
18
+
19
+ class SathamPlugin(Plugin):
20
+ def __init__(self) -> None:
21
+ super().__init__(__name__, __version__, __package__, logger)
22
+
23
+
24
+ Plugin.register_plugin(SathamPlugin())
@@ -0,0 +1,3 @@
1
+ import logging
2
+
3
+ logger = logging.getLogger("livekit.plugins.satham")