Control creativity, randomness, and determinism. Know exactly which settings to use for coding, writing, analysis, and more.
Temperature controls how "random" or "creative" the model's output is. It ranges from 0 to 2 (most APIs default to 0.7 or 1.0).
Deterministic output. Same prompt always produces same code. Essential for unit tests and CI/CD.
Structured, consistent results. You want the same entities extracted from similar inputs every time.
Factual and precise with minor variation in phrasing. Good for documentation and reports.
Natural, varied responses. The default range for most chat applications. Balanced and engaging.
Stories, poems, marketing copy. More surprising word choices and narrative directions.
Wild, unconventional ideas. High diversity for ideation sessions. Filter manually afterward.
Top-p is an alternative to temperature. Instead of scaling all token probabilities, it only considers tokens whose cumulative probability reaches a threshold p.
| Scenario | Use | Why |
|---|---|---|
| Need exact same output every time | Temperature = 0 | Greedy decoding, no randomness |
| Need some variety but bounded | Top-p (0.7-0.95) | Filters out truly bizarre tokens |
| Need full creative range | Temperature (1.0+) | Scales all probabilities uniformly |
| Testing prompt consistency | Temperature = 0 | Same prompt = identical output |
from openai import OpenAI client = OpenAI(api_key="YOUR_KEY", base_url="https://tokenease.io/v1") # Deterministic code generation code = client.chat.completions.create( model="deepseek-tc", messages=[{"role": "user", "content": "Write a Python function to reverse a string"}], temperature=0, max_tokens=200 ) # Creative marketing copy copy = client.chat.completions.create( model="k3", messages=[{"role": "user", "content": "Write a catchy headline for a running shoe"}], temperature=1.2, max_tokens=50 )
Hard limit on output length. Always set this to prevent runaway generation. For chat, 1000-2000 is usually sufficient. For long-form writing, you may need 4000+.
Discourage repetition. Presence penalty penalizes tokens that have appeared at all. Frequency penalty penalizes tokens proportionally to how often they've appeared. Range: -2.0 to 2.0. Default: 0. Use 0.1-0.3 to reduce repetition without breaking coherence.
For reproducibility. Setting a seed with temperature=0 (or low) gives more consistent results across calls. Not all providers support this.
One API key. Six models. Instant switching between temperature settings.
Get Free API Key