Metadata-Version: 2.4
Name: behavioralsignals
Version: 0.7.1
Summary: Official Python SDK for the Behavioral Signals API: voice emotion/behavior analysis and audio/video deepfake detection
Author: Behavioral Signal Technologies
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
Project-URL: Homepage, https://behavioralsignals.com/
Project-URL: Documentation, https://behavioralsignals.readme.io/
Project-URL: Repository, https://github.com/BehavioralSignalTechnologies/behavioralsignals-python
Project-URL: Issues, https://github.com/BehavioralSignalTechnologies/behavioralsignals-python/issues
Project-URL: Changelog, https://github.com/BehavioralSignalTechnologies/behavioralsignals-python/releases
Keywords: emotion-recognition,speech,voice,deepfake-detection,audio,video,grpc,sdk,mcp
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: grpcio>=1.73.1
Requires-Dist: protobuf>=6.31.1
Requires-Dist: pydantic>=2.11.7
Requires-Dist: pydub>=0.25.1
Requires-Dist: requests>=2.32.4
Requires-Dist: audioop-lts; python_version >= "3.13"
Provides-Extra: dev
Requires-Dist: grpcio-tools>=1.73.1; extra == "dev"
Requires-Dist: mcp<3,>=2.2.0; extra == "dev"
Requires-Dist: mypy==2.3.1; extra == "dev"
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-cov>=7; extra == "dev"
Requires-Dist: ruff==0.16.8; extra == "dev"
Requires-Dist: types-grpcio>=1.83.0; extra == "dev"
Requires-Dist: types-protobuf>=7.35.1; extra == "dev"
Provides-Extra: mcp
Requires-Dist: mcp<3,>=2.2.0; extra == "mcp"
Dynamic: license-file

# Behavioral Signals API Python SDK

<p align="center">
  <img src="https://raw.githubusercontent.com/BehavioralSignalTechnologies/behavioralsignals-python/main/assets/logo.png" alt="Behavioral Signal Technologies"/>
</p>

<div align="center">

[![Discord](https://badgen.net/discord/members/fxjRrbMH3Q/?color=8978cc&icon=discord)](https://discord.com/invite/fxjRrbMH3Q)
[![Twitter](https://badgen.net/badge/b/behavioralsignals/icon?icon=twitter&label&color=black)](https://x.com/behaviorsignals)
[![readme.io](https://badgen.net/badge/readme.io/Documentation/?color=black)](https://behavioralsignals.readme.io/)
[![CI](https://github.com/BehavioralSignalTechnologies/behavioralsignals-python/actions/workflows/ci.yml/badge.svg)](https://github.com/BehavioralSignalTechnologies/behavioralsignals-python/actions/workflows/ci.yml)
[![Coverage](https://raw.githubusercontent.com/BehavioralSignalTechnologies/behavioralsignals-python/python-coverage-comment-action-data/badge.svg)](https://github.com/BehavioralSignalTechnologies/behavioralsignals-python/tree/python-coverage-comment-action-data)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
[![PyPI](https://badgen.net/pypi/v/behavioralsignals)](https://pypi.org/project/behavioralsignals/)
[![Status](https://img.shields.io/pypi/status/behavioralsignals)](https://pypi.org/project/behavioralsignals/)
[![Downloads](https://badgen.net/pypi/dm/behavioralsignals)](https://pypistats.org/packages/behavioralsignals)
[![Python](https://badgen.net/pypi/python/behavioralsignals)](https://pypi.org/project/behavioralsignals/)
[![License](https://badgen.net/badge/license/Apache-2.0/blue)](https://github.com/BehavioralSignalTechnologies/behavioralsignals-python/blob/main/LICENSE)
[![Contributor Covenant](https://badgen.net/badge/Contributor%20Covenant/2.1/4baaaa)](https://github.com/BehavioralSignalTechnologies/behavioralsignals-python/blob/main/CODE_OF_CONDUCT.md)

</div>

Official Python SDK for the [Behavioral Signals API](https://behavioralsignals.readme.io/).

Analyze human behavior and detect deepfake speech using batch and real-time audio APIs. Experimental video deepfake detection is also available in batch mode.

[Python SDK Documentation](https://behavioralsignals.readme.io/docs/behavioral-signals-python-sdk) ·
[Examples](examples/) ·
[PyPI](https://pypi.org/project/behavioralsignals/) ·
[Contributing](CONTRIBUTING.md)

## Features

- **Behavioral Analysis** — analyze human behavior from speech in batch and real-time streaming modes
- **Deepfake Detection** — detect synthetic or manipulated speech in batch and real-time streaming modes
- **Video Deepfake Detection (Experimental, Batch Only)** — analyze both the video frames and audio track of supported video files
- **Core Speech Attributes (Batch Only)** — automatic speech recognition (ASR), speaker diarization, and language identification
- **Embeddings** — retrieve speaker and behavioral embeddings from the Behavioral API, or speaker and deepfake embeddings from the Deepfakes API
- **S3 Input** — submit audio and video using S3 presigned URLs
- **MCP Server** — use Behavioral Signals from MCP-compatible AI assistants

## Quickstart

### Install

```bash
pip install behavioralsignals
```

Requires Python 3.10 or later.

### Configure credentials

Create an account and API key in the [Behavioral Signals portal](https://portal.behavioralsignals.com/).

Set your client ID (CID) and API key as environment variables:

```bash
export BEHAVIORALSIGNALS_CID="your_cid"
export BEHAVIORALSIGNALS_API_KEY="your_api_key"
```

The SDK will pick them up automatically:

```python
from behavioralsignals import Client

client = Client()
```

You can also pass the credentials directly:

```python
client = Client("your_cid", "your_api_key")
```

### Analyze audio

```python
from behavioralsignals import Client
from behavioralsignals.utils import print_results

client = Client()

process = client.behavioral.upload_audio(file_path="audio.wav")
result = client.behavioral.wait_for_result(
    pid=process.pid,
    timeout=600,
)

print_results(result.results)
```

`upload_audio()` returns a process with a unique process ID (`pid`). `wait_for_result()` polls until processing completes and returns the analysis result.

`print_results()` prints one line per result: the start and end time in seconds, the task, and the top label with its probability.
Continuous tasks such as `intensity` have no label, only a score, and `asr` and `diarization` have a label without a probability.
For a 10-second clip of one speaker, the output starts like this:

```
0.487 3.001 asr The birch canoe slid on the smooth plank.
0.487 3.001 diarization SPEAKER_00
0.487 3.001 language en (98.9%)
0.487 3.001 gender female (99.7%)
0.487 3.001 age 18 - 22 (46.8%)
0.487 3.001 emotion sad (70.6%)
...
0.487 3.001 intensity 0.0873
```

Each row also has `prediction`, the list of all labels with their probabilities. Use `result.model_dump()` to get the results as a dictionary.

To include speaker and behavioral embeddings:

```python
process = client.behavioral.upload_audio(
    file_path="audio.wav",
    embeddings=True,
)
```

## Deepfake Detection

### Audio

Batch deepfake detection follows the same workflow as Behavioral Analysis:

```python
from behavioralsignals import Client
from behavioralsignals.utils import print_results

client = Client()

process = client.deepfakes.upload_audio(file_path="audio.wav")
result = client.deepfakes.wait_for_result(
    pid=process.pid,
    timeout=600,
)

print_results(result.results)
```

To include speaker and deepfake embeddings:

```python
process = client.deepfakes.upload_audio(
    file_path="audio.wav",
    embeddings=True,
)
```

### Experimental Generator Detection

Generator detection is an experimental batch feature that attempts to identify the model used to generate deepfake audio.

```python
process = client.deepfakes.upload_audio(
    file_path="audio.wav",
    enable_generator_detection=True,
)
```

See the [generator detection documentation](https://behavioralsignals.readme.io/docs/generator-detection) for details and supported generators.

### Experimental Video Deepfake Detection

Video deepfake detection is available in **batch mode only** and is currently experimental.

```python
process = client.deepfakes.upload_video(file_path="video.mp4")
result = client.deepfakes.wait_for_video_result(
    pid=process.pid,
    timeout=600,
)
```

Unlike an audio result, a video result contains two separate lists:

- `audio_results` — deepfake detection results for the video's audio track
- `video_results` — deepfake detection results for the video frames

For example:

```python
print_results(result.video_results)
```

You can also submit a video using an S3 presigned URL with `upload_s3_presigned_video_url()` and inspect video processes using `list_video_processes()` and `get_video_process()`.

See the [video deepfake documentation](https://behavioralsignals.readme.io/docs/submit-a-file-for-processing) for supported formats, limits, and the current experimental status.

## Streaming

Both the Behavioral and Deepfakes APIs support real-time **audio** streaming over gRPC.

To stream an audio file:

```python
from behavioralsignals import Client, StreamingOptions
from behavioralsignals.utils import make_audio_stream, print_results

client = Client()

audio_stream, sample_rate = make_audio_stream(
    "audio.wav",
    chunk_size=0.25,
)

options = StreamingOptions(
    sample_rate=sample_rate,
    encoding="LINEAR_PCM",
)

for result in client.behavioral.stream_audio(
    audio_stream=audio_stream,
    options=options,
):
    print_results(result.results)
```

`chunk_size` is specified in **seconds**, so `0.25` corresponds to 250 ms.

`stream_audio()` can also accept your own `Iterator[bytes]`, for example from a microphone or live call.

For real-time deepfake detection, use the same interface:

```python
for result in client.deepfakes.stream_audio(
    audio_stream=audio_stream,
    options=options,
):
    print_results(result.results)
```

See the [streaming examples](examples/streaming/) and [streaming documentation](https://behavioralsignals.readme.io/docs/streaming-using-python-sdk) for more.

## Available Methods

`client.behavioral` and `client.deepfakes` expose the same methods for audio. Video methods are available only on `client.deepfakes`.

| Method | What it does |
|---|---|
| `upload_audio(file_path, ...)` | Uploads an audio file and returns the process, including its `pid` |
| `upload_s3_presigned_url(url, ...)` | Submits audio using an S3 presigned URL |
| `wait_for_result(pid, timeout=None)` | Waits for a process to finish and returns its results |
| `get_result(pid)` | Returns the results of a finished process |
| `get_process(pid)` | Returns a process and its current status |
| `list_processes(...)` | Lists audio processes |
| `stream_audio(audio_stream, options)` | Streams audio and yields results as they arrive |
| `upload_video(file_path, ...)` | Deepfakes only: uploads a video file |
| `upload_s3_presigned_video_url(url, ...)` | Deepfakes only: submits video using an S3 presigned URL |
| `wait_for_video_result(pid, timeout=None)` | Deepfakes only: waits for a video process to finish and returns its results |
| `get_video_result(pid)` | Deepfakes only: returns the results of a finished video process |
| `get_video_process(pid)` | Deepfakes only: returns a video process and its status |
| `list_video_processes(...)` | Deepfakes only: lists video processes |

`behavioralsignals.utils` also has two helpers: `make_audio_stream(file_path, chunk_size=0.25)` turns an audio file into chunks for `stream_audio()`, and `print_results(items)` prints result rows as shown in [Analyze audio](#analyze-audio).

For detailed parameters and result schemas, see the [full API documentation](https://behavioralsignals.readme.io/).

## Timeouts and Error Handling

### Batch API

Batch HTTP API errors raise `BehavioralSignalsError`. Its `status_code` contains the HTTP status code.

```python
from behavioralsignals import BehavioralSignalsError, Client

client = Client()

try:
    result = client.behavioral.get_result(pid=12345)
except BehavioralSignalsError as error:
    print(error.status_code, error)
```

`wait_for_result()` and `wait_for_video_result()` also raise:

- `TimeoutError` if processing has not finished within the supplied `timeout`
- `RuntimeError` if the process finishes unsuccessfully, for example because of insufficient credits

Network problems raise the usual `requests` exceptions, such as `requests.ConnectionError`.

Each HTTP request also has its own timeout. By default, the SDK allows 10 seconds to connect and up to 60 seconds waiting for the server, or 300 seconds for uploads.

You can customize these limits when creating the client:

```python
client = Client(
    timeout=(10, 120),
    upload_timeout=(10, 900),
)
```

These request timeouts are separate from the overall `timeout` passed to `wait_for_result()`.

> If an upload request times out, the server may still have received the file and started processing it. Check `list_processes()` — or `list_video_processes()` for videos — before uploading the same file again.

### Streaming API

Streaming uses gRPC rather than the batch HTTP API. Streaming failures can therefore raise `grpc.RpcError` instead of `BehavioralSignalsError`.

```python
import grpc

try:
    for result in client.behavioral.stream_audio(
        audio_stream=audio_stream,
        options=options,
    ):
        ...  # handle results
except grpc.RpcError as error:
    print(error.code(), error.details())
```

## Use with AI Assistants (MCP)

The SDK includes an [MCP](https://modelcontextprotocol.io/) server (available since version 0.7.0), so AI assistants such as Claude Code, Codex, Claude Desktop, and Cursor can analyze audio and video files for you.

The setups below start the server with `uvx`, so install [uv](https://docs.astral.sh/uv/) first.

The server reads credentials from `BEHAVIORALSIGNALS_CID` and `BEHAVIORALSIGNALS_API_KEY`. Your assistant starts the server, so provide them in the assistant's MCP configuration as shown below.

### Claude Code

With the two variables set in your shell, run:

```bash
claude mcp add --env BEHAVIORALSIGNALS_CID="$BEHAVIORALSIGNALS_CID" \
  --env BEHAVIORALSIGNALS_API_KEY="$BEHAVIORALSIGNALS_API_KEY" --transport stdio \
  behavioralsignals -- uvx --python ">=3.10" --from "behavioralsignals[mcp]" behavioralsignals-mcp
```

This adds the server to the current project only. Your key stays out of your shell history and out of the repository.

### Codex

With the two variables set in your shell, run:

```bash
codex mcp add behavioralsignals --env BEHAVIORALSIGNALS_CID="$BEHAVIORALSIGNALS_CID" \
  --env BEHAVIORALSIGNALS_API_KEY="$BEHAVIORALSIGNALS_API_KEY" \
  -- uvx --python ">=3.10" --from "behavioralsignals[mcp]" behavioralsignals-mcp
```

This adds the server for all your projects in `~/.codex/config.toml`.

### Claude Desktop and Cursor

Add this to `claude_desktop_config.json` (Claude Desktop: **Settings > Developer > Edit Config**) or `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "behavioralsignals": {
      "command": "uvx",
      "args": [
        "--python",
        ">=3.10",
        "--from",
        "behavioralsignals[mcp]",
        "behavioralsignals-mcp"
      ],
      "env": {
        "BEHAVIORALSIGNALS_CID": "your_cid",
        "BEHAVIORALSIGNALS_API_KEY": "your_api_key"
      }
    }
  }
}
```

If the app cannot find `uvx`, use its full path (`which uvx`).

### MCP Tools

The server exposes four tools:

| Tool | What it does |
|---|---|
| `analyze_behavior` | Uploads an audio file or S3 presigned URL for behavioral analysis and returns the results |
| `detect_deepfake` | Uploads an audio or video file, or an S3 presigned URL, for deepfake detection and returns the results |
| `get_result` | Returns the results of a process, in pages, optionally filtered to specific tasks |
| `list_processes` | Lists processes, newest first, including the failure reason when available |

Notes:

- Each upload uses API credits, and files named in MCP tool calls are sent to the Behavioral Signals API.
- Upload tools wait up to `wait_seconds` (45 seconds by default, 50 seconds at most). If processing takes longer, they return the process ID so the assistant can check it later with `get_result`.
- Do not commit configuration files containing your API key.

### Running the MCP Server Manually

With `uv` installed, run the server without installing the package:

```bash
uvx --python ">=3.10" --from "behavioralsignals[mcp]" behavioralsignals-mcp
```

Or install the MCP extra with pip:

```bash
pip install "behavioralsignals[mcp]"
behavioralsignals-mcp
```

## Requirements

- Python 3.10+
- A Behavioral Signals account and API key

`ffmpeg` is needed by `make_audio_stream()` for formats other than WAV, such as mp3.

## Documentation and Examples

- [Python SDK Documentation](https://behavioralsignals.readme.io/docs/behavioral-signals-python-sdk)
- [Full API Documentation](https://behavioralsignals.readme.io/)
- [Streaming with the Python SDK](https://behavioralsignals.readme.io/docs/streaming-using-python-sdk)
- [Video Deepfake Detection](https://behavioralsignals.readme.io/docs/submit-a-file-for-processing)
- [Batch Examples](examples/batch/)
- [Streaming Examples](examples/streaming/)
- [AI-friendly Documentation (`llms.txt`)](https://behavioralsignals.readme.io/llms.txt)

## Contributing

Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, testing, formatting, and pull request guidelines.

Please report security issues according to [SECURITY.md](SECURITY.md).

## License

Licensed under the Apache License 2.0. See [LICENSE](LICENSE).
