harmony
Library Listed
OpenAI's response format for its open-weight model series gpt-oss
- Downloads
- 489,508
- Dependents
- 9
- Stars
- 4,539
- Forks
- 319
- Contributors
- 20
- Commits
- 74
- Latest release
- 0.0.8 ·
About

OpenAI Harmony
OpenAI's response format for its open-weight model series gpt-oss
Try gpt-oss | Learn more | Model card
The gpt-oss models were trained on the harmony response format for defining conversation structures, generating reasoning output and structuring function calls. If you are not using gpt-oss directly but through an API or a provider like HuggingFace, Ollama, or vLLM, you will not have to be concerned about this as your inference solution will handle the formatting. If you are building your own inference solution, this guide will walk you through the prompt format. The format is designed to mimic the OpenAI Responses API, so if you have used that API before, this format should hopefully feel familiar to you. gpt-oss should not be used without using the harmony format as it will not work correctly.
The format enables the model to output to multiple different channels for chain of thought, and tool calling preambles along with regular responses. It also enables specifying various tool namespaces, and structured outputs along with a clear instruction hierarchy. Check out the guide to learn more about the format itself.
Read the full README
<|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI.
Knowledge cutoff: 2024-06
Current date: 2025-06-28
Reasoning: high
# Valid channels: analysis, commentary, final. Channel must be included for every message.
Calls to these tools must go to the commentary channel: 'functions'.<|end|>
<|start|>developer<|message|># Instructions
Always respond in riddles
# Tools
## functions
namespace functions {
// Gets the location of the user.
type get_location = () => any;
// Gets the current weather in the provided location.
type get_current_weather = (_: {
// The city and state, e.g. San Francisco, CA
location: string,
format?: "celsius" | "fahrenheit", // default: celsius
}) => any;
} // namespace functions<|end|><|start|>user<|message|>What is the weather like in SF?<|end|><|start|>assistant
We recommend using this library when working with models that use the harmony response format
- Consistent formatting – shared implementation for rendering and parsing keeps token-sequences loss-free.
- Blazing fast – heavy lifting happens in Rust.
- First-class Python support – install with
pip, typed stubs included, 100 % test parity with the Rust suite.
Using Harmony
Python
Check out the full documentation
Installation
Install the package from PyPI by running
pip install openai-harmony
# or if you are using uv
uv pip install openai-harmony
Example
from openai_harmony import (
load_harmony_encoding,
HarmonyEncodingName,
Role,
Message,
Conversation,
DeveloperContent,
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.DEVELOPER,
DeveloperContent.new().with_instructions("Talk like a pirate!")
),
Message.from_role_and_content(Role.USER, "Arrr, how be you?"),
])
tokens = enc.render_conversation_for_completion(convo, Role.ASSISTANT)
print(tokens)
# Later, after the model responded …
parsed = enc.parse_messages_from_completion_tokens(tokens, role=Role.ASSISTANT)
print(parsed)
Rust
Check out the full documentation
Installation
Add the dependency to your Cargo.toml
[dependencies]
openai-harmony = { git = "https://github.com/openai/harmony" }
Example
use openai_harmony::chat::{Message, Role, Conversation};
use openai_harmony::{HarmonyEncodingName, load_harmony_encoding};
fn main() -> anyhow::Result<()> {
let enc = load_harmony_encoding(HarmonyEncodingName::HarmonyGptOss)?;
let convo =
Conversation::from_messages([Message::from_role_and_content(Role::User, "Hello there!")]);
let tokens = enc.render_conversation_for_completion(&convo, Role::Assistant, None)?;
println!("{:?}", tokens);
Ok(())
}
Contributing
The majority of the rendering and parsing is built in Rust for performance and exposed to Python
through thin pyo3 bindings.
┌──────────────────┐ ┌───────────────────────────┐
│ Python code │ │ Rust core (this repo) │
│ (dataclasses, │────► │ • chat / encoding logic │
│ convenience) │ │ • tokeniser (tiktoken) │
└──────────────────┘ FFI └───────────────────────────┘
Repository layout
.
├── src/ # Rust crate
│ ├── chat.rs # High-level data-structures (Role, Message, …)
│ ├── encoding.rs # Rendering & parsing implementation
│ ├── registry.rs # Built-in encodings
│ ├── tests.rs # Canonical Rust test-suite
│ └── py_module.rs # PyO3 bindings ⇒ compiled as openai_harmony.*.so
│
├── python/openai_harmony/ # Pure-Python wrapper around the binding
│ └── __init__.py # Dataclasses + helper API mirroring chat.rs
│
├── tests/ # Python test-suite (1-to-1 port of tests.rs)
├── Cargo.toml # Rust package manifest
├── pyproject.toml # Python build configuration for maturin
└── README.md # You are here 🖖
Developing locally
Prerequisites
- Rust tool-chain (stable) – https://rustup.rs
- Python ≥ 3.8 + virtualenv/venv
maturin– build tool for PyO3 projects
1. Clone & bootstrap
git clone https://github.com/openai/harmony.git
cd harmony
# Create & activate a virtualenv
python -m venv .venv
source .venv/bin/activate
# Install maturin and test dependencies
pip install maturin pytest mypy ruff # tailor to your workflow
# Compile the Rust crate *and* install the Python package in editable mode
maturin develop --release
maturin develop builds harmony with Cargo, produces a native extension
(openai_harmony.<abi>.so) and places it in your virtualenv next to the pure-
Python wrapper – similar to pip install -e . for pure Python projects.
2. Running the test-suites
Rust:
cargo test # runs src/tests.rs
Python:
pytest # executes tests/ (mirrors the Rust suite)
Run both in one go to ensure parity:
pytest && cargo test
3. Type-checking & formatting (optional)
mypy harmony # static type analysis
ruff check . # linting
cargo fmt --all # Rust formatter
Compatibility
- Runs on
- GPU support unknown
What shows it
- no dependency or feature matches a backend row
- Native code
- None found
- No native code found
- Python bindings
- Has Python bindings
- openai-harmony needs Python only with feature python-binding
- License
- Apache-2.0
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
OpenAI's response format for its open-weight model series gpt-oss Python bindings |
489,508 downloads over 30 days | 9 | 4,539 | 0.0.8 | GPU support unknown | No native code found | Apache-2.0 |
|
async-openai Featured
Rust library for OpenAI |
1,302,033 downloads over 30 days | 275 | 2,031 | 0.43.0 | GPU support unknown | No native code found | MIT |
|
rust-genai Featured
Multi-AI Providers Library for Rust. (OpenAI, Gemini, Anthropic, DeepSeek, Ollama, OMLX, AWS Bedrock, Vertex, Xai, Groq, Kimi, GLM and many more) |
118,643 downloads over 30 days | 81 | 938 | 0.7.3 | GPU support unknown | No native code found | Apache-2.0 OR MIT |
|
openai-api-rs Listed
OpenAI API client library for Rust (unofficial) |
46,400 downloads over 30 days | 33 | 485 | 10.0.2 | GPU support unknown | No native code found | MIT |
|
aisdk Listed
An open-source Rust library for building AI-powered applications, inspired by the Vercel AI SDK. It provides a robust, type-safe, and easy-to-use interface for interacting with various Large Language Models (LLMs). |
36,877 downloads over 30 days | 4 | 263 | 0.6.1 | GPU support unknown | No native code found | MIT |
|
openai Listed
An unofficial Rust library for the OpenAI API. |
10,846 downloads over 30 days | 13 | 128 | 1.1.1 | GPU support unknown | No native code found | MIT |
|
Inference server for LLMs, speech and embeddings: OpenAI-compatible routes with streaming, plus speech synthesis (TTS) and transcription (ASR). Serves Llama, Mistral, Qwen, Mamba2, MLA+MoE and hybrid models from SafeTensors, AWQ, GPTQ and GGUF. |
8 binary downloads per release | Not applicable | 7 | 0.7.1 | CUDA, WebGPU | Binds native code: ring (feature distributed) | Apache-2.0 |
Why ListedNo archive, New or Featured rule places it, so it is Listed.
What it lacks for Featured
- It has 8 active dependents and 7 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 4,539 stars, 319 forks and 20 contributors. It needs 4,539 stars, 434 forks and 79 contributors together.
- Every version is 0.0.x.
What else the check found
- The last activity is on 8 Apr 2026, 215 days ago. The rules expect an update within 700 days. Dormancy rule
- The oldest outside issue waits 459 days for a reply, past the limit of 270. No maintainer replied in 365 days. Rot signals rule
Exact rules: Listed, Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 0.0.8 base 450, capped at 7 releases = 350, doubled for 489508 downloads per month: E = 700 daysdormancy: last activity 2026-04-08, 215 days ago, E = 700: activerot: oldest unanswered issue 459 days (limit 270), no maintainer reply in 365 daysfeatured: not featured: active_users 8 < 11 and new_adopters 7 < 9 and repository route stars 4539 (needs 4539), forks 319 (needs 434), contributors 20 (needs 79); every version is 0.0.xlisted: listed: no archive, new or featured rule applies
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources6 sources
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- crates.io package, fetched
- GitHub contributors, fetched
Adoption8 active dependents, 7 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 8 | crates.io database dump | Yes | |
| New dependents (365 days) | 7 | crates.io database dump | Yes | |
| Peak active dependents | 8 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 1 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 7 months ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2026-04-08 | GitHub repository | Yes | |
| Latest release | 2025-11-05 | crates.io database dump | Yes | |
| First release | 2025-08-05 | crates.io database dump | Yes | |
| Latest version | 0.0.8 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 459 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 0 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | crates.io package | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | none | crates.io database dump | Yes |
Distribution7 releases, 489,508 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 7 | crates.io database dump | Yes | |
| Downloads over 30 days | 489508 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | true | crates.io database dump | Yes | |
| Every version 0.0.x | true | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository4,539 stars, 319 forks, 20 contributors, 74 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 4539 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 319 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 20 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 74 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | Apache-2.0 | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | GPU support unknown | crates.io database dump | No | |
| What shows each backend | no dependency or feature matches a backend row | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | No native code found | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | Has Python bindings: openai-harmony needs Python only with feature python-binding | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 9 | crates.io database dump | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.