Run gpt-oss, OpenAI's new open weights model. Run now
August 12, 20253 minute read

What is o200k Harmony? OpenAI’s latest edition to their tiktoken tokenizer library

Along with the launch of gpt-oss and GPT-5, OpenAI open-sourced the o200k Harmony (sometimes styled as o200k_harmony) tokenizer. This new tokenizer was merged into and made available through OpenAI’s tiktoken library.

Tokenizers break down text into smaller subunits called tokens. Efficient tokenization is critical to a model’s net performance; accordingly, tokenizers are constantly being improved to better accommodate industry needs.

Prior to August, there were two modern tokenizers that were available in tiktoken:

  • o200k_base: used for the GPT-4o, o3-mini, o4-mini, and many other modern OpenAI models. 200k indicates that this tokenizer supported 200,000 unique tokens.
  • p50k_base: used for OpenAI’s Codex models designed for coding applications like Windsurf or Cursor. 50k indicates that this tokenizer supported 50,000 unique tokens.

These tokenizers are now joined by a new tokenizer: Harmony. Similar to o200k_base, Harmony supports 200,000 tokens (201,088 tokens to be precise) and uses Byte Pair Encoding (BPE). To understand Harmony’s structure, let’s first cover what BPE is.

What is Byte Pair Encoding?

Byte Pair Encoding is an algorithm with roots in the 1990s that encodes text into smaller strings with a translation table. Byte Pair Encoding is lossless and reversible, where the original string could be reformed by leveraging the translation table as a lookup table.

What does Harmony introduce?

o200k_harmony introduces two new features to encoding: special tokens for chat formatting and for role-based prompting.

Chat Formatting

Tokenizing chat formatting is what allows a model to preserve, in an encoded context, the structure of a conversation. This is particularly critical for processing multi-speaker transcripts.

Role-Based Prompting

Tokenizing role-based prompting is what preserves specific instructions for a model’s role in the tokenized context.

What other features does Harmony support?

Like o200k_base, Harmony supports many types of tokens to better structure inputs. These include:

Message Roles & Hierarchy

Harmony supports multiple roles, system, developer, user, assistant, tool, with built-in role precedence system > developer > user > assistant > tool.

Message Channels

Harmony has three message channels, which alter how tokens are generated:

  • final , for generating end-user facing responses
  • analysis , for generating chain-of-thought reasoning (not for end-user display)
  • commentary , for generating tool calls, preambles, or multi-step action plans

Special Tokens

Harmony inherits o200k’s special tokens to wrap common constructs. This includes <|start|> / <|end|> for message boundaries, <|message|> for separating header from content, <|channel|> for specifying channel, <|constrain|> for specifying tool call argument type, <|return|> to indicate final completion, and <|call|> to indicate a tool call.

Function Calling

Harmony has namespaced function definitions with TypeScript-like syntax. These include tool call formatting with to={function_name} and the <|constrain|> token

Want to get started?

You can download or fork Harmony today from OpenAI’s tiktoken library. However, you also need a model—potentially the recent gpt-oss. To launch gpt-oss or another open-source model with Harmony, consider a platform like Modal to help you easily host models on cloud GPUs without managing infrastructure. We recently published an example on how to deploy gpt-oss.

Ship your first app in minutes.

Get Started

$30 / month free compute