AI Prompt Engineering Best Practices: The Developer's Guide for 2026
"Master prompt engineering for GPT, Claude, and Gemini. Learn proven techniques, templates, and best practices to get better results from any AI model."

A multi-model API gateway is a service that accepts an application request, authenticates it with a gateway key, and routes it to the selected AI model. Crazyrouter is a multi-model API gateway that accepts one gateway key across GPT, Claude, and Gemini, supports OpenAI-compatible chat requests, and lists Claude Sonnet 4.6 input at $1.95 per 1M tokens as of 2026-10.
Key facts#
The following facts use the Claude Sonnet 4.6 pricing snapshot, checked on 2026-10-12; rates may change.
- As of 2026-10, Crazyrouter lists Claude Sonnet 4.6 standard input at $1.95 per 1M tokens.
- As of 2026-10, Crazyrouter lists Claude Sonnet 4.6 standard output at $9.75 per 1M tokens.
- As of 2026-10, the same comparison lists Anthropic standard input at $3.00 per 1M tokens for Claude Sonnet 4.6.
- As of 2026-10, the same comparison lists Anthropic standard output at $15.00 per 1M tokens for Claude Sonnet 4.6.
- As of 2026-10, that table lists a Claude Sonnet 4.6 prototype workload of 10M input and 2M output tokens at $39.00 through Crazyrouter.
How to use one API key for multiple AI models like GPT Claude Gemini?#
Create a gateway API key, store it in your server environment, and configure your SDK with https://api.crazyrouter.com/v1. Select an available model using its exact identifier, such as gpt-5, claude-sonnet-4-6, or gemini-2.5-flash. Your gateway key authenticates requests to Crazyrouter; it is not an Anthropic Console key and will not authenticate against the direct Anthropic API. Check each model's supported request parameters before switching, particularly tools, images, streaming, and structured output. A common endpoint reduces integration work but does not guarantee identical features or answer quality across providers.
For reproducible comparisons, keep the user input and scoring criteria fixed, record the returned model and token usage, and review representative failures. Run small requests before a full batch, set application budgets, and avoid logging secret keys. The examples below illustrate request shapes rather than a new benchmark of all listed models.
This guide covers the techniques that actually work across GPT-5, Claude Opus, and Gemini 3 Pro, with real API code examples you can use today.
Why Prompt Engineering Matters#
LLMs are powerful but literal. They respond to what you write, not what you mean. A vague prompt produces a vague answer. A structured, specific prompt produces structured, specific output. For developers integrating AI into production systems, this isn't optional — it's the difference between a reliable feature and a random text generator.
The good news: prompt engineering follows learnable patterns. Master a handful of core techniques and you'll get dramatically better results from any model.
Core Techniques#
Zero-Shot Prompting#
The simplest approach — give the model a task with no examples. Works well for straightforward requests where the model already has strong training data.
Classify the following customer message as "billing", "technical", or "general":
Message: "I can't log into my account after changing my password"
Category:
Best for: simple classification, summarization, translation.
Few-Shot Prompting#
Provide 2-5 examples before your actual query. This dramatically improves accuracy for tasks where the model needs to understand your specific format or criteria.
Convert these product descriptions to JSON:
Input: "Red cotton t-shirt, size L, $29.99"
Output: {"color": "red", "material": "cotton", "type": "t-shirt", "size": "L", "price": 29.99}
Input: "Blue denim jacket, size M, $89.00"
Output: {"color": "blue", "material": "denim", "type": "jacket", "size": "M", "price": 89.00}
Input: "Black leather boots, size 10, $149.50"
Output:
Chain-of-Thought (CoT)#
Ask the model to reason step-by-step before giving a final answer. This is essential for math, logic, and complex analysis tasks.
A store has 150 items. 40% are electronics, and 25% of electronics are on sale.
How many electronics are on sale?
Think step by step:
A short request for a calculation and a check can help on some reasoning tasks; evaluate the effect on your own examples rather than assuming a fixed improvement.
Role Prompting#
Assign the model a specific persona or expertise. This activates relevant knowledge patterns and adjusts the response style.
You are a senior security engineer reviewing code for vulnerabilities.
Analyze the following Python function and identify any security issues:
Model-Specific Tips#
GPT-5 (OpenAI)#
- Excels at following complex multi-step instructions
- Use
response_format: { type: "json_object" }for reliable JSON output - System messages carry strong weight — put your core instructions there
- Supports function calling natively for structured tool use
Claude Opus (Anthropic)#
- Handles very long contexts well (200K tokens)
- Responds well to XML-tagged sections in prompts (
<instructions>,<context>,<examples>) - Tends to be more cautious — be explicit when you want direct answers
- Strong at following nuanced, detailed instructions
Gemini 3 Pro (Google)#
- Native multimodal — can process images, audio, and video in prompts
- Strong at grounding responses in provided documents
- Use structured prompts with clear section headers
- Good at code generation across many languages
Structured Output Techniques#
JSON Mode via API#
Here's how to get reliable JSON output using Python with the OpenAI-compatible API:
import openai
client = openai.OpenAI(
base_url="https://api.crazyrouter.com/v1",
api_key="your-crazyrouter-key"
)
response = client.chat.completions.create(
model="gpt-5",
response_format={"type": "json_object"},
messages=[
{"role": "system", "content": "Extract product info as JSON with fields: name, price, category."},
{"role": "user", "content": "The new AirPods Pro 3 cost $279 and fall under audio accessories."}
]
)
print(response.choices[0].message.content)
# {"name": "AirPods Pro 3", "price": 279, "category": "audio accessories"}
Function Calling#
Function calling lets you define a schema the model must follow:
tools = [{
"type": "function",
"function": {
"name": "create_ticket",
"description": "Create a support ticket from customer message",
"parameters": {
"type": "object",
"properties": {
"category": {"type": "string", "enum": ["billing", "technical", "general"]},
"priority": {"type": "string", "enum": ["low", "medium", "high"]},
"summary": {"type": "string"}
},
"required": ["category", "priority", "summary"]
}
}
}]
response = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "My payment failed and I'm locked out!"}],
tools=tools
)
Node.js Example#
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.crazyrouter.com/v1",
apiKey: "your-crazyrouter-key",
});
const response = await client.chat.completions.create({
model: "gemini-2.5-flash",
messages: [
{
role: "system",
content: `You are a code reviewer. Analyze the code and respond with JSON:
{"issues": [{"severity": "high|medium|low", "line": number, "description": "..."}]}`
},
{ role: "user", content: "def login(user, pwd):\n query = f'SELECT * FROM users WHERE name={user}'" }
],
response_format: { type: "json_object" },
});
console.log(JSON.parse(response.choices[0].message.content));
cURL Example#
curl -X POST https://api.crazyrouter.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-crazyrouter-key" \
-d '{
"model": "gpt-5",
"messages": [
{"role": "system", "content": "You are a helpful assistant. Use chain-of-thought reasoning."},
{"role": "user", "content": "Compare the time complexity of quicksort vs mergesort. Which should I use for a nearly-sorted array of 10M elements?"}
],
"temperature": 0.3
}'
Testing Prompts Across Models with Crazyrouter#
One of the biggest challenges in prompt engineering is that different models respond differently to the same prompt. A prompt optimized for GPT-5 might underperform on Claude, and vice versa.
Crazyrouter solves this by providing a single OpenAI-compatible API that routes to 300+ models. You can test the same prompt across GPT-5, Claude Opus, Gemini 3 Pro, DeepSeek, and more — just change the model parameter. No need to manage multiple API keys or SDKs.
models = ["gpt-5", "claude-sonnet-4-6", "gemini-2.5-flash", "deepseek-v4-pro"]
for model in models:
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": your_prompt}],
temperature=0.3
)
print(f"{model}: {response.choices[0].message.content[:100]}")
This makes A/B testing prompts across models trivial — essential for finding the best model-prompt combination for your use case.
Pricing Comparison#
As of 2026-10, the verified comparison below uses Claude Sonnet 4.6 standard token rates, in USD per 1M tokens. Subscription usage is a separate product and is not included in these figures.
| Provider | Model | Input / 1M tokens | Output / 1M tokens |
|---|---|---|---|
| Anthropic | Claude Sonnet 4.6 | $3.00 | $15.00 |
| Crazyrouter | Claude Sonnet 4.6 | $1.95 | $9.75 |
The figures come from the linked model pricing snapshot above. See crazyrouter.com for navigation and the current price directory before budgeting other models; this update does not carry forward the old, unverified comparison rates.
Common Mistakes to Avoid#
- Being too vague — "Write something about marketing" vs "Write a 200-word LinkedIn post about B2B SaaS marketing trends in 2026, targeting CTOs"
- Ignoring temperature settings — Use low temperature (0.1-0.3) for factual/structured tasks, higher (0.7-1.0) for creative work
- Overloading a single prompt — Break complex tasks into multiple API calls rather than cramming everything into one prompt
- Not using system messages — The system role is specifically designed for persistent instructions; use it
- Skipping output format specification — Always tell the model exactly what format you want (JSON, markdown, bullet points, etc.)
- Testing on only one model — Different models have different strengths; test across providers to find the best fit
FAQ#
Can one API key call GPT, Claude, and Gemini without separate provider accounts?#
A gateway key can authenticate supported models through that gateway's endpoint, subject to its availability and account terms. It cannot be substituted into each vendor's direct API. Check model-specific parameters before moving a working prompt between families.
What is prompt engineering?#
Prompt engineering is the practice of designing and optimizing inputs (prompts) for AI language models to produce accurate, relevant, and useful outputs. It involves techniques like few-shot learning, chain-of-thought reasoning, and structured formatting to guide model behavior.
Which AI model is best for prompt engineering in 2026?#
There's no single best model — it depends on your task. GPT-5 excels at instruction following and function calling. Claude Opus handles long documents and nuanced analysis. Gemini 3 Pro is strongest for multimodal tasks. Use a unified API like Crazyrouter to test across all of them.
How do I get consistent JSON output from LLMs?#
Use the response_format: { type: "json_object" } parameter (supported by most models via OpenAI-compatible APIs), include a JSON schema in your system prompt, or use function calling to enforce a specific output structure.
Does prompt engineering work the same across all models?#
No. Each model family has different strengths and quirks. Claude responds well to XML tags, GPT-5 follows system messages closely, and Gemini handles multimodal inputs natively. Always test your prompts across models before deploying to production.
What temperature should I use for different tasks?#
Use 0.0-0.3 for factual extraction, classification, and structured output. Use 0.5-0.7 for balanced tasks like summarization. Use 0.8-1.0 for creative writing, brainstorming, and generating diverse options.
How many few-shot examples should I include?#
For most tasks, 2-5 examples are sufficient. More examples improve consistency but increase token usage and cost. Start with 3 examples and adjust based on output quality.
Can I use the same API key to test prompts on different models?#
Yes — services like Crazyrouter provide a single API key that works across 300+ models from OpenAI, Anthropic, Google, DeepSeek, and more. Just change the model parameter in your API call.
Summary#
Prompt engineering in 2026 is about precision, structure, and testing. Master the core techniques — zero-shot, few-shot, chain-of-thought, and role prompting — then adapt them for each model's strengths. Use structured output modes and function calling for production reliability. Most importantly, test your prompts across multiple models to find the optimal combination.
Ready to start testing? Crazyrouter gives you one API key for 300+ models at up to 70% off official pricing — the fastest way to iterate on your prompts across GPT-5, Claude, Gemini, DeepSeek, and more.
<!-- crazyrouter-related-links -->




