pipecat-deapi 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ #
2
+ # Copyright (c) 2026, deAPI Inc.
3
+ #
4
+ # SPDX-License-Identifier: BSD 2-Clause License
5
+ #
6
+
7
+ """deAPI services for Pipecat."""
8
+
9
+ from pipecat_deapi.llm import DeAPILLMService, DeAPILLMSettings
10
+ from pipecat_deapi.stt import DeAPISTTService, DeAPISTTSettings
11
+ from pipecat_deapi.tts import DeAPITTSService, DeAPITTSSettings
12
+
13
+ __all__ = [
14
+ "DeAPILLMService",
15
+ "DeAPILLMSettings",
16
+ "DeAPISTTService",
17
+ "DeAPISTTSettings",
18
+ "DeAPITTSService",
19
+ "DeAPITTSSettings",
20
+ ]
21
+ __version__ = "0.1.0"
pipecat_deapi/llm.py ADDED
@@ -0,0 +1,100 @@
1
+ #
2
+ # Copyright (c) 2026, deAPI Inc.
3
+ #
4
+ # SPDX-License-Identifier: BSD 2-Clause License
5
+ #
6
+
7
+ """deAPI LLM service for Pipecat, built on deAPI's OpenAI-compatible API."""
8
+
9
+ from dataclasses import dataclass, field
10
+ from typing import Any, Literal
11
+
12
+ from pipecat.adapters.llm.services.open_ai_adapter import OpenAILLMInvocationParams
13
+ from pipecat.services.openai.base_llm import BaseOpenAILLMService
14
+ from pipecat.services.openai.llm import OpenAILLMService
15
+ from pipecat.utils.types import NOT_GIVEN, NotGiven, is_given
16
+
17
+ DEAPI_BASE_URL = "https://oai.deapi.ai/v1"
18
+ DEFAULT_MODEL = "qwen3.8-flash"
19
+
20
+ ReasoningEffort = Literal["none", "minimal", "low", "medium", "high", "xhigh", "max"]
21
+
22
+
23
+ @dataclass
24
+ class DeAPILLMSettings(BaseOpenAILLMService.Settings):
25
+ """Settings for DeAPILLMService.
26
+
27
+ Parameters:
28
+ reasoning_effort: How much the model reasons before it answers. deAPI's
29
+ chat models reason by default, and that pass runs before the first
30
+ spoken token, so this service defaults to ``"none"`` (reasoning off)
31
+ to keep a voice conversation responsive. Raise it for tasks that
32
+ need working out. Not every model accepts every value:
33
+ ``glm-5.3`` takes only ``"low"``, ``"high"`` and ``"max"``, and
34
+ ``gpt-6-luna`` does not take ``"minimal"``. An unsupported value is
35
+ rejected by the API with the list of values the model supports.
36
+ ``None`` leaves the choice to the model's own default.
37
+ """
38
+
39
+ reasoning_effort: ReasoningEffort | str | None | NotGiven = field(
40
+ default_factory=lambda: NOT_GIVEN
41
+ )
42
+
43
+
44
+ class DeAPILLMService(OpenAILLMService):
45
+ """LLM service for the chat models deAPI serves at ``https://oai.deapi.ai/v1``.
46
+
47
+ The endpoint follows the OpenAI Chat Completions contract (streaming, tool
48
+ calling, image input), so this service extends ``OpenAILLMService`` and adds
49
+ deAPI's defaults and the ``reasoning_effort`` setting. The list of models
50
+ available to a key is returned by ``GET https://oai.deapi.ai/v1/models``.
51
+ """
52
+
53
+ Settings = DeAPILLMSettings
54
+ _settings: Settings
55
+ _requires_api_key = True
56
+
57
+ def __init__(
58
+ self,
59
+ *,
60
+ api_key: str,
61
+ base_url: str = DEAPI_BASE_URL,
62
+ settings: Settings | None = None,
63
+ **kwargs,
64
+ ):
65
+ """Initialize the deAPI LLM service.
66
+
67
+ Args:
68
+ api_key: A deAPI API key (``sk-dp-...``).
69
+ base_url: Base URL of deAPI's OpenAI-compatible API.
70
+ settings: Runtime-updatable settings. Defaults to the model
71
+ ``"qwen3.8-flash"`` with reasoning off.
72
+ **kwargs: Additional keyword arguments passed to ``OpenAILLMService``.
73
+ """
74
+ default_settings = self.Settings(model=DEFAULT_MODEL, reasoning_effort="none")
75
+ if settings is not None:
76
+ default_settings.apply_update(settings)
77
+
78
+ super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs)
79
+
80
+ def build_chat_completion_params(
81
+ self, params_from_context: OpenAILLMInvocationParams
82
+ ) -> dict[str, Any]:
83
+ """Build the parameters for a deAPI chat completion request.
84
+
85
+ Args:
86
+ params_from_context: Parameters derived from the LLM context:
87
+ messages, tools and tool choice.
88
+
89
+ Returns:
90
+ Dictionary of parameters for the chat completion request.
91
+ """
92
+ params = super().build_chat_completion_params(params_from_context)
93
+
94
+ reasoning_effort = self._settings.reasoning_effort
95
+ if is_given(reasoning_effort) and reasoning_effort is not None:
96
+ params["reasoning_effort"] = reasoning_effort
97
+ else:
98
+ params.pop("reasoning_effort", None)
99
+
100
+ return params
pipecat_deapi/stt.py ADDED
@@ -0,0 +1,174 @@
1
+ #
2
+ # Copyright (c) 2026, deAPI Inc.
3
+ #
4
+ # SPDX-License-Identifier: BSD 2-Clause License
5
+ #
6
+
7
+ """deAPI speech-to-text service for Pipecat, using deAPI's synchronous transcription API."""
8
+
9
+ from collections.abc import AsyncGenerator
10
+ from dataclasses import dataclass
11
+
12
+ import aiohttp
13
+ from loguru import logger
14
+ from pipecat.frames.frames import ErrorFrame, Frame, TranscriptionFrame
15
+ from pipecat.services.settings import STTSettings
16
+ from pipecat.services.stt_service import SegmentedSTTService
17
+ from pipecat.transcriptions.language import Language
18
+ from pipecat.utils.time import time_now_iso8601
19
+ from pipecat.utils.tracing.service_decorators import traced_stt
20
+
21
+ DEAPI_SYNC_TRANSCRIPTION_URL = "https://api.deapi.ai/api/v2/audio/transcriptions/sync"
22
+ DEFAULT_MODEL = "FluidSpeechPro"
23
+
24
+ # Speech end to final transcript, in seconds. Measured against the public endpoint
25
+ # with 3-4 second utterances in December 2026 (1.2-2.2 s); override for your deployment.
26
+ DEAPI_TTFS_P99 = 2.5
27
+
28
+
29
+ def _to_language(code: str | None) -> Language | None:
30
+ """Return the Pipecat ``Language`` for a language code reported by deAPI."""
31
+ if not code:
32
+ return None
33
+ try:
34
+ return Language(code)
35
+ except ValueError:
36
+ return None
37
+
38
+
39
+ @dataclass
40
+ class DeAPISTTSettings(STTSettings):
41
+ """Settings for DeAPISTTService.
42
+
43
+ The synchronous endpoint detects the spoken language itself, so ``language``
44
+ is unused and stays ``None``.
45
+ """
46
+
47
+
48
+ class DeAPISTTService(SegmentedSTTService):
49
+ """Speech-to-text service using deAPI's synchronous transcription endpoint.
50
+
51
+ Each speech segment found by the pipeline's VAD is uploaded as a WAV file and
52
+ the transcript comes back in the same response. The endpoint detects the language
53
+ automatically and is billed per second of audio; a segment longer than the API's
54
+ clip limit is refused with the API's message, pushed as an ``ErrorFrame``. One ``TranscriptionFrame`` is pushed per segment.
55
+ """
56
+
57
+ Settings = DeAPISTTSettings
58
+ _settings: Settings
59
+
60
+ def __init__(
61
+ self,
62
+ *,
63
+ api_key: str,
64
+ base_url: str = DEAPI_SYNC_TRANSCRIPTION_URL,
65
+ aiohttp_session: aiohttp.ClientSession | None = None,
66
+ sample_rate: int | None = None,
67
+ settings: Settings | None = None,
68
+ ttfs_p99_latency: float | None = DEAPI_TTFS_P99,
69
+ **kwargs,
70
+ ):
71
+ """Initialize the deAPI STT service.
72
+
73
+ Args:
74
+ api_key: A deAPI API key (``sk-dp-...``).
75
+ base_url: URL of the synchronous transcription endpoint.
76
+ aiohttp_session: Optional aiohttp session for the HTTP requests. If not
77
+ provided, one is created and closed by the service.
78
+ sample_rate: Audio sample rate in Hz. If not provided, uses the pipeline's rate.
79
+ settings: Runtime-updatable settings. Defaults to the model ``"FluidSpeechPro"``.
80
+ ttfs_p99_latency: P99 latency from speech end to final transcript, in seconds.
81
+ **kwargs: Additional arguments passed to ``SegmentedSTTService``.
82
+ """
83
+ default_settings = self.Settings(model=DEFAULT_MODEL, language=None)
84
+ if settings is not None:
85
+ default_settings.apply_update(settings)
86
+
87
+ super().__init__(
88
+ sample_rate=sample_rate,
89
+ ttfs_p99_latency=ttfs_p99_latency,
90
+ settings=default_settings,
91
+ **kwargs,
92
+ )
93
+
94
+ if not api_key:
95
+ raise ValueError("A deAPI API key is required")
96
+ self._api_key = api_key
97
+ self._base_url = base_url
98
+ self._session: aiohttp.ClientSession | None = aiohttp_session
99
+ self._owns_session = aiohttp_session is None
100
+
101
+ def can_generate_metrics(self) -> bool:
102
+ """Check if the service can generate processing metrics.
103
+
104
+ Returns:
105
+ True, as the deAPI STT service supports metrics generation.
106
+ """
107
+ return True
108
+
109
+ async def cleanup(self):
110
+ """Close the HTTP session at teardown, unless the caller provided it."""
111
+ await super().cleanup()
112
+ if self._owns_session and self._session:
113
+ await self._session.close()
114
+ self._session = None
115
+
116
+ @traced_stt
117
+ async def _handle_transcription(
118
+ self, transcript: str, is_final: bool, language: str | None = None
119
+ ):
120
+ """Handle a transcription result with tracing."""
121
+ await self.stop_processing_metrics()
122
+
123
+ async def run_stt(self, audio: bytes) -> AsyncGenerator[Frame, None]:
124
+ """Transcribe one speech segment with deAPI.
125
+
126
+ Args:
127
+ audio: The segment as WAV bytes (already converted by the base class).
128
+
129
+ Yields:
130
+ Frame: A ``TranscriptionFrame`` with the transcript, or an ``ErrorFrame``
131
+ on failure. A segment without speech yields nothing.
132
+ """
133
+ try:
134
+ await self.start_processing_metrics()
135
+
136
+ if not self._session:
137
+ self._session = aiohttp.ClientSession()
138
+
139
+ form = aiohttp.FormData()
140
+ form.add_field("model", str(self._settings.model))
141
+ form.add_field("source_file", audio, filename="audio.wav", content_type="audio/wav")
142
+ headers = {
143
+ "Authorization": f"Bearer {self._api_key}",
144
+ "Accept": "application/json",
145
+ }
146
+
147
+ async with self._session.post(self._base_url, data=form, headers=headers) as resp:
148
+ if resp.status != 200:
149
+ error_text = await resp.text()
150
+ await self.stop_processing_metrics()
151
+ yield ErrorFrame(error=f"deAPI error ({resp.status}): {error_text}")
152
+ return
153
+ response = await resp.json()
154
+
155
+ data = response.get("data") or {}
156
+ text = (data.get("transcription") or "").strip()
157
+ if not text:
158
+ # Silence or noise comes back as an empty transcript, not as an error.
159
+ await self.stop_processing_metrics()
160
+ return
161
+
162
+ language = data.get("language")
163
+ await self._handle_transcription(text, True, language)
164
+ logger.debug(f"Transcription: [{text}]")
165
+ yield TranscriptionFrame(
166
+ text,
167
+ self._user_id,
168
+ time_now_iso8601(),
169
+ _to_language(language),
170
+ result=response,
171
+ )
172
+
173
+ except Exception as e: # noqa: BLE001 - report any failure as a frame
174
+ yield ErrorFrame(error=f"Unknown error occurred: {e}")
pipecat_deapi/tts.py ADDED
@@ -0,0 +1,199 @@
1
+ #
2
+ # Copyright (c) 2026, deAPI Inc.
3
+ #
4
+ # SPDX-License-Identifier: BSD 2-Clause License
5
+ #
6
+
7
+ """deAPI text-to-speech service for Pipecat, using deAPI's OpenAI-compatible speech API."""
8
+
9
+ import asyncio
10
+ import io
11
+ from collections.abc import AsyncGenerator
12
+ from dataclasses import dataclass, field
13
+
14
+ import aiohttp
15
+ import soundfile as sf
16
+ from loguru import logger
17
+ from pipecat.frames.frames import ErrorFrame, Frame, TTSAudioRawFrame
18
+ from pipecat.services.settings import TTSSettings
19
+ from pipecat.services.tts_service import TTSService
20
+ from pipecat.utils.tracing.service_decorators import traced_tts
21
+ from pipecat.utils.types import NOT_GIVEN, NotGiven, is_given
22
+
23
+ DEAPI_SPEECH_URL = "https://oai.deapi.ai/v1/audio/speech"
24
+ DEFAULT_MODEL = "Kokoro"
25
+ DEFAULT_VOICE = "af_nova"
26
+
27
+
28
+ def decode_mp3(data: bytes) -> tuple[bytes, int]:
29
+ """Decode an MP3 file into 16-bit mono PCM.
30
+
31
+ Args:
32
+ data: The MP3 file as bytes.
33
+
34
+ Returns:
35
+ The PCM samples and their sample rate in Hz.
36
+ """
37
+ samples, sample_rate = sf.read(io.BytesIO(data), dtype="int16", always_2d=True)
38
+ return samples[:, 0].tobytes(), sample_rate
39
+
40
+
41
+ @dataclass
42
+ class DeAPITTSSettings(TTSSettings):
43
+ """Settings for DeAPITTSService.
44
+
45
+ Parameters:
46
+ speed: Speech speed multiplier. The accepted range depends on the model;
47
+ the API rejects a value outside it. ``None`` leaves it to the model.
48
+ instructions: A description of the voice, for the voice-design model
49
+ (``Qwen3_TTS_12Hz_1_7B_VoiceDesign``) only. Other models reject it.
50
+ """
51
+
52
+ speed: float | None | NotGiven = field(default_factory=lambda: NOT_GIVEN)
53
+ instructions: str | None | NotGiven = field(default_factory=lambda: NOT_GIVEN)
54
+
55
+
56
+ class DeAPITTSService(TTSService):
57
+ """Text-to-speech service using deAPI's ``/v1/audio/speech`` endpoint.
58
+
59
+ Each sentence is synthesized as one complete MP3 file, which the service decodes
60
+ to PCM and pushes as audio frames.
61
+
62
+ Voices belong to the model. ``Kokoro`` has named voices such as ``af_nova``
63
+ (the prefix selects the language) and also accepts the OpenAI voice names.
64
+ """
65
+
66
+ Settings = DeAPITTSSettings
67
+ _settings: Settings
68
+
69
+ def __init__(
70
+ self,
71
+ *,
72
+ api_key: str,
73
+ base_url: str = DEAPI_SPEECH_URL,
74
+ aiohttp_session: aiohttp.ClientSession | None = None,
75
+ sample_rate: int | None = None,
76
+ settings: Settings | None = None,
77
+ **kwargs,
78
+ ):
79
+ """Initialize the deAPI TTS service.
80
+
81
+ Args:
82
+ api_key: A deAPI API key (``sk-dp-...``).
83
+ base_url: URL of the speech endpoint.
84
+ aiohttp_session: Optional aiohttp session for the HTTP requests. If not
85
+ provided, one is created and closed by the service.
86
+ sample_rate: Output sample rate in Hz. If not provided, uses the pipeline's rate.
87
+ settings: Runtime-updatable settings. Defaults to the model ``"Kokoro"``
88
+ with the voice ``"af_nova"``.
89
+ **kwargs: Additional arguments passed to ``TTSService``.
90
+ """
91
+ default_settings = self.Settings(
92
+ model=DEFAULT_MODEL,
93
+ voice=DEFAULT_VOICE,
94
+ language=None,
95
+ speed=None,
96
+ instructions=None,
97
+ )
98
+ if settings is not None:
99
+ default_settings.apply_update(settings)
100
+
101
+ super().__init__(
102
+ pause_frame_processing=True,
103
+ push_start_frame=True,
104
+ push_stop_frames=True,
105
+ sample_rate=sample_rate,
106
+ settings=default_settings,
107
+ **kwargs,
108
+ )
109
+
110
+ if not api_key:
111
+ raise ValueError("A deAPI API key is required")
112
+ self._api_key = api_key
113
+ self._base_url = base_url
114
+ self._session: aiohttp.ClientSession | None = aiohttp_session
115
+ self._owns_session = aiohttp_session is None
116
+
117
+ def can_generate_metrics(self) -> bool:
118
+ """Check if this service can generate processing metrics.
119
+
120
+ Returns:
121
+ True, as the deAPI TTS service supports metrics generation.
122
+ """
123
+ return True
124
+
125
+ async def cleanup(self):
126
+ """Close the HTTP session at teardown, unless the caller provided it."""
127
+ await super().cleanup()
128
+ if self._owns_session and self._session:
129
+ await self._session.close()
130
+ self._session = None
131
+
132
+ def _payload(self, text: str) -> dict:
133
+ payload: dict = {
134
+ "model": self._settings.model,
135
+ "voice": self._settings.voice,
136
+ "input": text,
137
+ "response_format": "mp3",
138
+ }
139
+ for name in ("speed", "instructions", "language"):
140
+ value = getattr(self._settings, name)
141
+ if is_given(value) and value is not None:
142
+ payload[name] = str(value) if name == "language" else value
143
+ return payload
144
+
145
+ async def _request_speech(self, text: str) -> tuple[int, bytes]:
146
+ """Request the speech for a text and return the HTTP status and the response body."""
147
+ if not self._session:
148
+ self._session = aiohttp.ClientSession()
149
+ headers = {"Authorization": f"Bearer {self._api_key}"}
150
+ async with self._session.post(
151
+ self._base_url, json=self._payload(text), headers=headers
152
+ ) as resp:
153
+ return resp.status, await resp.read()
154
+
155
+ @traced_tts
156
+ async def run_tts(self, text: str, context_id: str) -> AsyncGenerator[Frame, None]:
157
+ """Generate speech from text with deAPI.
158
+
159
+ Args:
160
+ text: The text to synthesize.
161
+ context_id: The context ID for tracking audio frames.
162
+
163
+ Yields:
164
+ Frame: Audio frames with the synthesized speech, or an ``ErrorFrame``.
165
+ """
166
+ logger.debug(f"{self}: Generating TTS [{text}]")
167
+ try:
168
+ request = asyncio.ensure_future(self._request_speech(text))
169
+ try:
170
+ # The reply is one complete file; keep the audio context open until it arrives.
171
+ while True:
172
+ done, _ = await asyncio.wait({request}, timeout=1.0)
173
+ if done:
174
+ break
175
+ self._refresh_audio_context(context_id)
176
+ except asyncio.CancelledError:
177
+ request.cancel()
178
+ raise
179
+ status, data = request.result()
180
+
181
+ if status != 200:
182
+ yield ErrorFrame(error=f"deAPI error ({status}): {data.decode(errors='replace')}")
183
+ return
184
+
185
+ await self.stop_ttfb_metrics()
186
+ await self.start_tts_usage_metrics(text)
187
+
188
+ pcm, source_rate = decode_mp3(data)
189
+
190
+ # About 100 ms per frame, so an interruption can cut playback promptly. The
191
+ # base class resamples to the pipeline's rate when the two differ.
192
+ chunk_size = int(source_rate * 0.1) * 2
193
+ for start in range(0, len(pcm), chunk_size):
194
+ yield TTSAudioRawFrame(
195
+ pcm[start : start + chunk_size], source_rate, 1, context_id=context_id
196
+ )
197
+
198
+ except Exception as e: # noqa: BLE001 - report any failure as a frame
199
+ yield ErrorFrame(error=f"Unknown error occurred: {e}")
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.5
2
+ Name: pipecat-deapi
3
+ Version: 0.1.0
4
+ Summary: deAPI services for Pipecat: LLM, speech-to-text and text-to-speech
5
+ Project-URL: Homepage, https://deapi.ai
6
+ Project-URL: Documentation, https://docs.deapi.ai
7
+ Project-URL: Source, https://github.com/deapi-ai/pipecat-deapi
8
+ Author-email: "deAPI Inc." <support@deapi.ai>
9
+ License-Expression: BSD-2-Clause
10
+ License-File: LICENSE
11
+ Keywords: ai,deapi,llm,pipecat,speech-to-text,text-to-speech,voice
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: aiohttp<4,>=3.9
19
+ Requires-Dist: pipecat-ai<2,>=1.0.0
20
+ Requires-Dist: soundfile>=0.13
21
+ Provides-Extra: dev
22
+ Requires-Dist: build; extra == 'dev'
23
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
24
+ Requires-Dist: pytest>=8; extra == 'dev'
25
+ Requires-Dist: ruff>=0.6; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # pipecat-deapi
29
+
30
+ [deAPI](https://deapi.ai) services for [Pipecat](https://github.com/pipecat-ai/pipecat):
31
+
32
+ - **`DeAPILLMService`**: chat models served through deAPI's OpenAI-compatible API, with
33
+ streaming and tool calling.
34
+ - **`DeAPISTTService`**: speech-to-text on deAPI's synchronous transcription endpoint. The
35
+ transcript comes back in the same response, with automatic language detection.
36
+ - **`DeAPITTSService`**: text-to-speech with deAPI's voices (Kokoro and others).
37
+
38
+ ![Demo](https://raw.githubusercontent.com/deapi-ai/pipecat-deapi/main/demo/demo.gif)
39
+
40
+ The clip above is a real-time recording of the pipeline in [`demo/`](https://github.com/deapi-ai/pipecat-deapi/tree/main/demo): a scripted user
41
+ asks a question, the agent calls a function and answers, then gets interrupted mid-story.
42
+ The full video with sound is [`demo/demo.mp4`](https://github.com/deapi-ai/pipecat-deapi/blob/main/demo/demo.mp4).
43
+
44
+ This integration is maintained by deAPI Inc., the company that runs the deAPI service.
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install pipecat-deapi
50
+ ```
51
+
52
+ or `uv add pipecat-deapi`.
53
+
54
+ You also need a deAPI API key. Create one in the
55
+ [deAPI panel](https://app.deapi.ai/settings/api-keys) and set it as `DEAPI_API_KEY`.
56
+
57
+ ## Usage
58
+
59
+ All three services take the same key and drop into a Pipecat pipeline like any other service:
60
+
61
+ ```python
62
+ import os
63
+
64
+ from pipecat.pipeline.pipeline import Pipeline
65
+ from pipecat_deapi import DeAPILLMService, DeAPISTTService, DeAPITTSService
66
+
67
+ stt = DeAPISTTService(api_key=os.environ["DEAPI_API_KEY"])
68
+
69
+ llm = DeAPILLMService(
70
+ api_key=os.environ["DEAPI_API_KEY"],
71
+ settings=DeAPILLMService.Settings(
72
+ model="qwen3.8-flash",
73
+ system_instruction="You are a helpful assistant in a voice conversation.",
74
+ ),
75
+ )
76
+
77
+ tts = DeAPITTSService(
78
+ api_key=os.environ["DEAPI_API_KEY"],
79
+ settings=DeAPITTSService.Settings(voice="af_nova"),
80
+ )
81
+
82
+ pipeline = Pipeline(
83
+ [
84
+ transport.input(),
85
+ stt,
86
+ user_aggregator,
87
+ llm,
88
+ tts,
89
+ transport.output(),
90
+ assistant_aggregator,
91
+ ]
92
+ )
93
+ ```
94
+
95
+ ### LLM
96
+
97
+ | Setting | Default | Notes |
98
+ | - | - | - |
99
+ | `model` | `qwen3.8-flash` | Any chat model from `GET https://oai.deapi.ai/v1/models` |
100
+ | `reasoning_effort` | `"none"` | `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`, or `None` for the model's own default |
101
+
102
+ deAPI's chat models reason before they answer, and that pass runs before the first spoken
103
+ token. The service therefore turns reasoning off by default. Raise `reasoning_effort` when the
104
+ task needs working out:
105
+
106
+ ```python
107
+ llm = DeAPILLMService(
108
+ api_key=os.environ["DEAPI_API_KEY"],
109
+ settings=DeAPILLMService.Settings(model="qwen3.8-max", reasoning_effort="low"),
110
+ )
111
+ ```
112
+
113
+ Not every model accepts every value. `glm-5.3` takes only `low`, `high` and `max`, so set one
114
+ of those when you use it; `gpt-6-luna` does not take `minimal`. The API rejects an unsupported
115
+ value with the list of values the model supports. All other `OpenAILLMService` settings
116
+ (`temperature`, `max_tokens`, tools, and so on) work unchanged.
117
+
118
+ ### Speech-to-text
119
+
120
+ `DeAPISTTService` is a segmented service: the pipeline's VAD marks where the user stops
121
+ speaking, the segment is uploaded, and one `TranscriptionFrame` is pushed with the transcript.
122
+ It needs a VAD analyzer in the pipeline, as in the example.
123
+
124
+ - Model: `FluidSpeechPro` (the default and, today, the only synchronous model).
125
+ - The clip length limit is the API's: a longer segment is refused with the API's message,
126
+ which states the current limit, and comes back as an `ErrorFrame`.
127
+ - The language is detected automatically and reported on the frame.
128
+ - One final transcript is pushed per segment.
129
+ - Billing is per second of audio; a segment with no speech returns nothing.
130
+
131
+ ### Text-to-speech
132
+
133
+ | Setting | Default | Notes |
134
+ | - | - | - |
135
+ | `model` | `Kokoro` | Also `Chatterbox`, `Qwen3_TTS_12Hz_1_7B_CustomVoice`, `Qwen3_TTS_12Hz_1_7B_VoiceDesign` |
136
+ | `voice` | `af_nova` | Voices belong to the model. On `Kokoro` the prefix picks the language (`af_`/`am_` US English, `bf_`/`bm_` British English, `ef_`/`em_` Spanish, and more); the OpenAI voice names work too |
137
+ | `speed` | model default | Speed multiplier; the accepted range depends on the model, and the API rejects a value outside it |
138
+ | `instructions` | not set | A description of the voice, for the voice-design model only |
139
+ | `language` | from the voice | Set it to override the language chosen from the voice |
140
+
141
+ Each sentence is synthesized as one complete audio file and played as soon as it arrives.
142
+
143
+ ## Running the example
144
+
145
+ [`examples/voice_agent.py`](https://github.com/deapi-ai/pipecat-deapi/blob/main/examples/voice_agent.py) is a complete voice agent on deAPI alone:
146
+ speech-to-text, an LLM with a function call, and the voice.
147
+
148
+ ```bash
149
+ pip install pipecat-deapi "pipecat-ai[silero,webrtc,runner]" python-dotenv
150
+ export DEAPI_API_KEY=sk-dp-...
151
+ python examples/voice_agent.py
152
+ ```
153
+
154
+ Then open `http://localhost:7860` and talk to the agent.
155
+
156
+ ## Compatibility
157
+
158
+ Tested with Pipecat v1.17.0 on Python 3.12. Requires `pipecat-ai` 1.x.
159
+
160
+ ## Development
161
+
162
+ ```bash
163
+ pip install -e ".[dev]"
164
+ pytest
165
+ ruff check . && ruff format --check .
166
+ ```
167
+
168
+ `DEAPI_API_KEY` in the environment also runs the live tests; without it they are skipped.
169
+
170
+ To record the demo again: `python demo/record_demo.py`, then `python demo/render_video.py`
171
+ (needs ffmpeg). It runs the real pipeline with a scripted user and costs a few cents.
172
+
173
+ ## License
174
+
175
+ BSD 2-Clause. See [LICENSE](https://github.com/deapi-ai/pipecat-deapi/blob/main/LICENSE).
@@ -0,0 +1,8 @@
1
+ pipecat_deapi/__init__.py,sha256=aUHvqzf2-_Z5yxunTs1lSFiiQKDWeHFDdoDUsj0zVb8,493
2
+ pipecat_deapi/llm.py,sha256=6lEX4FhKGxJw_gQSdYxrOkyFo8r1Bs50_YWhSXduwUU,3772
3
+ pipecat_deapi/stt.py,sha256=oWMHMZWiQHz4XIuICPGRdhwPfjnjrrZr2wArerPAw0o,6538
4
+ pipecat_deapi/tts.py,sha256=Kaf1jPPo1YG9owAMRQeaBO_EavLk3pmZr-oERB418TA,7233
5
+ pipecat_deapi-0.1.0.dist-info/METADATA,sha256=m2BiE5fCgmdfVo4_azR3X5lRlzTsXl8ED5SJ7hMGqvk,6619
6
+ pipecat_deapi-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
7
+ pipecat_deapi-0.1.0.dist-info/licenses/LICENSE,sha256=KLRzWnhlLF3bvWJP0XziW5X8cmtBCyIO-vJ4SgYmH_0,1299
8
+ pipecat_deapi-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,24 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2026, deAPI Inc.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.