openai-harmony
OpenAI's response format for its open-weight model series gpt-oss
What it is and what it does
OpenAI Harmony is a Python library that encodes and decodes conversations in the Harmony response format, a structured format designed for OpenAI's open-weight gpt-oss models. The format enables models to output to multiple channels (analysis, commentary, final), handle chain-of-thought reasoning, and structure function calls with tool namespaces. The library wraps a Rust core via PyO3 bindings for performance, exposing a pure-Python API with dataclasses and helper functions.
You use it when building inference solutions that directly invoke gpt-oss models and need to format prompts and parse responses according to the Harmony specification. If you're using gpt-oss through an API provider (HuggingFace, Ollama, vLLM), the provider handles formatting and you don't need this library. The library depends only on Pydantic and aims to keep token sequences loss-free during rendering and parsing.
Use it for:
- Format multi-turn conversations with system, developer, and user roles for direct gpt-oss inference.
- Parse structured model outputs including reasoning, commentary, and function calls from gpt-oss completions.
- Define tool namespaces and function signatures in a format gpt-oss expects for reliable tool calling.
- Encode conversations for token counting and prompt optimization before sending to a gpt-oss model.
- Build a custom inference pipeline that requires explicit control over prompt and response formatting.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Renders and parses the Harmony response format used by OpenAI's gpt-oss models, enabling structured conversation handling, reasoning output, and function calls in Python.
Yes, if you are building a custom inference solution directly using gpt-oss models and need to handle the Harmony format yourself. No, if you are using gpt-oss through a managed API or inference provider—they handle formatting transparently. Caution: the package is aging (282 days since last release) and license terms are unclear; verify both before committing to production use.
Install
openai-harmony on PyPI
pip
pip install openai-harmonyuv
uv add openai-harmonypoetry
poetry add openai-harmonyInstalling openai-harmony
Before you install
Medium install friction due to compiled Rust bindings; prebuilt wheels cover common platforms (x86_64, ARM, i686, ppc64le on Linux/macOS/Windows). Package is aging—last release was 282 days ago—so expect limited active maintenance.
License in practice
License status is unclear; no SPDX identifier or raw license text is available in the metadata. Verify the actual license terms before using in proprietary or restricted contexts.
Quickstart
pip install openai-harmony
from openai_harmony import (
load_harmony_encoding,
HarmonyEncodingName,
Role,
Message,
Conversation,
SystemContent,
)
enc = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
convo = Conversation.from_messages([
Message.from_role_and_content(Role.SYSTEM, SystemContent.new()),
Message.from_role_and_content(Role.USER, "Hello"),
])
tokens = enc.render_conversation_for_completion(convo, Role.ASSISTANT)
Requires Python ≥3.8; compiled Rust extension must be available for your platform (wheels provided for common architectures).
Verify before relying
- Whether the package is actively maintained or in maintenance-only mode (282 days since last release, status marked 'aging').
- Actual license terms and any restrictions on commercial or derivative use.
- Whether the harmony format is stable or subject to breaking changes in future gpt-oss model releases.
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — pydantic |
| Maintenance | aging — 282 days since the last release |
| First released | |
| Downloads | 7,237,088/month — #1,764 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: openai_harmony-0.0.8-cp38-abi3-macosx_11_0_arm64.whl; openai_harmony-0.0.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; openai_harmony-0.0.8-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; openai_harmony-0.0.8-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl; openai_harmony-0.0.8-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl; openai_harmony-0.0.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; openai_harmony-0.0.8-cp38-abi3-musllinux_1_2_aarch64.whl; openai_harmony-0.0.8-cp38-abi3-musllinux_1_2_armv7l.whl; openai_harmony-0.0.8-cp38-abi3-musllinux_1_2_i686.whl; openai_harmony-0.0.8-cp38-abi3-musllinux_1_2_x86_64.whl; openai_harmony-0.0.8-cp38-abi3-win32.whl; openai_harmony-0.0.8-cp38-abi3-win_amd64.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
gpt-ossProvides reference implementations for running…
unclear · top 15,000 on PyPI
openai-messages-token-helperEstimates token usage for OpenAI Chat…
permissive · top 15,000 on PyPI
cohere-melodyParses and renders templated text for Cohere…
permissive · top 15,000 on PyPI
composio-openaiBridges Composio's tool ecosystem to OpenAI's…
permissive · top 15,000 on PyPI
openai-whisperWhisper performs multilingual speech…
permissive · top 5,000 on PyPI
openaiProvides a Python client library for the OpenAI…
permissive · top 1,000 on PyPI
llama-index-llms-openaiIntegrates OpenAI's language models into…
permissive · top 1,000 on PyPI
openai-chatkitA backend SDK for building chat applications…
unclear · top 15,000 on PyPI
agent-framework-openaiProvides OpenAI and Azure OpenAI integration…
permissive · top 5,000 on PyPI
llm-openai-pluginA plugin that extends LLM to access OpenAI…
permissive · top 15,000 on PyPI