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:
CommentsType 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
- 1Pick the tokenizer that matches your model (o200k_base or cl100k_base).
- 2Add each word with a bias from −100 (ban) to 100 (force) — include a leading space for mid-sentence words.
- 3Copy the generated logit_bias JSON into your API request.
Key Concepts
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
Context Window Checker
Check whether your prompt fits a model's context window before you send it. Estimates prompt tokens, reserves room for the response, and shows remaining headroom across GPT-4o, o1, Claude, Gemini, DeepSeek and more. 100% local.
Prompt Token Breakdown
Break a prompt into segments and see how many tokens — and how much cost — each part uses. Find the heaviest section (system, few-shot examples, or user input) so you know exactly what to trim. 100% local.
Schema → Tool Definition
Turn a sample JSON payload into function-calling / tool definitions for OpenAI, Anthropic, and Gemini — side by side. Strict-mode toggle adds required + additionalProperties: false. 100% local, paste straight into your tools array.
Chat Messages Validator
Validate a Chat Completions messages array before you send it — checks roles (system/user/assistant/tool), required content, and common mistakes that cause a 400. 100% local.
Prompt Template Tester
Write a prompt with {{variable}} placeholders, fill in values, and preview the final prompt. Detects every variable and flags any you left unfilled. 100% local.
Prompt Diff
Compare two versions of a prompt line by line and see the token delta between them — so you know exactly what changed and whether an edit made the prompt cheaper or more expensive. 100% local.