DevKits

Logit Bias Calculator — Build OpenAI logit_bias From Words

Type the words you want to ban or boost and get the OpenAI logit_bias map — each word is tokenized to its token IDs and assigned a −100 to 100 bias. Copy the JSON. 100% local.

Last updated:

Comments

Type the words you want to ban or boost and this calculator tokenizes each one and builds the OpenAI logit_bias map — a JSON object from token ID to a bias between −100 (effectively banned) and +100 (strongly forced). Because a word can split into several tokens, each token ID gets the bias. Copy the JSON straight into your request. Everything runs in your browser.

Tokenizing runs in your browser. A word often splits into several tokens — each gets the same bias. Include a leading space to match how the word appears mid-sentence.

What is Logit Bias Calculator?

logit_bias lets you steer an OpenAI model toward or away from specific tokens by adding a fixed value to their logits before sampling. The catch is that its keys are token IDs, not words — and a single word often tokenizes into multiple pieces, each with its own ID. This calculator closes that gap: you enter the words and a bias from −100 to 100, it runs the model's real BPE tokenizer (o200k_base for GPT-4o/GPT-5 or cl100k_base for GPT-4/3.5) to expand each word into its token IDs, and it assigns your bias to every one of them, producing a ready-to-paste logit_bias object. It also shows the per-token breakdown so you can see exactly what you're biasing. Use −100 to ban a word (profanity filters, forbidden brand names), small positive values to gently encourage a term, or large values to force a choice in constrained tasks. A key detail it handles for you: mid-sentence words usually carry a leading space (' apple' ≠ 'apple'), so include the space to bias the form the model actually emits.

How to build a logit_bias map

  1. 1Pick the tokenizer that matches your model (o200k_base or cl100k_base).
  2. 2Add each word with a bias from −100 (ban) to 100 (force) — include a leading space for mid-sentence words.
  3. 3Copy the generated logit_bias JSON into your API request.

Key Concepts

logit_bias
Map from token ID to a −100..100 value added to the token's logit before sampling.
Token IDs
The keys must be IDs, not words; see how text maps to tokens.
Sampling
Bias interacts with temperature and top-p — explore them here.

Tips & Best Practices

  • ▸−100 effectively bans a token; ±1 to ±5 nudges gently without fully overriding the model.
  • ▸Always include the leading space for words that appear mid-sentence, or you'll bias the wrong token.

Frequently Asked Questions

What is logit_bias?

logit_bias is an OpenAI parameter that nudges the model toward or away from specific tokens. It's a map from token ID to a bias between −100 and 100 that's added to the token's logit before sampling. −100 effectively bans a token; +100 strongly forces it; values like ±1 to ±5 gently steer.

Why does it use token IDs, not words?

The model samples tokens, not words, so logit_bias keys must be token IDs. A single word often splits into several tokens — this calculator tokenizes each word (with the model's BPE vocabulary) and assigns the bias to every resulting token ID for you.

Why does a leading space matter?

Mid-sentence, words are usually tokenized with a leading space (' apple' is a different token from 'apple'). To bias a word as it appears in normal text, include the leading space — this tool preserves exactly what you type.

Which tokenizer should I pick?

Use o200k_base for GPT-4o and GPT-5-era models and cl100k_base for GPT-4 and GPT-3.5. The token IDs differ between them, so choose the one matching your target model.

Try Next

Text Chunker

Split long text into overlapping chunks for embedding and RAG pipelines. Preview recursive, paragraph, sentence, or fixed strategies with live token counts. Runs 100% in your browser.

Related Tools

Reference & Guides