> For the complete documentation index, see [llms.txt](https://docs.tensorx.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tensorx.ai/research-and-knowledge/podcastfy.md).

# Podcastfy

Configure Podcastfy to generate podcasts through TensorX.

***

## What is Podcastfy?

[Podcastfy](https://github.com/souzatharsis/podcastfy) is an open-source Python package that converts text, images, websites, PDFs and video sources into multi-speaker audio.

***

## Prerequisites

* Python 3.11 or higher
* ffmpeg installed (`pip install ffmpeg` or system package)
* A TensorX API key ([sign up here](https://app.tensorx.ai))

***

## Installation

```bash
pip install podcastfy
```

***

## Quick Start

### Python

```python
from podcastfy.client import generate_podcast

# Generate podcast from URLs using TensorX
audio_file = generate_podcast(
    urls=["https://en.wikipedia.org/wiki/Artificial_intelligence"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY"
)

print(f"Podcast saved to: {audio_file}")
```

### CLI

```bash
python -m podcastfy.client \
  --url https://en.wikipedia.org/wiki/Artificial_intelligence \
  --llm-model-name openai/z-ai/glm-5.2
```

***

## Configuration

### Environment Variables

Create a `.env` file in your project root:

```bash
# TensorX API Key (used for both LLM and TTS)
OPENAI_API_KEY=your-tensorx-api-key

# TensorX API Base URL
OPENAI_BASE_URL=https://api.tensorx.ai/v1
```

{% hint style="warning" %}
**Note**: The environment variable is `OPENAI_BASE_URL` (not `OPENAI_API_BASE`). This is the standard LiteLLM format.
{% endhint %}

### Using TensorX for Transcript Generation

Podcastfy uses LiteLLM for LLM support. To use TensorX models:

```python
from podcastfy.client import generate_podcast

audio_file = generate_podcast(
    urls=["https://example.com/article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY"
)
```

{% hint style="info" %}
**Model format**: Use `openai/` prefix followed by the TensorX model name. This tells LiteLLM to route requests to an OpenAI-compatible endpoint.
{% endhint %}

***

## LiteLLM Model Format

Podcastfy uses LiteLLM which requires specific model naming for OpenAI-compatible APIs:

```
openai/<tensorx-model-name>
```

Replace `<tensorx-model-name>` with an ID returned by `GET /v1/models`.

***

## Model selection

Call `GET /v1/models` with your TensorX API key and use one of the returned IDs. If the integration depends on a capability or token limit, query `GET /v1/model/info` before selecting the model. See [Models](/api-reference/models.md) for examples.

***

## Text-to-Speech with TensorX

Configure TensorX TTS for audio generation:

```python
from podcastfy.client import generate_podcast

audio_file = generate_podcast(
    urls=["https://example.com/article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    tts_model="openai"  # Uses OpenAI-compatible TTS
)
```

### Environment Variables for TTS

```bash
# In your .env file
OPENAI_API_KEY=your-tensorx-api-key
OPENAI_BASE_URL=https://api.tensorx.ai/v1
```

***

## Customization

### Conversation Style

Customize the podcast conversation:

```python
from podcastfy.client import generate_podcast

custom_config = {
    "word_count": 500,
    "conversation_style": ["casual", "informative"],
    "podcast_name": "Tech Insights",
    "creativity": 0.7,
    "output_language": "English"
}

audio_file = generate_podcast(
    urls=["https://example.com/tech-news"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    conversation_config=custom_config
)
```

### CLI with Custom Config

Create a `custom_config.yaml`:

```yaml
word_count: 500
conversation_style:
  - casual
  - informative
podcast_name: "Tech Insights"
creativity: 0.7
output_language: English
```

Run with:

```bash
python -m podcastfy.client \
  --url https://example.com/article \
  --llm-model-name openai/z-ai/glm-5.2 \
  --conversation-config custom_config.yaml
```

***

## Generate from Multiple Sources

### Multiple URLs

```python
audio_file = generate_podcast(
    urls=[
        "https://example.com/article1",
        "https://example.com/article2",
        "https://youtube.com/watch?v=example"
    ],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY"
)
```

### From PDF Files

```python
audio_file = generate_podcast(
    urls=["path/to/document.pdf"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY"
)
```

### From Images

```python
audio_file = generate_podcast(
    urls=["path/to/image1.jpg", "path/to/image2.png"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY"
)
```

***

## Longform Podcasts

Generate longer podcasts (20-30 minutes):

```python
audio_file = generate_podcast(
    urls=["https://example.com/long-article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    longform=True
)
```

### Customize Longform Length

```python
custom_config = {
    "max_num_chunks": 10,  # More chunks = longer podcast
    "min_chunk_size": 400  # Smaller chunks = more detail
}

audio_file = generate_podcast(
    urls=["https://example.com/article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    longform=True,
    conversation_config=custom_config
)
```

***

## Transcript Only

Generate just the transcript without audio:

```python
from podcastfy.client import generate_podcast

transcript = generate_podcast(
    urls=["https://example.com/article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    transcript_only=True
)

print(transcript)
```

### CLI

```bash
python -m podcastfy.client \
  --url https://example.com/article \
  --llm-model-name openai/z-ai/glm-5.2 \
  --transcript-only
```

***

## Multilingual Podcasts

Generate podcasts in different languages:

```python
custom_config = {
    "output_language": "French"
}

audio_file = generate_podcast(
    urls=["https://example.com/article"],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    conversation_config=custom_config
)
```

Supported languages depend on the TTS model capabilities.

***

## Troubleshooting

### API Key Errors

1. Verify your `.env` file contains:

   ```bash
   OPENAI_API_KEY=your-tensorx-api-key
   OPENAI_API_BASE=https://api.tensorx.ai/v1
   ```
2. Test your API key:

   ```bash
   curl https://api.tensorx.ai/v1/models \
     -H "Authorization: Bearer YOUR_API_KEY"
   ```

### Model Not Found

Ensure you're using the correct LiteLLM format:

* `openai/z-ai/glm-5.2`
* `z-ai/glm-5.2`

### Audio Generation Fails

1. Ensure ffmpeg is installed: `ffmpeg -version`
2. Check TTS configuration in your environment
3. Verify API key has sufficient credits

### Content Extraction Fails

1. Check the URL is accessible
2. For PDFs, ensure the file path is correct
3. For YouTube, verify the video is public

***

## Complete Example

```python
import os
from podcastfy.client import generate_podcast

# Set environment variables
os.environ["OPENAI_API_KEY"] = "your-tensorx-api-key"
os.environ["OPENAI_BASE_URL"] = "https://api.tensorx.ai/v1"

# Custom configuration
config = {
    "word_count": 800,
    "conversation_style": ["engaging", "educational"],
    "podcast_name": "AI Weekly",
    "creativity": 0.8
}

# Generate podcast
audio_file = generate_podcast(
    urls=[
        "https://en.wikipedia.org/wiki/Large_language_model",
        "https://en.wikipedia.org/wiki/Transformer_(deep_learning_architecture)"
    ],
    llm_model_name="openai/z-ai/glm-5.2",
    api_key_label="OPENAI_API_KEY",
    conversation_config=config
)

print(f" Podcast generated: {audio_file}")
```

***

## Resources

* [Podcastfy Documentation](https://podcastfy.readthedocs.io/)
* [Podcastfy GitHub](https://github.com/souzatharsis/podcastfy)
* [LiteLLM Providers](https://docs.litellm.ai/docs/providers)
* [TensorX Models & Pricing](https://tensorx.ai/models)

***

## See Also

* [Audio API](/api-reference/audio.md) - TensorX text-to-speech and speech-to-text
* [API Examples](/api-reference/api-examples.md) - Code examples for TensorX API
* [SurfSense](/research-and-knowledge/surfsense.md) - Another tool with podcast generation
* [Open Notebook](/research-and-knowledge/open-notebook.md) - NotebookLM alternative with podcasts


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tensorx.ai/research-and-knowledge/podcastfy.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
