> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-css-tab-borders.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Integrate W&B with OpenAI Gym to track reinforcement learning experiments and record episode performance videos.

# OpenAI Gym

<Note>
  "The team that has been maintaining Gym since 2021 has moved all future development to [Gymnasium](https://github.com/Farama-Foundation/Gymnasium), a drop in replacement for Gym (import gymnasium as gym), and Gym will not be receiving any future updates." ([Source](https://github.com/openai/gym#the-team-that-has-been-maintaining-gym-since-2021-has-moved-all-future-development-to-gymnasium-a-drop-in-replacement-for-gym-import-gymnasium-as-gym-and-gym-will-not-be-receiving-any-future-updates-please-switch-over-to-gymnasium-as-soon-as-youre-able-to-do-so-if-youd-like-to-read-more-about-the-story-behind-this-switch-please-check-out-this-blog-post))

  Since Gym is no longer a maintained project, try out the integration with Gymnasium.
</Note>

This page describes how to use W\&B with [OpenAI Gym](https://github.com/openai/gym) to automatically capture videos of your reinforcement learning environments. You can then review agent behavior alongside your experiment metrics in W\&B.

If you're using OpenAI Gym, W\&B automatically logs videos of your environment generated by `gym.wrappers.Monitor`. To enable this, set the `monitor_gym` keyword argument to [`wandb.init()`](/models/ref/python/functions/init) to `True`, or call `wandb.gym.monitor()`.

The gym integration is lightweight. It [looks at the name of the video file](https://github.com/wandb/wandb/blob/master/wandb/integration/gym/__init__.py#L15) being logged from `gym` and names it after that, or falls back to `"videos"` if it doesn't find a match. If you want more control, you can manually [log a video](/models/track/log/media/).

The [OpenRL Benchmark](https://wandb.me/openrl-benchmark-report) by [CleanRL](https://github.com/vwxyzjn/cleanrl) uses this integration for its OpenAI Gym examples. You can find source code (including [the code used for specific runs](https://wandb.ai/cleanrl/cleanrl.benchmark/runs/2jrqfugg/code?workspace=user-costa-huang)) that demonstrates how to use gym with W\&B.

<Frame>
  <img src="https://mintcdn.com/wb-21fd5541-css-tab-borders/Zp1Au-vBGBD27x6o/images/integrations/open_ai_report_example.png?fit=max&auto=format&n=Zp1Au-vBGBD27x6o&q=85&s=6badda204eb3d6e7706dca7cc31d593a" alt="OpenAI Gym dashboard" width="1048" height="815" data-path="images/integrations/open_ai_report_example.png" />
</Frame>
