> ## Documentation Index
> Fetch the complete documentation index at: https://daily-mb-reorg-api-reference-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Fal Smart Turn

> Cloud-hosted Smart Turn detection using Fal.ai

<Warning>
  DEPRECATED: `FalSmartTurnAnalyzer` is deprecated. Please use
  [LocalSmartTurnAnalyzerV3](/api-reference/server/utilities/turn-detection/smart-turn-overview#local-smart-turn)
  instead, which provides fast CPU inference without requiring external API
  calls.
</Warning>

## Overview

`FalSmartTurnAnalyzer` provides an easy way to use Smart Turn detection via Fal.ai's cloud infrastructure. This implementation requires minimal setup - just an API key - and offers scalable inference without having to manage your own servers.

## Installation

```bash theme={null}
pip install "pipecat-ai[remote-smart-turn]"
```

## Requirements

* A Fal.ai account and API key (get one at [Fal.ai](https://fal.ai))
* Internet connectivity for making API calls

## Configuration

### Constructor Parameters

<ParamField path="api_key" type="Optional[str]" default="None">
  Your Fal.ai API key for authentication (required unless using a custom
  deployment)
</ParamField>

<ParamField path="url" type="str" default="https://fal.run/fal-ai/turn-detection/raw">
  URL endpoint for the Smart Turn API (defaults to the official Fal deployment)
</ParamField>

<ParamField path="aiohttp_session" type="aiohttp.ClientSession" required>
  An aiohttp client session for making HTTP requests
</ParamField>

<ParamField path="sample_rate" type="Optional[int]" default="None">
  Audio sample rate (will be set by the transport if not provided)
</ParamField>

<ParamField path="params" type="SmartTurnParams" default="SmartTurnParams()">
  Configuration parameters for turn detection. See
  [SmartTurnParams](/api-reference/server/utilities/turn-detection/smart-turn-overview#configuration)
  for details.
</ParamField>

## Example

```python theme={null}
import os
import aiohttp
from pipecat.audio.turn.smart_turn.fal_smart_turn import FalSmartTurnAnalyzer
from pipecat.audio.vad.silero import SileroVADAnalyzer
from pipecat.audio.vad.vad_analyzer import VADParams
from pipecat.processors.aggregators.llm_response_universal import (
    LLMContextAggregatorPair,
    LLMUserAggregatorParams,
)
from pipecat.transports.base_transport import TransportParams
from pipecat.turns.user_stop import TurnAnalyzerUserTurnStopStrategy
from pipecat.turns.user_turn_strategies import UserTurnStrategies

async def setup_transport():
    async with aiohttp.ClientSession() as session:
        transport = SmallWebRTCTransport(
            webrtc_connection=webrtc_connection,
            params=TransportParams(
                audio_in_enabled=True,
                audio_out_enabled=True,
            ),
        )

        # Configure Smart Turn Detection via user turn strategies
        user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
            context,
            user_params=LLMUserAggregatorParams(
                user_turn_strategies=UserTurnStrategies(
                    stop=[TurnAnalyzerUserTurnStopStrategy(
                        turn_analyzer=FalSmartTurnAnalyzer(
                            api_key=os.getenv("FAL_SMART_TURN_API_KEY"),
                            aiohttp_session=session
                        )
                    )]
                ),
                vad_analyzer=SileroVADAnalyzer(),
            ),
        )

        # Continue with pipeline setup...
```

## Custom Deployment

You can also deploy the Smart Turn model yourself on Fal.ai and point to your custom deployment:

```python theme={null}
TurnAnalyzerUserTurnStopStrategy(
    turn_analyzer=FalSmartTurnAnalyzer(
        url="https://fal.run/your-username/your-deployment/raw",
        api_key=os.getenv("FAL_API_KEY"),
        aiohttp_session=session
    )
)
```

## Performance Considerations

* **Latency**: While Fal provides global infrastructure, there will be network latency compared to local inference
* **Reliability**: Depends on network connectivity and Fal.ai service availability
* **Scalability**: Handles scaling automatically based on your usage

## Notes

* Fal handles the model hosting, scaling, and infrastructure management
* The session timeout is controlled by the `stop_secs` parameter
* For high-throughput applications, consider deploying your own inference service
