CLI commands
CLI สำหรับการอนุมาน
openclaw infer คือพื้นผิวแบบ headless มาตรฐานสำหรับเวิร์กโฟลว์การอนุมานที่มีผู้ให้บริการรองรับ
โดยตั้งใจเปิดเผย capability families ไม่ใช่ชื่อ gateway RPC ดิบ และไม่ใช่ raw agent tool ids ดิบ
เปลี่ยน infer ให้เป็น skill
คัดลอกและวางสิ่งนี้ให้ agent:
Read https://docs.openclaw.ai/cli/infer, then create a skill that routes my common workflows to `openclaw infer`.Focus on model runs, image generation, video generation, audio transcription, TTS, web search, and embeddings.skill ที่ดีซึ่งอิง infer ควร:
- จับคู่เจตนาทั่วไปของผู้ใช้กับ infer subcommand ที่ถูกต้อง
- มีตัวอย่าง infer มาตรฐานไม่กี่ตัวอย่างสำหรับเวิร์กโฟลว์ที่ครอบคลุม
- เลือกใช้
openclaw infer ...ในตัวอย่างและคำแนะนำ - หลีกเลี่ยงการเขียนเอกสารพื้นผิว infer ทั้งหมดซ้ำภายในเนื้อหา skill
ขอบเขตทั่วไปของ skill ที่เน้น infer:
openclaw infer model runopenclaw infer image generateopenclaw infer audio transcribeopenclaw infer tts convertopenclaw infer web searchopenclaw infer embedding create
เหตุผลที่ใช้ infer
openclaw infer ให้ CLI เดียวที่สอดคล้องกันสำหรับงานการอนุมานที่มีผู้ให้บริการรองรับภายใน OpenClaw
ประโยชน์:
- ใช้ผู้ให้บริการและโมเดลที่กำหนดค่าไว้แล้วใน OpenClaw แทนการต่อ wrapper เฉพาะกิจสำหรับ backend แต่ละตัว
- เก็บเวิร์กโฟลว์โมเดล รูปภาพ การถอดเสียง เสียงเป็นข้อความ วิดีโอ เว็บ และ embedding ไว้ภายใต้ command tree เดียว
- ใช้รูปแบบเอาต์พุต
--jsonที่เสถียรสำหรับสคริปต์ ระบบอัตโนมัติ และเวิร์กโฟลว์ที่ขับเคลื่อนด้วย agent - เลือกใช้พื้นผิว OpenClaw แบบ first-party เมื่องานนั้นโดยพื้นฐานคือ "รันการอนุมาน"
- ใช้เส้นทาง local ปกติโดยไม่ต้องใช้ gateway สำหรับคำสั่ง infer ส่วนใหญ่
สำหรับการตรวจสอบผู้ให้บริการแบบ end-to-end ให้เลือกใช้ openclaw infer ... เมื่อการทดสอบ
ผู้ให้บริการระดับล่างผ่านแล้ว คำสั่งนี้ทดสอบ CLI ที่จัดส่งจริง การโหลด config
การ resolve default-agent การเปิดใช้งาน bundled Plugin และ runtime ของ capability
ร่วมกันก่อนส่งคำขอไปยังผู้ให้บริการ
Command tree
openclaw infer list inspect model run list inspect providers auth login auth logout auth status image generate edit describe describe-many providers audio transcribe providers tts convert voices providers status enable disable set-provider video generate describe providers web search fetch providers embedding create providersงานทั่วไป
ตารางนี้จับคู่งานการอนุมานทั่วไปกับคำสั่ง infer ที่สอดคล้องกัน
| งาน | คำสั่ง | หมายเหตุ |
|---|---|---|
| รันพรอมป์ข้อความ/โมเดล | openclaw infer model run --prompt "..." --json |
ใช้เส้นทาง local ปกติเป็นค่าเริ่มต้น |
| รันพรอมป์โมเดลกับรูปภาพ | openclaw infer model run --prompt "Describe this" --file ./image.png --model provider/model |
ระบุ --file ซ้ำสำหรับอินพุตรูปภาพหลายรายการ |
| สร้างรูปภาพ | openclaw infer image generate --prompt "..." --json |
ใช้ image edit เมื่อเริ่มจากไฟล์ที่มีอยู่ |
| อธิบายไฟล์รูปภาพหรือ URL | openclaw infer image describe --file ./image.png --prompt "..." --json |
--model ต้องเป็น <provider/model> ที่รองรับรูปภาพ |
| ถอดเสียง | openclaw infer audio transcribe --file ./memo.m4a --json |
--model ต้องเป็น <provider/model> |
| สังเคราะห์เสียงพูด | openclaw infer tts convert --text "..." --output ./speech.mp3 --json |
tts status มุ่งเน้น Gateway |
| สร้างวิดีโอ | openclaw infer video generate --prompt "..." --json |
รองรับคำใบ้สำหรับผู้ให้บริการ เช่น --resolution |
| อธิบายไฟล์วิดีโอ | openclaw infer video describe --file ./clip.mp4 --json |
--model ต้องเป็น <provider/model> |
| ค้นหาเว็บ | openclaw infer web search --query "..." --json |
|
| ดึงหน้าเว็บ | openclaw infer web fetch --url https://example.com --json |
|
| สร้าง embeddings | openclaw infer embedding create --text "..." --json |
พฤติกรรม
openclaw infer ...คือพื้นผิว CLI หลักสำหรับเวิร์กโฟลว์เหล่านี้- ใช้
--jsonเมื่อเอาต์พุตจะถูกใช้โดยคำสั่งหรือสคริปต์อื่น - ใช้
--providerหรือ--model provider/modelเมื่อต้องการ backend เฉพาะ - ใช้
model run --thinking <level>เพื่อส่งระดับ thinking/reasoning แบบ one-shot (off,minimal,low,medium,high,adaptive,xhighหรือmax) โดยยังคงให้การรันเป็นแบบ raw - สำหรับ
image describe,audio transcribeและvideo describeนั้น--modelต้องใช้รูปแบบ<provider/model> - สำหรับ
image describeนั้น--fileรับ path local และ URL รูปภาพ HTTP(S) URL ระยะไกลใช้ media-fetch SSRF policy ปกติ - สำหรับ
image describeนั้น--modelที่ระบุชัดเจนจะรัน provider/model นั้นโดยตรง โมเดลต้องรองรับรูปภาพใน model catalog หรือ provider configcodex/<model>รันรอบการเข้าใจรูปภาพของ Codex app-server แบบมีขอบเขต;openai/<model>ใช้เส้นทางผู้ให้บริการ OpenAI พร้อม auth แบบ API-key หรือ ChatGPT/Codex OAuth - คำสั่งการทำงานแบบ stateless ใช้ local เป็นค่าเริ่มต้น
- คำสั่งสถานะที่ Gateway จัดการใช้ gateway เป็นค่าเริ่มต้น
- เส้นทาง local ปกติไม่จำเป็นต้องให้ gateway ทำงานอยู่
model runแบบ local คือ provider completion แบบ one-shot ที่กระชับ โดย resolve โมเดลและ auth ของ agent ที่กำหนดค่าไว้ แต่ไม่เริ่มรอบ chat-agent ไม่โหลด tools และไม่เปิด bundled MCP serversmodel run --fileรับไฟล์รูปภาพ ตรวจจับ MIME type และส่งไปพร้อมพรอมป์ที่ระบุไปยังโมเดลที่เลือก ระบุ--fileซ้ำสำหรับหลายรูปภาพmodel run --fileปฏิเสธอินพุตที่ไม่ใช่รูปภาพ ใช้infer audio transcribeสำหรับไฟล์เสียง และinfer video describeสำหรับไฟล์วิดีโอmodel run --gatewayทดสอบการ routing ของ Gateway, auth ที่บันทึกไว้, การเลือกผู้ให้บริการ และ runtime แบบฝังตัว แต่ยังคงรันเป็น raw model probe: ส่งพรอมป์ที่ให้มาและไฟล์แนบรูปภาพใดๆ โดยไม่มี transcript ของ session ก่อนหน้า, บริบท bootstrap/AGENTS, การประกอบ context-engine, tools หรือ bundled MCP serversmodel run --gateway --model <provider/model>ต้องใช้ credential ของ operator gateway ที่เชื่อถือได้ เพราะคำขอให้ Gateway รัน provider/model override แบบ one-offmodel run --thinkingแบบ local ใช้เส้นทาง provider-completion ที่กระชับ; ระดับเฉพาะผู้ให้บริการ เช่นadaptiveและmaxจะถูก map ไปยังระดับ simple-completion แบบ portable ที่ใกล้ที่สุด
โมเดล
ใช้ model สำหรับการอนุมานข้อความที่มีผู้ให้บริการรองรับ และการตรวจสอบโมเดล/ผู้ให้บริการ
openclaw infer model run --prompt "Reply with exactly: smoke-ok" --jsonopenclaw infer model run --prompt "Summarize this changelog entry" --model openai/gpt-5.4 --jsonopenclaw infer model run --prompt "Describe this image in one sentence" --file ./photo.jpg --model google/gemini-2.5-flash --jsonopenclaw infer model run --prompt "Use more reasoning here" --thinking high --jsonopenclaw infer model providers --jsonopenclaw infer model inspect --name gpt-5.5 --jsonใช้ refs แบบเต็ม <provider/model> เพื่อ smoke-test ผู้ให้บริการเฉพาะรายโดยไม่ต้อง
เริ่ม Gateway หรือโหลดพื้นผิว agent tool ทั้งหมด:
openclaw infer model run --local --model anthropic/claude-sonnet-4-6 --prompt "Reply with exactly: pong" --jsonopenclaw infer model run --local --model cerebras/zai-glm-4.7 --prompt "Reply with exactly: pong" --jsonopenclaw infer model run --local --model google/gemini-2.5-flash --prompt "Reply with exactly: pong" --jsonopenclaw infer model run --local --model groq/llama-3.1-8b-instant --prompt "Reply with exactly: pong" --jsonopenclaw infer model run --local --model mistral/mistral-medium-3-5 --prompt "Reply with exactly: pong" --jsonopenclaw infer model run --local --model mistral/mistral-small-latest --prompt "Reply with exactly: pong" --jsonopenclaw infer model run --local --model openai/gpt-5.5 --prompt "Reply with exactly: pong" --jsonopenclaw infer model run --local --model ollama/qwen2.5vl:7b --prompt "Describe this image." --file ./photo.jpg --jsonหมายเหตุ:
model runแบบ local คือ smoke CLI ที่แคบที่สุดสำหรับสุขภาพของผู้ให้บริการ/โมเดล/auth เพราะสำหรับผู้ให้บริการที่ไม่ใช่ Codex คำสั่งนี้ส่งเฉพาะพรอมป์ที่ให้มาไปยังโมเดลที่เลือกmodel run --model <provider/model>แบบ local สามารถใช้แถว static catalog แบบ bundled ที่แน่นอนจากmodels list --allก่อนที่จะเขียนผู้ให้บริการนั้นลง config ได้ ยังต้องใช้ auth ของผู้ให้บริการอยู่; credential ที่หายไปจะล้มเหลวเป็นข้อผิดพลาด auth ไม่ใช่Unknown model- สำหรับ reasoning probes ของ Mistral Medium 3.5 ให้ปล่อย temperature เป็น unset/default Mistral ปฏิเสธ
reasoning_effort="high"พร้อมtemperature: 0; ใช้mistral/mistral-medium-3-5กับ temperature ค่าเริ่มต้น หรือค่า reasoning-mode ที่ไม่ใช่ศูนย์ เช่น0.7 - local probes ของ Codex Responses เป็นข้อยกเว้นแคบๆ: OpenClaw เพิ่มคำสั่งระบบขั้นต่ำเพื่อให้ transport เติมฟิลด์
instructionsที่จำเป็นได้ โดยไม่เพิ่มบริบท agent แบบเต็ม tools, memory หรือ transcript ของ session model run --fileแบบ local คงเส้นทางที่กระชับนั้นไว้ และแนบเนื้อหารูปภาพเข้ากับข้อความผู้ใช้เดียวโดยตรง ไฟล์รูปภาพทั่วไป เช่น PNG, JPEG และ WebP ใช้งานได้เมื่อ MIME type ถูกตรวจพบเป็นimage/*; ไฟล์ที่ไม่รองรับหรือไม่รู้จักจะล้มเหลวก่อนเรียกผู้ให้บริการmodel run --fileเหมาะที่สุดเมื่อคุณต้องการทดสอบโมเดลข้อความ multimodal ที่เลือกโดยตรง ใช้infer image describeเมื่อคุณต้องการการเลือกผู้ให้บริการด้านการเข้าใจรูปภาพของ OpenClaw และการ routing โมเดลรูปภาพเริ่มต้น- โมเดลที่เลือกต้องรองรับอินพุตรูปภาพ; โมเดลข้อความอย่างเดียวอาจปฏิเสธคำขอที่ชั้นผู้ให้บริการ
model run --promptต้องมีข้อความที่ไม่ใช่ช่องว่าง; พรอมป์ว่างจะถูกปฏิเสธก่อนเรียกผู้ให้บริการ local หรือ Gatewaymodel runแบบ local ออกด้วยสถานะ non-zero เมื่อผู้ให้บริการไม่ส่งเอาต์พุตข้อความกลับมา ดังนั้นผู้ให้บริการ local ที่เข้าถึงไม่ได้และ completion ว่างจะไม่ดูเหมือน probe ที่สำเร็จ- ใช้
model run --gatewayเมื่อคุณต้องทดสอบการ routing ของ Gateway, การตั้งค่า agent-runtime หรือสถานะผู้ให้บริการที่ Gateway จัดการ โดยยังคงให้อินพุตโมเดลเป็น raw ใช้openclaw agentหรือพื้นผิวแชทเมื่อคุณต้องการบริบท agent แบบเต็ม tools, memory และ transcript ของ session model auth login,model auth logoutและmodel auth statusจัดการสถานะ auth ของผู้ให้บริการที่บันทึกไว้
รูปภาพ
ใช้ image สำหรับการสร้าง การแก้ไข และคำอธิบาย
openclaw infer image generate --prompt "friendly lobster illustration" --jsonopenclaw infer image generate --prompt "cinematic product photo of headphones" --jsonopenclaw infer image generate --model openai/gpt-image-1.5 --output-format png --background transparent --prompt "simple red circle sticker on a transparent background" --jsonopenclaw infer image generate --model openai/gpt-image-2 --quality low --openai-moderation low --prompt "low-cost draft poster" --jsonopenclaw infer image generate --prompt "slow image backend" --timeout-ms 180000 --jsonopenclaw infer image edit --file ./logo.png --model openai/gpt-image-1.5 --output-format png --background transparent --prompt "keep the logo, remove the background" --jsonopenclaw infer image edit --file ./poster.png --prompt "make this a vertical story ad" --size 2160x3840 --aspect-ratio 9:16 --resolution 4K --jsonopenclaw infer image describe --file ./photo.jpg --jsonopenclaw infer image describe --file https://example.com/photo.png --jsonopenclaw infer image describe --file ./receipt.jpg --prompt "Extract the merchant, date, and total" --jsonopenclaw infer image describe-many --file ./before.png --file ./after.png --prompt "Compare the screenshots and list visible UI changes" --jsonopenclaw infer image describe --file ./ui-screenshot.png --model openai/gpt-5.4-mini --jsonopenclaw infer image describe --file ./photo.jpg --model ollama/qwen2.5vl:7b --prompt "Describe the image in one sentence" --timeout-ms 300000 --jsonหมายเหตุ:
-
ใช้
image editเมื่อเริ่มจากไฟล์อินพุตที่มีอยู่แล้ว -
ใช้
--size,--aspect-ratioหรือ--resolutionกับimage editสำหรับ ผู้ให้บริการ/โมเดลที่รองรับคำใบ้เรขาคณิตในการแก้ไขรูปภาพอ้างอิง -
ใช้
--output-format png --background transparentกับ--model openai/gpt-image-1.5สำหรับเอาต์พุต PNG ของ OpenAI ที่มีพื้นหลังโปร่งใส;--openai-backgroundยังคงพร้อมใช้งานในฐานะ alias เฉพาะของ OpenAI ผู้ให้บริการ ที่ไม่ได้ประกาศการรองรับพื้นหลังจะรายงานคำใบ้นี้เป็น override ที่ถูกละเว้น -
ใช้
--quality low|medium|high|autoสำหรับผู้ให้บริการที่รองรับคำใบ้คุณภาพรูปภาพ รวมถึง OpenAI ด้วย OpenAI ยังยอมรับ--openai-moderation low|autoสำหรับ คำใบ้การกลั่นกรองเฉพาะผู้ให้บริการ -
ใช้
image providers --jsonเพื่อตรวจสอบว่าผู้ให้บริการรูปภาพที่รวมมา ค้นพบได้ กำหนดค่าแล้ว ถูกเลือก และความสามารถในการสร้าง/แก้ไขใดบ้าง ที่แต่ละผู้ให้บริการเปิดเผย -
ใช้
image generate --model <provider/model> --jsonเป็นการทดสอบ live CLI smoke ที่แคบที่สุดสำหรับการเปลี่ยนแปลงการสร้างรูปภาพ ตัวอย่าง:bash openclaw infer image providers --jsonopenclaw infer image generate \ --model google/gemini-3.1-flash-image-preview \ --prompt "Minimal flat test image: one blue square on a white background, no text." \ --output ./openclaw-infer-image-smoke.png \ --jsonการตอบกลับ JSON จะรายงาน
ok,provider,model,attemptsและพาธเอาต์พุต ที่เขียนไว้ เมื่อกำหนด--outputแล้ว นามสกุลสุดท้ายอาจตาม MIME type ที่ผู้ให้บริการส่งกลับมา -
สำหรับ
image describeและimage describe-manyให้ใช้--promptเพื่อให้คำสั่งเฉพาะงานแก่โมเดลวิชัน เช่น OCR, การเปรียบเทียบ, การตรวจสอบ UI หรือคำบรรยายสั้นกระชับ -
ใช้
--timeout-msกับโมเดลวิชันภายในเครื่องที่ช้า หรือการเริ่ม Ollama แบบเย็น -
สำหรับ
image describe,--modelต้องเป็น<provider/model>ที่รองรับรูปภาพ -
สำหรับโมเดลวิชัน Ollama ภายในเครื่อง ให้ดึงโมเดลก่อนและตั้งค่า
OLLAMA_API_KEYเป็นค่าตัวยึดตำแหน่งใดก็ได้ เช่นollama-localดู Ollama
เสียง
ใช้ audio สำหรับการถอดเสียงจากไฟล์
openclaw infer audio transcribe --file ./memo.m4a --jsonopenclaw infer audio transcribe --file ./team-sync.m4a --language en --prompt "Focus on names and action items" --jsonopenclaw infer audio transcribe --file ./memo.m4a --model openai/whisper-1 --jsonหมายเหตุ:
audio transcribeใช้สำหรับการถอดเสียงจากไฟล์ ไม่ใช่การจัดการเซสชันแบบเรียลไทม์--modelต้องเป็น<provider/model>
TTS
ใช้ tts สำหรับการสังเคราะห์เสียงพูดและสถานะผู้ให้บริการ TTS
openclaw infer tts convert --text "hello from openclaw" --output ./hello.mp3 --jsonopenclaw infer tts convert --text "Your build is complete" --output ./build-complete.mp3 --jsonopenclaw infer tts providers --jsonopenclaw infer tts status --jsonหมายเหตุ:
tts statusมีค่าเริ่มต้นเป็น gateway เพราะสะท้อนสถานะ TTS ที่ Gateway จัดการ- ใช้
tts providers,tts voicesและtts set-providerเพื่อตรวจสอบและกำหนดค่าพฤติกรรม TTS
วิดีโอ
ใช้ video สำหรับการสร้างและการอธิบาย
openclaw infer video generate --prompt "cinematic sunset over the ocean" --jsonopenclaw infer video generate --prompt "slow drone shot over a forest lake" --resolution 768P --duration 6 --jsonopenclaw infer video describe --file ./clip.mp4 --jsonopenclaw infer video describe --file ./clip.mp4 --model openai/gpt-5.4-mini --jsonหมายเหตุ:
video generateยอมรับ--size,--aspect-ratio,--resolution,--duration,--audio,--watermarkและ--timeout-msแล้วส่งต่อไปยังรันไทม์การสร้างวิดีโอ--modelต้องเป็น<provider/model>สำหรับvideo describe
เว็บ
ใช้ web สำหรับเวิร์กโฟลว์การค้นหาและการดึงข้อมูล
openclaw infer web search --query "OpenClaw docs" --jsonopenclaw infer web search --query "OpenClaw infer web providers" --jsonopenclaw infer web fetch --url https://docs.openclaw.ai/cli/infer --jsonopenclaw infer web providers --jsonหมายเหตุ:
- ใช้
web providersเพื่อตรวจสอบผู้ให้บริการที่พร้อมใช้งาน กำหนดค่าแล้ว และถูกเลือก
Embedding
ใช้ embedding สำหรับการสร้างเวกเตอร์และการตรวจสอบผู้ให้บริการ embedding
openclaw infer embedding create --text "friendly lobster" --jsonopenclaw infer embedding create --text "customer support ticket: delayed shipment" --model openai/text-embedding-3-large --jsonopenclaw infer embedding providers --jsonเอาต์พุต JSON
คำสั่ง infer ทำให้เอาต์พุต JSON อยู่ใน envelope ร่วมแบบมาตรฐาน:
{ "ok": true, "capability": "image.generate", "transport": "local", "provider": "openai", "model": "gpt-image-2", "attempts": [], "outputs": []}ฟิลด์ระดับบนสุดมีความเสถียร:
okcapabilitytransportprovidermodelattemptsoutputserror
สำหรับคำสั่งสื่อที่สร้างขึ้น outputs จะมีไฟล์ที่ OpenClaw เขียนไว้ ใช้
path, mimeType, size และมิติที่เฉพาะกับสื่อใดๆ ในอาร์เรย์นั้น
สำหรับระบบอัตโนมัติ แทนการแยกวิเคราะห์ stdout ที่มนุษย์อ่านได้
ข้อผิดพลาดที่พบบ่อย
# Badopenclaw infer media image generate --prompt "friendly lobster" # Goodopenclaw infer image generate --prompt "friendly lobster"# Badopenclaw infer audio transcribe --file ./memo.m4a --model whisper-1 --json # Goodopenclaw infer audio transcribe --file ./memo.m4a --model openai/whisper-1 --jsonหมายเหตุ
openclaw capability ...เป็น alias สำหรับopenclaw infer ...