> ## Documentation Index
> Fetch the complete documentation index at: https://visionagents.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Golf Coach

> Build a real-time golf coaching agent with YOLO pose detection and voice feedback

<iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/62Ly11LlYrE" title="AI Golf Coach" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

<Card title="View Golf Coach Example on GitHub" icon="github" href="https://github.com/GetStream/Vision-Agents/tree/main/examples/02_golf_coach_example">
  Check out the complete AI Golf Coach example in our GitHub repository
</Card>

Build a real-time golf coach that watches your swing via camera and gives spoken feedback. It combines [Ultralytics YOLO](https://docs.ultralytics.com/tasks/pose/) pose detection to analyze body position with [Gemini Live](https://gemini.google/overview/gemini-live/) for real-time coaching — all running on [Stream's](https://getstream.io/) low-latency edge network. This pattern applies to any video coaching use case: sports training, physical therapy, workout guidance, or drone monitoring.

<Info>
  Complete the [Quickstart](/introduction/quickstart) first. This example adds a **video processor** on top of a Realtime LLM.
</Info>

## What You Will Build

* Analyze golf swings in real time using [YOLO](https://www.ultralytics.com/yolo) pose detection
* Process video at configurable FPS with [Gemini Live](https://ai.google.dev/) or [OpenAI Realtime](https://platform.openai.com/docs/guides/realtime)
* Deliver spoken coaching feedback based on body position and movement
* Hot-swap between AI providers with a one-line config change

## Prerequisites

```bash theme={null}
STREAM_API_KEY=
STREAM_API_SECRET=
GOOGLE_API_KEY=
```

If using OpenAI instead of Gemini, also add `OPENAI_API_KEY`.

## Run the example

<Steps>
  <Step title="Clone and install" icon="folder-plus">
    Clone the repo and install dependencies from the root:

    ```bash theme={null}
    git clone git@github.com:GetStream/Vision-Agents.git
    cd Vision-Agents
    uv sync
    ```
  </Step>

  <Step title="Configure environment" icon="key">
    Create a `.env` file at the repo root with your Stream and Gemini API keys.
  </Step>

  <Step title="Run the agent" icon="play">
    From the example directory:

    ```bash theme={null}
    cd examples/02_golf_coach_example
    uv run golf_coach_example.py run
    ```

    The CLI opens a browser demo with your camera. Position yourself so the camera can see your full body, then perform a golf swing. The agent analyzes your form and gives spoken feedback.
  </Step>
</Steps>

## How it works

The agent combines a Realtime LLM with a YOLO pose processor:

```python theme={null}
agent = Agent(
    edge=getstream.Edge(),
    agent_user=User(name="AI golf coach"),
    instructions="Read @golf_coach.md",
    llm=gemini.Realtime(fps=3),
    processors=[
        ultralytics.YOLOPoseProcessor(model_path="yolo26n-pose.pt")
    ],
)
```

1. **Video capture** — the user's camera feeds video to the agent
2. **Pose detection** — YOLO analyzes each frame and extracts body position data
3. **LLM processing** — Gemini Realtime receives video frames at 3 FPS
4. **Feedback** — the agent speaks coaching guidance based on `golf_coach.md` instructions

The `fps=3` parameter controls how many frames per second are sent to the model. Higher FPS gives more detail but uses more tokens.

## Customize

* **Change FPS**: `gemini.Realtime(fps=5)` for lower cost, `fps=10` for more detail
* **Switch to OpenAI**: replace with `openai.Realtime(fps=3)` in `agent.py`
* **Edit coaching style**: modify `golf_coach.md` in the example directory
* **Different YOLO models**: use `YOLOProcessor` for object detection instead of pose estimation

## Next Steps

<CardGroup cols={2}>
  <Card title="Video Agents" icon="video" href="/introduction/video-agents">
    VLMs, processors, and realtime video patterns
  </Card>

  <Card title="Video Processors" icon="eye" href="/guides/video-processors">
    Build custom detection and analysis pipelines
  </Card>

  <Card title="Live Sports Commentator" icon="futbol" href="/examples/football-commentator">
    Use Roboflow object detection for multi-object tracking
  </Card>

  <Card title="Ultralytics Integration" icon="plug" href="/integrations/vision/ultralytics">
    Explore YOLO model options and configuration
  </Card>
</CardGroup>
