CLI commands
CLI สำหรับการอนุมาน
openclaw infer คืออินเทอร์เฟซแบบไม่ใช้หน้าจอหลักสำหรับการอนุมานที่ทำงานผ่านผู้ให้บริการ โดยเปิดเผยกลุ่มความสามารถ (model, image, audio, tts, video, web, embedding) ไม่ใช่ชื่อ RPC ดิบของ Gateway หรือรหัสเครื่องมือของเอเจนต์ openclaw capability ... เป็นนามแฝงของโครงสร้างคำสั่งเดียวกัน
เหตุผลที่ควรเลือกใช้แทนตัวห่อหุ้มผู้ให้บริการที่สร้างขึ้นเฉพาะกิจ:
- ใช้ผู้ให้บริการและโมเดลที่กำหนดค่าไว้ใน OpenClaw แล้วซ้ำได้
- มีเอนเวโลป
--jsonที่เสถียรสำหรับสคริปต์และระบบอัตโนมัติที่ขับเคลื่อนโดยเอเจนต์ (ดู เอาต์พุต JSON) - สำหรับคำสั่งย่อยส่วนใหญ่ จะทำงานผ่านเส้นทางภายในเครื่องตามปกติโดยไม่ใช้ Gateway
- สำหรับการตรวจสอบผู้ให้บริการแบบต้นทางถึงปลายทาง คำสั่งนี้จะทดสอบ CLI ที่เผยแพร่จริง การโหลดการกำหนดค่า การระบุเอเจนต์เริ่มต้น การเปิดใช้งาน Plugin ที่รวมมาให้ และรันไทม์ความสามารถที่ใช้ร่วมกัน ก่อนส่งคำขอไปยังผู้ให้บริการ
เปลี่ยน infer ให้เป็น Skills
คัดลอกและวางข้อความนี้ให้เอเจนต์:
อ่าน https://docs.openclaw.ai/cli/infer แล้วสร้าง Skills ที่กำหนดเส้นทางเวิร์กโฟลว์ทั่วไปของฉันไปยัง `openclaw infer`เน้นการเรียกใช้โมเดล การสร้างภาพ การสร้างวิดีโอ การถอดเสียง การสังเคราะห์เสียงพูด การค้นหาเว็บ และเวกเตอร์ฝังตัวSkills ที่ใช้ infer อย่างเหมาะสมจะจับคู่เจตนาทั่วไปของผู้ใช้กับคำสั่งย่อยที่ถูกต้อง มีตัวอย่างมาตรฐานสองสามรายการต่อเวิร์กโฟลว์ เลือกใช้ openclaw infer ... แทนทางเลือกระดับล่าง และไม่จัดทำเอกสารอินเทอร์เฟซ infer ทั้งหมดซ้ำในเนื้อหา Skills
โครงสร้างคำสั่ง
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 personas status enable disable set-provider set-persona video generate describe providers web search fetch providers embedding create providersinfer list / infer inspect --name <capability> แสดงโครงสร้างนี้ในรูปแบบข้อมูล (รหัสความสามารถ การรับส่งข้อมูล คำอธิบาย)
งานทั่วไป
| งาน | คำสั่ง | หมายเหตุ |
|---|---|---|
| เรียกใช้พรอมต์ข้อความ/โมเดล | openclaw infer model run --prompt "..." --json |
ใช้ภายในเครื่องโดยค่าเริ่มต้น |
| เรียกใช้พรอมต์โมเดลกับภาพ | 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 |
|
| สร้างเวกเตอร์ฝังตัว | openclaw infer embedding create --text "..." --json |
ลักษณะการทำงาน
- ใช้
--jsonเมื่อเอาต์พุตจะถูกส่งต่อให้คำสั่งหรือสคริปต์อื่น มิฉะนั้นให้ใช้เอาต์พุตข้อความ - ใช้
--providerหรือ--model provider/modelเพื่อระบุแบ็กเอนด์ที่ต้องการ - ใช้
model run --thinking <level>เพื่อแทนที่ระดับการคิด/การให้เหตุผลสำหรับการเรียกครั้งเดียว:off,minimal,low,medium,high,adaptive,xhighหรือmax - สำหรับ
image describe,audio transcribeและvideo describeค่า--modelต้องอยู่ในรูปแบบ<provider/model> - สำหรับ
image describeค่า--fileรับพาธภายในเครื่องและ URL แบบ HTTP(S) โดย URL ระยะไกลจะผ่านนโยบาย SSRF สำหรับการดึงสื่อตามปกติ - คำสั่งที่ทำงานแบบไร้สถานะ (
model run,image *,audio *,video *,web *,embedding *) ใช้ภายในเครื่องโดยค่าเริ่มต้น ส่วนคำสั่งสถานะที่ Gateway จัดการ (tts status) ใช้ Gateway โดยค่าเริ่มต้น - เส้นทางภายในเครื่องไม่จำเป็นต้องให้ Gateway ทำงานอยู่
model runภายในเครื่องคือการสร้างผลลัพธ์จากผู้ให้บริการแบบครั้งเดียวที่กระชับ โดยจะระบุโมเดลและข้อมูลยืนยันตัวตนของเอเจนต์ที่กำหนดค่าไว้ แต่จะไม่เริ่มรอบการสนทนาของเอเจนต์ โหลดเครื่องมือ หรือเปิดเซิร์ฟเวอร์ MCP ที่รวมมาให้model run --fileแนบไฟล์ภาพ (ตรวจหาชนิด MIME อัตโนมัติ) ไปกับพรอมต์ ใช้--fileซ้ำสำหรับหลายภาพ ระบบจะปฏิเสธไฟล์ที่ไม่ใช่ภาพ ให้ใช้infer audio transcribeหรือinfer video describeแทนmodel run --gatewayทดสอบการกำหนดเส้นทางของ Gateway ข้อมูลยืนยันตัวตนที่บันทึกไว้ การเลือกผู้ให้บริการ และรันไทม์แบบฝัง แต่ยังคงเป็นการตรวจสอบโมเดลดิบ โดยไม่มีบทสนทนาจากเซสชันก่อนหน้า บริบทบูตสแตรป/AGENTS เครื่องมือ หรือเซิร์ฟเวอร์ MCP ที่รวมมาให้model run --gateway --model <provider/model>ต้องใช้ข้อมูลประจำตัว Gateway ของผู้ดำเนินการที่เชื่อถือได้ เพราะเป็นการขอให้ Gateway ใช้การแทนที่ผู้ให้บริการ/โมเดลแบบครั้งเดียว
โมเดล
การอนุมานข้อความและการตรวจสอบโมเดล/ผู้ให้บริการ
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 --model gpt-5.6-sol --jsonใช้การอ้างอิง <provider/model> แบบเต็มกับ --local เพื่อทดสอบเบื้องต้นผู้ให้บริการหนึ่งรายโดยไม่เริ่ม Gateway หรือโหลดอินเทอร์เฟซเครื่องมือของเอเจนต์:
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.6-luna --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ภายในเครื่องคือการทดสอบเบื้องต้นผ่าน CLI ที่มีขอบเขตแคบที่สุดสำหรับตรวจสอบความพร้อมของผู้ให้บริการ/โมเดล/ข้อมูลยืนยันตัวตน โดยสำหรับผู้ให้บริการที่ไม่ใช่ ChatGPT-Codex ระบบจะส่งเฉพาะพรอมต์ที่ระบุเท่านั้นmodel run --model <provider/model>ภายในเครื่องสามารถระบุแถวในแค็ตตาล็อกแบบคงที่ที่รวมมาให้ได้อย่างแม่นยำ (แถวเดียวกับที่openclaw models list --allแสดง) ก่อนเขียนผู้ให้บริการนั้นลงในการกำหนดค่า ยังคงต้องมีข้อมูลยืนยันตัวตนของผู้ให้บริการ หากไม่มีข้อมูลประจำตัว ระบบจะล้มเหลวด้วยข้อผิดพลาดการยืนยันตัวตน ไม่ใช่Unknown model- สำหรับการตรวจสอบการให้เหตุผลของ Mistral Medium 3.5 ให้เว้นค่าอุณหภูมิไว้โดยไม่กำหนดหรือใช้ค่าเริ่มต้น Mistral ปฏิเสธ
reasoning_effort="high"เมื่อใช้temperature: 0ให้ใช้อุณหภูมิเริ่มต้นหรือค่าที่ไม่ใช่ศูนย์ เช่น0.7 - การตรวจสอบภายในเครื่องด้วย OpenAI ChatGPT/Codex OAuth (API
openai-chatgpt-responses) จะเพิ่มคำสั่งระบบขั้นต่ำเพื่อให้การรับส่งข้อมูลเติมฟิลด์instructionsที่จำเป็นได้ โดยไม่มีบริบทเอเจนต์แบบเต็ม เครื่องมือ หน่วยความจำ หรือบทสนทนาของเซสชัน model run --fileแนบเนื้อหาภาพไปยังข้อความผู้ใช้รายการเดียวโดยตรง รูปแบบทั่วไป (PNG, JPEG, WebP) ใช้งานได้เมื่อตรวจพบชนิด MIME เป็นimage/*ส่วนไฟล์ที่ไม่รองรับหรือระบุชนิดไม่ได้จะล้มเหลวก่อนเรียกผู้ให้บริการ ใช้infer image describeแทนเมื่อต้องการการกำหนดเส้นทางและกลไกสำรองของโมเดลภาพจาก OpenClaw แทนการตรวจสอบโมเดลหลายรูปแบบโดยตรง- โมเดลที่เลือกต้องรองรับอินพุตภาพ โมเดลที่รองรับเฉพาะข้อความอาจปฏิเสธคำขอที่ชั้นผู้ให้บริการ
model run --promptต้องมีข้อความที่ไม่ใช่เพียงอักขระช่องว่าง ระบบจะปฏิเสธพรอมต์ว่างก่อนเรียกผู้ให้บริการหรือ Gatewaymodel runภายในเครื่องจะจบการทำงานด้วยรหัสที่ไม่ใช่ศูนย์เมื่อผู้ให้บริการไม่ส่งเอาต์พุตข้อความ เพื่อไม่ให้ผู้ให้บริการที่เข้าถึงไม่ได้และผลลัพธ์ว่างดูเหมือนการตรวจสอบที่สำเร็จ- ใช้
model run --gatewayเพื่อทดสอบการกำหนดเส้นทางของ Gateway หรือการตั้งค่ารันไทม์เอเจนต์ โดยยังคงอินพุตโมเดลแบบดิบ ใช้openclaw agentหรืออินเทอร์เฟซแชตเมื่อต้องการบริบทเอเจนต์ เครื่องมือ หน่วยความจำ และบทสนทนาของเซสชันแบบเต็ม --thinking adaptiveจับคู่กับระดับmediumของรันไทม์การสร้างผลลัพธ์ ส่วน--thinking maxจับคู่กับmaxสำหรับโมเดล OpenAI ที่รองรับระดับความพยายามสูงสุดโดยตรง มิฉะนั้นจะใช้xhighmodel auth login,model auth logoutและmodel auth statusใช้จัดการสถานะข้อมูลยืนยันตัวตนของผู้ให้บริการที่บันทึกไว้
ภาพ
การสร้าง การแก้ไข และการอธิบาย
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จะเพิ่มคำใบ้ด้านเรขาคณิตสำหรับผู้ให้บริการ/โมเดลที่รองรับ -
--output-format png --background transparentร่วมกับ--model openai/gpt-image-1.5จะสร้างเอาต์พุต PNG พื้นหลังโปร่งใสจาก OpenAI โดย--openai-backgroundเป็นนามแฝงเฉพาะ OpenAI สำหรับคำใบ้เดียวกัน ผู้ให้บริการที่ไม่ได้ประกาศว่ารองรับพื้นหลังจะรายงานว่าเป็นการกำหนดค่าทับที่ถูกละเว้น (ดูignoredOverridesในซองข้อมูล JSON) -
--quality low|medium|high|autoใช้ได้กับผู้ให้บริการที่รองรับคำใบ้ด้านคุณภาพรูปภาพ รวมถึง OpenAI นอกจากนี้ OpenAI ยังยอมรับ--openai-moderation low|auto -
image providers --jsonแสดงรายการผู้ให้บริการรูปภาพแบบรวมมาให้ที่ระบบค้นพบได้ กำหนดค่าแล้ว เลือกใช้อยู่ และความสามารถด้านการสร้าง/แก้ไขที่แต่ละรายเปิดให้ใช้ -
image generate --model <provider/model> --jsonเป็นการทดสอบควันแบบสดที่เจาะจงที่สุดสำหรับการเปลี่ยนแปลงด้านการสร้างรูปภาพ: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การตอบกลับจะรายงาน
ok,provider,model,attemptsและพาธของเอาต์พุตที่เขียนแล้ว เมื่อกำหนด--outputนามสกุลสุดท้ายอาจเปลี่ยนตามชนิด MIME ที่ผู้ให้บริการส่งกลับ -
สำหรับ
image describeและimage describe-manyให้ใช้--promptเพื่อระบุคำสั่งเฉพาะงาน (OCR, การเปรียบเทียบ, การตรวจสอบ UI, การสร้างคำบรรยายแบบกระชับ) -
ใช้
--timeout-msสำหรับโมเดลการมองเห็นภายในเครื่องที่ทำงานช้า หรือการเริ่มต้น Ollama แบบเย็น -
สำหรับ
image describeระบบจะเรียกใช้--modelที่ระบุอย่างชัดเจน (ต้องเป็น<provider/model>ที่รองรับรูปภาพ) ก่อน จากนั้นจะลองใช้agents.defaults.imageModel.fallbacksที่กำหนดค่าไว้หากการเรียกนั้นล้มเหลว ข้อผิดพลาดในการเตรียมอินพุต (ไฟล์หาย, URL ที่ไม่รองรับ) จะทำให้ล้มเหลวก่อนลองใช้ตัวสำรองใด ๆ และโมเดลต้องรองรับรูปภาพในแคตตาล็อกโมเดลหรือการกำหนดค่าผู้ให้บริการ -
สำหรับโมเดลการมองเห็น Ollama ภายในเครื่อง ให้ดึงโมเดลมาก่อนและตั้งค่า
OLLAMA_API_KEYเป็นค่าตัวยึดตำแหน่งใด ๆ เช่นollama-localดู Ollama
เสียง
การถอดเสียงไฟล์ (ไม่ใช่การจัดการเซสชันแบบเรียลไทม์)
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--model ต้องเป็น <provider/model>
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 personas --jsonopenclaw infer tts status --jsonหมายเหตุ:
tts statusรองรับเฉพาะ--gateway(คำสั่งนี้สะท้อนสถานะ TTS ที่ Gateway จัดการ)- ใช้
tts providers,tts voices,tts personas,tts set-providerและtts set-personaเพื่อตรวจสอบและกำหนดค่าพฤติกรรม TTS
วิดีโอ
การสร้างและการอธิบาย
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
เว็บ
การค้นหาและการดึงข้อมูล
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 --jsonweb providers แสดงรายการผู้ให้บริการที่พร้อมใช้งาน กำหนดค่าแล้ว และเลือกใช้อยู่สำหรับการค้นหาและการดึงข้อมูล
การฝังเวกเตอร์
การสร้างเวกเตอร์และการตรวจสอบผู้ให้บริการการฝังเวกเตอร์
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 ให้อยู่ภายใต้ซองข้อมูลร่วม:
{ "ok": true, "capability": "image.generate", "transport": "local", "provider": "openai", "model": "gpt-image-2", "attempts": [], "outputs": []}ฟิลด์ระดับบนสุดที่เสถียร:
okcapabilitytransportprovidermodelattemptsinputs(ไฟล์แนบรูปภาพที่ส่งพร้อมคำขอ เมื่อเกี่ยวข้อง)outputsignoredOverrides(คีย์คำใบ้ที่ผู้ให้บริการไม่รองรับ เมื่อเกี่ยวข้อง)error
สำหรับคำสั่งสร้างสื่อ 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