Skip to main content

Harmony

Response format library for the gpt-oss open-weight model series (fork of openai-harmony)


The [gpt-oss models][gpt-oss] were trained on the [harmony response format][harmony-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][harmony-format] to learn more about the format itself.

<|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][harmony-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 oss-harmony
# or if you are using uv
uv pip install oss-harmony

Note: oss-harmony and openai-harmony both provide the openai_harmony Python module. Do not install both packages in the same environment — pip will silently overwrite one with the other. If you are switching between packages, uninstall the existing one first:

pip uninstall openai-harmony && pip install oss-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]
oss-harmony = { git = "https://github.com/oss-harmony/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

See CONTRIBUTING.md

Metadata

Release files for oss-harmony 0.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oss-harmony 0.0.12
File Size Uploaded Provenance Actions
oss_harmony-0.0.12.tar.gz 2.2 MB Without provenance Details for oss_harmony-0.0.12.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for oss-harmony 0.0.12
File Actions
oss_harmony-0.0.12-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for oss_harmony-0.0.12-cp38-abi3-win_amd64.whl
oss_harmony-0.0.12-cp38-abi3-win32.whl CPython 3.8 abi3 Windows x86-32 Details for oss_harmony-0.0.12-cp38-abi3-win32.whl
oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_x86_64.whl CPython 3.8 abi3 Linux musl 1.2+ x86-64 Details for oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_x86_64.whl
oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_i686.whl CPython 3.8 abi3 Linux musl 1.2+ x86-32 Details for oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_i686.whl
oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_armv7l.whl CPython 3.8 abi3 Linux musl 1.2+ ARMv7l Details for oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_armv7l.whl
oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_aarch64.whl CPython 3.8 abi3 Linux musl 1.2+ ARM64 Details for oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_aarch64.whl
oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl CPython 3.8 abi3 Linux glibc 2.17+ PowerPC 64-le Details for oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.8 abi3 Linux glibc 2.17+ ARMv7l Details for oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details for oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
oss_harmony-0.0.12-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl CPython 3.8 abi3 Linux glibc 2.5+ x86-32 Details for oss_harmony-0.0.12-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
oss_harmony-0.0.12-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for oss_harmony-0.0.12-cp38-abi3-macosx_11_0_arm64.whl

Total release size: 44.7 MB

Release files / oss_harmony-0.0.12.tar.gz

Download URL oss_harmony-0.0.12.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
6a2dd2db3ecd5ac771768c0a3091a2e1ee1354cbfcd61efa1283c26f300f0fcd
BLAKE2b-256 checksum
How to use checksums
12569f5b3e589e78849575f1a64e2fd717a16af6a01ba0fd2fc7476db7557587
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-win_amd64.whl

Download URL oss_harmony-0.0.12-cp38-abi3-win_amd64.whl
Size 3.3 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
53d7a88712ebe9601e5b534eff3d6fa158f81909dbd60b451d987b8fbe4a5875
BLAKE2b-256 checksum
How to use checksums
42003b0dfaac5d6a6ca1ffc20dd7cd655cde6828eeb0950fb445bbe002e9df96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-win32.whl

Download URL oss_harmony-0.0.12-cp38-abi3-win32.whl
Size 3.1 MB
Tags CPython 3.8 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
99cfae82b5f0c09f8373965edc9e67fc978b899a302c5b7ebe73eec1eefcfde4
BLAKE2b-256 checksum
How to use checksums
9ef1a22e4a29d30a05bff5be314eb5cb8006dd315bd04ccd96fc073479c7d2a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_x86_64.whl

Download URL oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_x86_64.whl
Size 3.8 MB
Tags CPython 3.8 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
a71cbb14fe56b875b5216eb4a565e066cda986b72ce759652451c40ad70a3c46
BLAKE2b-256 checksum
How to use checksums
4bfef4b86120c7906a5e00aa47427894bc127c90475e482b7a5830f7992c3de4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_i686.whl

Download URL oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_i686.whl
Size 3.8 MB
Tags CPython 3.8 Linux musl 1.2+ x86-32 abi3
SHA-256 checksum
How to use checksums
53003c572f43fbbfc70c6673fda57cd75791f930fd9840fcfe501580f9aadbd3
BLAKE2b-256 checksum
How to use checksums
12ffec954c0aecbcd7625f2e61537c589a84e3a3aef69b4a731a8d4cf75a1b08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_armv7l.whl

Download URL oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_armv7l.whl
Size 3.7 MB
Tags CPython 3.8 Linux musl 1.2+ ARMv7l abi3
SHA-256 checksum
How to use checksums
7b2ab2825cff7bc760607de07cde4cec4de6810da3764670d3f91b32328217d6
BLAKE2b-256 checksum
How to use checksums
41072f6a3d424c666b101817d29cf0650b3213bbf91e79259d4161c66b46e02d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_aarch64.whl

Download URL oss_harmony-0.0.12-cp38-abi3-musllinux_1_2_aarch64.whl
Size 3.7 MB
Tags CPython 3.8 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
48188c5506265e97d7ec67a31c32c27fc8ba57f50ef577b272c296a1725a2c29
BLAKE2b-256 checksum
How to use checksums
4bd2fd8c5e89401d36d98da95c7c0dc7c14009dbc7a3483e4cead7289a88052b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.5 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d49afad3d5deeaa0ce95a51e7c86f90d1630d36cea3ebd4a8542d214b97cecd7
BLAKE2b-256 checksum
How to use checksums
d28ecb441e220a2188aaf78d2695aa0ae9d776845941fadbc244d2d74c3b7317
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl

Download URL oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Size 3.7 MB
Tags CPython 3.8 Linux glibc 2.17+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
14780fec962cd107a7241f970de0cdd78b596a62a4b24c5b9465820d49f06a85
BLAKE2b-256 checksum
How to use checksums
9d7803a27ad6e9f29fbde9f63d0cde5c2937e049a24ad82ea60a3271255eb68c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 3.4 MB
Tags CPython 3.8 Linux glibc 2.17+ ARMv7l abi3
SHA-256 checksum
How to use checksums
ceb5164cd5fdb1f37b89717b604342dfcc0902f89e5fef571e3b1416eb012bc2
BLAKE2b-256 checksum
How to use checksums
830e378a33f97d52172e70e58554300338a45ba8f25f46717bb4b7d627f74128
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL oss_harmony-0.0.12-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.5 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
b710757817422e8100516b553b9b3843a283d61e047886d1b55e8f5952bdf482
BLAKE2b-256 checksum
How to use checksums
ab875d9f978b0b65ff8b8ede9febca66be3f2ae3cc8661cd7f850b390e84b254
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl

Download URL oss_harmony-0.0.12-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Size 3.6 MB
Tags CPython 3.8 Linux glibc 2.5+ x86-32 abi3
SHA-256 checksum
How to use checksums
f70700ef555c504a3866078d4dc46495775f2038184d079895d25432eec894f9
BLAKE2b-256 checksum
How to use checksums
36a0bddd3bea24b3720e2d0301aa45e930f73a8dedaa91b632346a822585a882
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / oss_harmony-0.0.12-cp38-abi3-macosx_11_0_arm64.whl

Download URL oss_harmony-0.0.12-cp38-abi3-macosx_11_0_arm64.whl
Size 3.3 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6089913900b3ebf3a63f03aebed16df65bf9e86f494adc7d5a7dacac9dd0f959
BLAKE2b-256 checksum
How to use checksums
a7df0e81986055908d24b51997f03e7d7ea97e9a661569692607e7a992bd1d0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Security for oss-harmony 0.0.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page