Metadata-Version: 2.5
Name: pipecat-deapi
Version: 0.1.0
Summary: deAPI services for Pipecat: LLM, speech-to-text and text-to-speech
Project-URL: Homepage, https://deapi.ai
Project-URL: Documentation, https://docs.deapi.ai
Project-URL: Source, https://github.com/deapi-ai/pipecat-deapi
Author-email: "deAPI Inc." <support@deapi.ai>
License-Expression: BSD-2-Clause
License-File: LICENSE
Keywords: ai,deapi,llm,pipecat,speech-to-text,text-to-speech,voice
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Requires-Dist: aiohttp<4,>=3.9
Requires-Dist: pipecat-ai<2,>=1.0.0
Requires-Dist: soundfile>=0.13
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# pipecat-deapi

[deAPI](https://deapi.ai) services for [Pipecat](https://github.com/pipecat-ai/pipecat):

- **`DeAPILLMService`**: chat models served through deAPI's OpenAI-compatible API, with
  streaming and tool calling.
- **`DeAPISTTService`**: speech-to-text on deAPI's synchronous transcription endpoint. The
  transcript comes back in the same response, with automatic language detection.
- **`DeAPITTSService`**: text-to-speech with deAPI's voices (Kokoro and others).

![Demo](https://raw.githubusercontent.com/deapi-ai/pipecat-deapi/main/demo/demo.gif)

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
asks a question, the agent calls a function and answers, then gets interrupted mid-story.
The full video with sound is [`demo/demo.mp4`](https://github.com/deapi-ai/pipecat-deapi/blob/main/demo/demo.mp4).

This integration is maintained by deAPI Inc., the company that runs the deAPI service.

## Installation

```bash
pip install pipecat-deapi
```

or `uv add pipecat-deapi`.

You also need a deAPI API key. Create one in the
[deAPI panel](https://app.deapi.ai/settings/api-keys) and set it as `DEAPI_API_KEY`.

## Usage

All three services take the same key and drop into a Pipecat pipeline like any other service:

```python
import os

from pipecat.pipeline.pipeline import Pipeline
from pipecat_deapi import DeAPILLMService, DeAPISTTService, DeAPITTSService

stt = DeAPISTTService(api_key=os.environ["DEAPI_API_KEY"])

llm = DeAPILLMService(
    api_key=os.environ["DEAPI_API_KEY"],
    settings=DeAPILLMService.Settings(
        model="qwen3.8-flash",
        system_instruction="You are a helpful assistant in a voice conversation.",
    ),
)

tts = DeAPITTSService(
    api_key=os.environ["DEAPI_API_KEY"],
    settings=DeAPITTSService.Settings(voice="af_nova"),
)

pipeline = Pipeline(
    [
        transport.input(),
        stt,
        user_aggregator,
        llm,
        tts,
        transport.output(),
        assistant_aggregator,
    ]
)
```

### LLM

| Setting | Default | Notes |
| - | - | - |
| `model` | `qwen3.8-flash` | Any chat model from `GET https://oai.deapi.ai/v1/models` |
| `reasoning_effort` | `"none"` | `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`, or `None` for the model's own default |

deAPI's chat models reason before they answer, and that pass runs before the first spoken
token. The service therefore turns reasoning off by default. Raise `reasoning_effort` when the
task needs working out:

```python
llm = DeAPILLMService(
    api_key=os.environ["DEAPI_API_KEY"],
    settings=DeAPILLMService.Settings(model="qwen3.8-max", reasoning_effort="low"),
)
```

Not every model accepts every value. `glm-5.3` takes only `low`, `high` and `max`, so set one
of those when you use it; `gpt-6-luna` does not take `minimal`. The API rejects an unsupported
value with the list of values the model supports. All other `OpenAILLMService` settings
(`temperature`, `max_tokens`, tools, and so on) work unchanged.

### Speech-to-text

`DeAPISTTService` is a segmented service: the pipeline's VAD marks where the user stops
speaking, the segment is uploaded, and one `TranscriptionFrame` is pushed with the transcript.
It needs a VAD analyzer in the pipeline, as in the example.

- Model: `FluidSpeechPro` (the default and, today, the only synchronous model).
- The clip length limit is the API's: a longer segment is refused with the API's message,
  which states the current limit, and comes back as an `ErrorFrame`.
- The language is detected automatically and reported on the frame.
- One final transcript is pushed per segment.
- Billing is per second of audio; a segment with no speech returns nothing.

### Text-to-speech

| Setting | Default | Notes |
| - | - | - |
| `model` | `Kokoro` | Also `Chatterbox`, `Qwen3_TTS_12Hz_1_7B_CustomVoice`, `Qwen3_TTS_12Hz_1_7B_VoiceDesign` |
| `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 |
| `speed` | model default | Speed multiplier; the accepted range depends on the model, and the API rejects a value outside it |
| `instructions` | not set | A description of the voice, for the voice-design model only |
| `language` | from the voice | Set it to override the language chosen from the voice |

Each sentence is synthesized as one complete audio file and played as soon as it arrives.

## Running the example

[`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:
speech-to-text, an LLM with a function call, and the voice.

```bash
pip install pipecat-deapi "pipecat-ai[silero,webrtc,runner]" python-dotenv
export DEAPI_API_KEY=sk-dp-...
python examples/voice_agent.py
```

Then open `http://localhost:7860` and talk to the agent.

## Compatibility

Tested with Pipecat v1.17.0 on Python 3.12. Requires `pipecat-ai` 1.x.

## Development

```bash
pip install -e ".[dev]"
pytest
ruff check . && ruff format --check .
```

`DEAPI_API_KEY` in the environment also runs the live tests; without it they are skipped.

To record the demo again: `python demo/record_demo.py`, then `python demo/render_video.py`
(needs ffmpeg). It runs the real pipeline with a scripted user and costs a few cents.

## License

BSD 2-Clause. See [LICENSE](https://github.com/deapi-ai/pipecat-deapi/blob/main/LICENSE).
