The Must-Haves
messages (For Chat Models)
Type:array
Required: Yes (unless you’re using text completion) This is your conversation history. The AI reads all previous messages to understand context.
Message Roles Explained
- system: Sets the AI’s personality and behavior (like “You’re a pirate” or “Be concise”)
- user: What the human said
- assistant: What the AI responded
- tool: Results from function calls (for advanced use cases)
prompt (For Text Completion)
Type:string
Required: Yes (for old-school completion models) Just raw text for the model to continue.
model
Type:string
Required: Optional (we’ll use your account default) Which AI brain you want to use.
The Core Controls
max_tokens
Type:integer
Range:
[1, context_length)
Default: Depends on the model How many tokens (roughly words) the AI can generate. Think of it as setting a word limit.
temperature
Type:number
Range:
[0, 2]
Default:
1.0
The creativity dial. This is probably the most important parameter you’ll use.
- 0.0: Robot mode - very predictable and focused
- 1.0: Balanced - creative but still coherent
- 2.0: Chaos mode - wild and unpredictable
stream
Type:boolean
Default:
false
Get results as they’re generated instead of waiting for the full response.
Advanced Creativity Controls
top_p
Type:number
Range:
(0, 1]
Default:
1.0
Alternative to temperature. Controls randomness by only considering the top % of probable next tokens.
temperature
OR top_p
, not both. They don’t play well together.
top_k
Type:integer
Range:
[1, ∞)
Default: Model-specific Limits how many word choices the model considers at each step.
frequency_penalty
Type:number
Range:
[-2, 2]
Default:
0
Reduces word repetition. Positive values make the model avoid repeating words it’s already used.
presence_penalty
Type:number
Range:
[-2, 2]
Default:
0
Encourages talking about new topics. Positive values push the model to explore different subjects.
repetition_penalty
Type:number
Range:
(0, 2]
Default:
1.0
Another way to fight repetition. Values > 1.0 discourage repeating, < 1.0 encourage it.
Output Control
stop
Type:string | array
Default:
null
Tell the model when to shut up. Generation stops when it hits these sequences.
seed
Type:integer
Default: Random Make the model deterministic. Same seed + same parameters = similar outputs.
Structured Output
response_format
Type:object
Default:
null
Force the model to output in specific formats.
{"type": "json_object"}
: Forces valid JSON{"type": "text"}
: Regular text (default)
Function/Tool Calling
tools
Type:array
Default:
null
Give the model superpowers by defining functions it can call.
tool_choice
Type:string | object
Default:
"auto"
Control how the model uses tools.
"auto"
: Model decides when to use tools"none"
: No tools allowed{"type": "function", "function": {"name": "function_name"}}
: Force a specific tool
AnyAPI Superpowers
transforms
Type:array
Default:
[]
Apply smart transformations to your messages before sending them to models.
"middle-out"
: Rearranges messages for better context utilization (especially useful for long conversations)
models
Type:array
Default:
null
Specify fallback models in order of preference.
provider
Type:object
Default:
null
Fine-tune provider selection and behavior.
Model-Specific Quirks
Different AI families have different personalities:OpenAI Models (GPT-4, GPT-3.5)
- Love
frequency_penalty
andpresence_penalty
- Don’t understand
top_k
orrepetition_penalty
- Great at
response_format
for structured output
Anthropic Models (Claude)
- Support
top_k
parameter - Prefer
repetition_penalty
over frequency penalties - Handle system messages a bit differently
Google Models (Gemini)
- Support
top_k
parameter - Have different token limits
- Can handle images and other media
Open Source Models (Llama, Mistral, etc.)
- Usually support
repetition_penalty
- May have unique sampling parameters
- Context lengths vary wildly
Real-World Parameter Recipes
Creative Writing
Code Generation
Data Extraction
Conversational AI
Parameter Validation (What Happens When You Mess Up)
Unknown Parameters
Models ignore parameters they don’t understand. This means you can use the same parameter set across different models without breaking anything.Out-of-Range Values
We’ll fix obviously broken values:temperature: 3.0
becomestemperature: 2.0
top_p: 1.5
becomestop_p: 1.0
Wrong Types
These will cause errors, so double-check:max_tokens: "100"
❌ (should be a number)stream: "true"
❌ (should be booleantrue
)
Pro Tips for Parameter Mastery
- Start simple: Begin with just
temperature
andmax_tokens
, add complexity later - Temperature is king: This one parameter controls most of what you care about
- Test with your content: Parameters behave differently with different prompts
- Monitor token usage: Higher
max_tokens
= higher costs - Use streaming wisely: Great for UX, but adds complexity to your code
- Don’t overthink penalties: Start with 0.0-0.5 range for frequency/presence penalties
- Seed for testing: Use consistent seeds when testing parameter changes
- Model-specific tuning: What works for GPT-4 might not work for Claude
Remember: Parameters are tools, not magic. The best parameter settings depend on your specific use case, content, and model. Start with sensible defaults and iterate based on your results.