Skip to content

Gymnasium

Gymnasium provides an open-source framework with a standardized API for developing and comparing reinforcement learning algorithms.

Free · Python Library · API

stork
I am a painting.
One still painting and one typed sentence.
This painting was never filmed.
A photo, a cartoon, a painting or a 3D character. From 10 cents a minute. Free to try.
Make a photo talkDevelopers: there is an API

What is Gymnasium?

Gymnasium is a foundational open-source Python library developed by the Farama Foundation that enables researchers and developers to build, test, and benchmark single-agent reinforcement learning (RL) algorithms. It serves as the actively maintained successor to OpenAI Gym, providing a standardized Application Programming Interface (API) for developing and comparing RL algorithms. Its core functionality revolves around a simple API with make(), reset(), and step() functions to initialize environments, reset them for new episodes, and advance the simulation based on an agent's actions. The platform focuses on foundational tools for building simulations, allowing users to construct specific environments for their AI models. It requires users to set up and manage their own infrastructure and data pipelines for their reinforcement learning projects.

Key Features of Gymnasium

Gymnasium offers a comprehensive set of features designed to support reinforcement learning research and development, including a standardized API and a wide array of environments. The library provides foundational tools for building simulations and allows for custom environment creation.

  • Standardized API for single-agent reinforcement learning algorithm development and comparison.
  • Collection of pre-built environments including Classic Control, Box2D, Toy Text, MuJoCo, and Atari.
  • Foundational tools for building custom simulations and defining specific environments for AI models.
  • Core API components: Env, make() and register(), Spaces, Wrappers, and Vectorize.
  • Tutorials for custom environment creation, handling time limits, and implementing custom wrappers.
  • Tutorials for training agents using methods like action masking, Q-learning, REINFORCE, and A2C.
  • Support for Python 3.10, 3.11, 3.12, 3.13, and 3.14 on Linux and macOS.
  • VectorEnv Autoreset Control with three options for managing sub-environment resets.

Who Should Use Gymnasium?

Gymnasium is primarily utilized by researchers, developers, and educators in the field of artificial intelligence, specifically those focusing on reinforcement learning. Its standardized API and diverse environment collection make it suitable for various applications.

  • RL Researchers: For developing, testing, and benchmarking novel reinforcement learning algorithms against established environments like Atari and MuJoCo.
  • Educators & Students: For learning RL fundamentals through accessible environments such as CartPole, MountainCar, and FrozenLake.
  • AI Developers: For prototyping and building specific environments for AI models, leveraging the custom environment creation framework.
  • Robotics & Control Engineers: For simulating and developing control policies using continuous-action MuJoCo control suites like HalfCheetah and Humanoid.
  • Multi-agent RL Developers: As a foundational API that underpins broader libraries like PettingZoo for multi-agent reinforcement learning scenarios.

How to Use Gymnasium

To begin using Gymnasium, users typically install the Python library and then interact with environments through its standardized API. This involves initializing an environment, resetting it for new episodes, and taking steps based on agent actions.

  1. Install the Gymnasium library using pip install gymnasium.
  2. Import the library and create an environment using gymnasium.make('EnvironmentName').
  3. Reset the environment to its initial state using env.reset() to start a new episode.
  4. Interact with the environment by taking actions using env.step(action), which returns observations, rewards, termination status, truncation status, and info.
  5. Render the environment for visualization using env.render() (if supported).
  6. Close the environment using env.close() when done to release resources.

Gymnasium Pricing & Plans

Gymnasium is an open-source Python library released under an MIT license. This means it is entirely free to use, modify, and distribute for both commercial and non-commercial purposes. There are no subscription fees, usage-based costs, or premium tiers associated with the core Gymnasium library.

  • Gymnasium: free (MIT license)

Pros

  • Actively maintained by the Farama Foundation, ensuring ongoing development and support.
  • Provides a standardized API for consistent development and comparison of RL algorithms.
  • Offers a wide range of pre-built environments (e.g., Atari, MuJoCo, Classic Control) for diverse research needs.
  • Supports custom environment creation, allowing users to tailor simulations to specific AI models.
  • Open-source and free to use under an MIT license, promoting accessibility and collaboration.
  • Strong community adoption and integration with other popular RL libraries like Stable Baselines3 and PettingZoo.

Cons

  • Requires users to set up and manage their own infrastructure and data pipelines for RL projects.
  • Primarily focused on single-agent reinforcement learning, requiring extensions like PettingZoo for multi-agent tasks.
  • Does not include pre-implemented state-of-the-art RL algorithms, necessitating integration with libraries like Stable Baselines3.
  • While comprehensive, the initial learning curve for new users unfamiliar with RL concepts and the API can be steep.
  • Performance optimization for very large-scale or distributed training requires integration with external frameworks like Ray/RLlib.

Gymnasium vs Competitors

Gymnasium holds a unique position as the actively maintained successor to OpenAI Gym, providing a standardized API for single-agent reinforcement learning. Its competitive landscape includes other libraries that either extend its functionality or offer alternative approaches to RL environment and algorithm development.

See every Gymnasium alternative, compared

Gymnasium

Free · Python Library · API

Enjoying this? Get one like it in your inbox each morning.

one email a day · unsubscribe in two clicks · no third-party tracking