Prompt Engineering Guide
Master prompt engineering for AI models via inference.sh CLI.

Quick Start
CODEBLOCK0 python\nuserinput = request.args.get(\"query\")\nresult = db.execute(f\"SELECT * FROM users WHERE name = {userinput}\")\n``\n\nProvide specific issues and fixes."
}'
CODEBLOCK1
[Role/Context] + [Task] + [Constraints] + [Output Format]
CODEBLOCK2 bash
infsh app run openrouter/claude-sonnet-45 --input '{
"prompt": "You are an expert data scientist with 15 years of experience in machine learning. Explain gradient descent to a beginner, using simple analogies."
}'
CODEBLOCK3 bash
# Bad: vague
"Help me with my code"
# Good: specific
"Debug this Python function that should return the sum of even numbers from a list, but returns 0 for all inputs:
def sum_evens(numbers):
total = 0
for n in numbers:
if n % 2 == 0:
total += n
return total
Identify the bug and provide the corrected code."
CODEBLOCK4 bash
infsh app run openrouter/claude-sonnet-45 --input '{
"prompt": "Solve this step by step:\n\nA store sells apples for $2 each and oranges for $3 each. If someone buys 5 fruits and spends $12, how many of each fruit did they buy?\n\nThink through this step by step before giving the final answer."
}'
CODEBLOCK5 bash
infsh app run openrouter/claude-sonnet-45 --input '{
"prompt": "Convert these sentences to formal business English:\n\nExample 1:\nInput: gonna send u the report tmrw\nOutput: I will send you the report tomorrow.\n\nExample 2:\nInput: cant make the meeting, something came up\nOutput: I apologize, but I will be unable to attend the meeting due to an unforeseen circumstance.\n\nNow convert:\nInput: hey can we push the deadline back a bit?"
}'
CODEBLOCK6 bash
infsh app run openrouter/claude-sonnet-45 --input '{
"prompt": "Analyze the sentiment of these customer reviews. Return a JSON array with objects containing \"text\", \"sentiment\" (positive/negative/neutral), and \"confidence\" (0-1).\n\nReviews:\n1. \"Great product, fast shipping!\"\n2. \"Meh, its okay I guess\"\n3. \"Worst purchase ever, total waste of money\"\n\nReturn only valid JSON, no explanation."
}'
CODEBLOCK7 bash
infsh app run openrouter/claude-sonnet-45 --input '{
"prompt": "Summarize this article in exactly 3 bullet points. Each bullet must be under 20 words. Focus only on actionable insights, not background information.\n\n[article text]"
}'
CODEBLOCK8
[Subject] + [Style] + [Composition] + [Lighting] + [Technical]
CODEBLOCK9 bash
# Bad: vague
"a cat"
# Good: specific
infsh app run falai/flux-dev --input '{
"prompt": "A fluffy orange tabby cat with green eyes, sitting on a vintage leather armchair"
}'
CODEBLOCK10 bash
infsh app run falai/flux-dev --input '{
"prompt": "Portrait photograph of a woman, shot on Kodak Portra 400 film, soft natural lighting, shallow depth of field, nostalgic mood, analog photography aesthetic"
}'
CODEBLOCK11 bash
infsh app run falai/flux-dev --input '{
"prompt": "Wide establishing shot of a cyberpunk city skyline at night, rule of thirds composition, neon signs in foreground, towering skyscrapers in background, rain-slicked streets"
}'
CODEBLOCK12
photorealistic, 8K, ultra detailed, sharp focus, professional,
masterpiece, high quality, best quality, intricate details
CODEBLOCK13 bash
infsh app run falai/flux-dev --input '{
"prompt": "Professional headshot portrait, clean background",
"negative_prompt": "blurry, distorted, extra limbs, watermark, text, low quality, cartoon, anime"
}'
CODEBLOCK14
[Shot Type] + [Subject] + [Action] + [Setting] + [Style]
CODEBLOCK15 bash
infsh app run google/veo-3-1-fast --input '{
"prompt": "Slow tracking shot following a woman walking through a sunlit forest, golden hour lighting, shallow depth of field, cinematic, 4K"
}'
CODEBLOCK16 bash
infsh app run google/veo-3-1-fast --input '{
"prompt": "Close-up of hands kneading bread dough on a wooden surface, flour dust floating in morning light, slow motion, cozy baking aesthetic"
}'
CODEBLOCK17
slow motion, timelapse, real-time, smooth motion,
continuous shot, quick cuts, frozen moment
CODEBLOCK18 bash
infsh app run openrouter/claude-sonnet-45 --input '{
"system": "You are a helpful coding assistant. Always provide code with comments. If you are unsure about something, say so rather than guessing.",
"prompt": "Write a Python function to validate email addresses using regex."
}'
CODEBLOCK19 bash
infsh app run openrouter/claude-sonnet-45 --input '{
"prompt": "Extract information from this text and return as JSON:\n\n\"John Smith, CEO of TechCorp, announced yesterday that the company raised $50 million in Series B funding. The round was led by Venture Partners.\"\n\nSchema:\n{\n \"person\": string,\n \"title\": string,\n \"company\": string,\n \"event\": string,\n \"amount\": string,\n \"investor\": string\n}"
}'
CODEBLOCK20 bash
# Start broad
infsh app run falai/flux-dev --input '{
"prompt": "A castle on a hill"
}'
# Add specifics
infsh app run falai/flux-dev --input '{
"prompt": "A medieval stone castle on a grassy hill"
}'
# Add style
infsh app run falai/flux-dev --input '{
"prompt": "A medieval stone castle on a grassy hill, dramatic sunset sky, fantasy art style, epic composition"
}'
# Add technical
infsh app run falai/flux-dev --input '{
"prompt": "A medieval stone castle on a grassy hill, dramatic sunset sky, fantasy art style by Greg Rutkowski, epic composition, 8K, highly detailed"
}'
CODEBLOCK21 bash
# First: analyze
infsh app run openrouter/claude-sonnet-45 --input '{
"prompt": "Analyze this business problem: Our e-commerce site has a 70% cart abandonment rate. List potential causes."
}'
# Second: prioritize
infsh app run openrouter/claude-sonnet-45 --input '{
"prompt": "Given these causes of cart abandonment: [previous output], rank them by likely impact and ease of fixing. Format as a priority matrix."
}'
# Third: action plan
infsh app run openrouter/claude-sonnet-45 --input '{
"prompt": "For the top 3 causes identified, provide specific A/B tests we can run to validate and fix each issue."
}'
CODEBLOCK22
Review this [language] code for:
1. Bugs and logic errors
2. Security vulnerabilities
3. Performance issues
4. Code style/best practices
Code:
[code]
For each issue found, provide:
- Line number
- Issue description
- Severity (high/medium/low)
- Suggested fix
CODEBLOCK23
Write a [content type] about [topic].
Audience: [target audience]
Tone: [formal/casual/professional]
Length: [word count]
Key points to cover:
1. [point 1]
2. [point 2]
3. [point 3]
Include: [specific elements]
Avoid: [things to exclude]
CODEBLOCK24
[Subject with details], [setting/background], [lighting type],
[art style or photography style], [composition], [quality keywords]
CODEBLOCK25 bash
# Video prompting guide
npx skills add inference-sh/skills@video-prompting-guide
# LLM models
npx skills add inference-sh/skills@llm-models
# Image generation
npx skills add inference-sh/skills@ai-image-generation
# Full platform skill
npx skills add inference-sh/skills@inference-sh
`
Browse all apps: infsh app list`
提示工程指南
通过 inference.sh CLI 掌握 AI 模型的提示工程。

快速开始
bash
curl -fsSL https://cli.inference.sh | sh && infsh login
结构良好的 LLM 提示
infsh app run openrouter/claude-sonnet-45 --input {
prompt: 你是一名资深软件工程师。请审查以下代码是否存在安全漏洞:\n\npython\nuser
input = request.args.get(\query\)\nresult = db.execute(f\SELECT * FROM users WHERE name = {userinput}\)\n\n\n请指出具体问题并提供修复方案。
}
安装说明: 安装脚本 仅检测您的操作系统/架构,从 dist.inference.sh 下载匹配的二进制文件,并验证其 SHA-256 校验和。无需提升权限或后台进程。提供手动安装与验证方式。
LLM 提示
基本结构
[角色/上下文] + [任务] + [约束条件] + [输出格式]
角色提示
bash
infsh app run openrouter/claude-sonnet-45 --input {
prompt: 你是一名拥有 15 年机器学习经验的资深数据科学家。请用简单的类比向初学者解释梯度下降。
}
任务清晰度
bash
糟糕:模糊不清
帮我处理代码
优秀:具体明确
调试这个 Python 函数,该函数应返回列表中偶数的和,但所有输入都返回 0:
def sum_evens(numbers):
total = 0
for n in numbers:
if n % 2 == 0:
total += n
return total
请找出 bug 并提供修正后的代码。
思维链
bash
infsh app run openrouter/claude-sonnet-45 --input {
prompt: 请逐步解决这个问题:\n\n一家商店苹果售价 2 美元,橙子售价 3 美元。如果某人买了 5 个水果,花费 12 美元,那么每种水果各买了多少个?\n\n在给出最终答案之前,请逐步思考。
}
少样本示例
bash
infsh app run openrouter/claude-sonnet-45 --input {
prompt: 将这些句子转换为正式商务英语:\n\n示例 1:\n输入:明天把报告发你\n输出:我将于明天将报告发送给您。\n\n示例 2:\n输入:开不了会了,临时有事\n输出:很抱歉,由于突发情况,我无法参加会议。\n\n现在转换:\n输入:嘿,我们能推迟一下截止日期吗?
}
输出格式规范
bash
infsh app run openrouter/claude-sonnet-45 --input {
prompt: 分析以下客户评论的情感倾向。返回一个 JSON 数组,每个对象包含 \text\、\sentiment\(positive/negative/neutral)和 \confidence\(0-1)。\n\n评论:\n1. \很棒的产品,发货很快!\\n2. \嗯,还行吧\\n3. \最糟糕的购买,完全浪费钱\\n\n只返回有效的 JSON,无需解释。
}
约束条件设置
bash
infsh app run openrouter/claude-sonnet-45 --input {
prompt: 用恰好 3 个要点总结这篇文章。每个要点不超过 20 个字。只关注可操作的见解,不要背景信息。\n\n[文章内容]
}
图像生成提示
基本结构
[主体] + [风格] + [构图] + [光照] + [技术参数]
主体描述
bash
糟糕:模糊不清
一只猫
优秀:具体明确
infsh app run falai/flux-dev --input {
prompt: 一只毛茸茸的橙色虎斑猫,绿色眼睛,坐在复古皮革扶手椅上
}
风格关键词
bash
infsh app run falai/flux-dev --input {
prompt: 女性肖像照片,使用柯达 Portra 400 胶片拍摄,柔和自然光,浅景深,怀旧氛围,模拟摄影美学
}
构图控制
bash
infsh app run falai/flux-dev --input {
prompt: 赛博朋克城市天际线夜景的广角定场镜头,三分法构图,前景霓虹灯招牌,背景摩天大楼,雨水浸湿的街道
}
质量关键词
照片级真实感,8K,超精细,锐利对焦,专业,
杰作,高质量,最佳质量,复杂细节
负面提示
bash
infsh app run falai/flux-dev --input {
prompt: 专业头像肖像,干净背景,
negative_prompt: 模糊,扭曲,多余肢体,水印,文字,低质量,卡通,动漫
}
视频提示
基本结构
[镜头类型] + [主体] + [动作] + [场景] + [风格]
镜头运动
bash
infsh app run google/veo-3-1-fast --input {
prompt: 缓慢跟拍镜头,跟随一位女性穿过阳光明媚的森林,黄金时刻光线,浅景深,电影感,4K
}
动作描述
bash
infsh app run google/veo-3-1-fast --input {
prompt: 特写镜头,双手在木制台面上揉面包面团,晨光中面粉飘浮,慢动作,温馨烘焙美学
}
时间关键词
慢动作,延时摄影,实时,流畅运动,
连续镜头,快速切换,定格瞬间
高级技巧
系统提示
bash
infsh app run openrouter/claude-sonnet-45 --input {
system: 你是一名乐于助人的编程助手。始终提供带注释的代码。如果不确定,请如实说明,不要猜测。,
prompt: 编写一个使用正则表达式验证电子邮件地址的 Python 函数。
}
结构化输出
bash
infsh app run openrouter/claude-sonnet-45 --input {
prompt: 从以下文本中提取信息并以 JSON 格式返回:\n\n\TechCorp 首席执行官 John Smith 昨天宣布,公司已获得 5000 万美元 B 轮融资。本轮融资由 Venture Partners 领投。\\n\n架构:\n{\n \person\: 字符串,\n \title\: 字符串,\n \company\: 字符串,\n \event\: 字符串,\n \amount\: 字符串,\n \investor\: 字符串\n}
}
迭代优化
bash
从宽泛开始
infsh app run falai/flux-dev --input {
prompt: 山上的城堡
}
添加细节
infsh app run falai/flux-dev --input {
prompt: 草地山丘上的中世纪石头城堡
}
添加风格
infsh app run falai/flux-dev --input {
prompt: 草地山丘上的中世纪石头城堡,戏剧性日落天空,奇幻艺术风格,史诗构图
}
添加技术参数
infsh app run falai/flux-dev --input {
prompt: 草地山丘上的中世纪石头城堡,戏剧性日落天空,Greg Rutkowski 风格的奇幻艺术,史诗构图,8K,高度精细
}
多轮推理
bash
第一步:分析
infsh app run openrouter/claude-sonnet-45 --input {
prompt: 分析这个业务问题:我们的电商网站购物车放弃率为 70%。列出可能的原因。
}
第二步:优先级排序
infsh app run openrouter/claude-sonnet-45 --input {
prompt: 针对这些购物车放弃原因:[上一步输出],按可能的影响和修复难度排序。格式化为优先级矩阵。
}
第三步:行动计划
infsh app run openrouter/claude-sonnet-45 --input {
prompt: 针对识别出的前 3 个原因,提供具体的 A/B 测试方案来验证和修复每个问题。
}
模型特定技巧
Claude