Test AI Providers with OpenClaw
Promptfoo example testing OpenClaw's personal AI assistant gateway, agents, and embeddings via auto-detected config.
Why it matters
Automate the testing and evaluation of AI providers using the OpenClaw framework. Ensure your AI integrations are robust and performant by running comprehensive test suites.
Outcomes
What it gets done
Integrate promptfoo with OpenClaw for AI provider testing.
Define and execute test cases for AI model responses.
Analyze test results to identify areas for improvement.
Facilitate code review and debugging of AI interactions.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/pfoo-provider-openclaw | bash Steps
Steps in the chain
Overview
Provider Openclaw
A promptfoo example testing an OpenClaw personal AI assistant gateway's chat, agent, and embedding endpoints via auto-detected or explicit connection config. Use when you already run an OpenClaw gateway and want to evaluate its chat, agent, or embedding endpoints through promptfoo.
What it does
This example demonstrates how to use promptfoo with OpenClaw, a personal AI assistant framework. The promptfoo provider auto-detects the gateway URL and bearer auth secret from the active OpenClaw config (OPENCLAW_CONFIG_PATH when set, otherwise ~/.openclaw/openclaw.json), including local bind/port, OPENCLAW_GATEWAY_PORT overrides, gateway.tls.enabled, and gateway.mode=remote with gateway.remote.url.
When to use - and when NOT to
Use this example when you're already running an OpenClaw gateway and want promptfoo to evaluate it - its chat/responses endpoints, its agents, or its embeddings - through auto-detected or explicitly configured connection settings. It is not an OpenClaw setup guide beyond onboarding and enabling the HTTP API; it assumes OpenClaw itself is installed and running.
Inputs and outputs
Install OpenClaw (npm install -g openclaw@latest), run openclaw onboard, enable the HTTP API's chatCompletions/responses endpoints in ~/.openclaw/openclaw.json (disabled by default upstream), and start the gateway with openclaw gateway (or openclaw gateway restart). Then:
npx promptfoo@latest init --example provider-openclaw
cd provider-openclaw
npx promptfoo@latest eval
Auto-detection can be overridden explicitly via provider config (gateway_url, auth_token or auth_password, and an optional backend_model override sent as the x-openclaw-model header) or via environment variables (OPENCLAW_CONFIG_PATH, OPENCLAW_GATEWAY_URL, OPENCLAW_GATEWAY_PORT, OPENCLAW_GATEWAY_TOKEN, or OPENCLAW_GATEWAY_PASSWORD for password-mode gateways).
Integrations
Integrates OpenClaw's gateway as a promptfoo provider family: openclaw:main for the primary session, openclaw:agent:* (which generates an isolated session key per call by default, separate from the persistent main session, unless session_key is set explicitly for continuity), and openclaw:embedding:main/openclaw:embeddings:<agent-id> for the /v1/embeddings endpoint (with backend_model selecting a specific embedding model such as openai/text-embedding-3-small). The WS provider signs OpenClaw's connect.challenge, persists issued device tokens, and retries once with a cached device token when the gateway recommends it.
Who it's for
Teams running OpenClaw as their personal AI assistant gateway who want to evaluate its chat, agent, and embedding endpoints through promptfoo using either auto-detected local config or explicit remote gateway settings.
Source README
provider-openclaw (OpenClaw Agent Testing)
This example demonstrates how to use promptfoo with OpenClaw, a personal AI assistant framework.
Prerequisites
- Install OpenClaw:
npm install -g openclaw@latest - Run the onboarding wizard:
openclaw onboard - Enable the HTTP API in
~/.openclaw/openclaw.jsonif you want Chat or Responses.
These HTTP endpoints are disabled by default upstream:{ "gateway": { "http": { "endpoints": { "chatCompletions": { "enabled": true }, "responses": { "enabled": true } } } } } - Start the gateway:
openclaw gateway(or restart if already running:openclaw gateway restart)
Setup
npx promptfoo@latest init --example provider-openclaw
cd provider-openclaw
Usage
npx promptfoo@latest eval
The provider auto-detects the gateway URL and bearer auth secret from the active OpenClaw config
(OPENCLAW_CONFIG_PATH when set, otherwise ~/.openclaw/openclaw.json). This includes local
bind/port, OPENCLAW_GATEWAY_PORT local port overrides, gateway.tls.enabled, andgateway.mode=remote with gateway.remote.url.
Configuration
You can override auto-detection with explicit config:
providers:
- id: openclaw:main
config:
gateway_url: http://127.0.0.1:18789
auth_token: your-token-here
# Use auth_password instead when gateway.auth.mode=password
# Optional backend model override, sent as x-openclaw-model:
backend_model: openai/gpt-5.6-terra
Or use environment variables:
export OPENCLAW_CONFIG_PATH=~/.openclaw/openclaw.json # optional
export OPENCLAW_GATEWAY_URL=http://127.0.0.1:18789
### Or override only the local auto-detected port:
### export OPENCLAW_GATEWAY_PORT=18789
export OPENCLAW_GATEWAY_TOKEN=your-token-here
### Or, if your gateway uses password auth:
### export OPENCLAW_GATEWAY_PASSWORD=your-password-here
For openclaw:agent:*, promptfoo generates an isolated session key per call by default so evals do
not reuse your persistent OpenClaw main session. Set session_key explicitly if you want session
continuity. The WS provider signs OpenClaw's connect.challenge, persists issued device tokens,
and retries once with a cached device token when the gateway recommends it.
Use openclaw:embedding:main or openclaw:embeddings:<agent-id> for /v1/embeddings. Setbackend_model when you want a specific embedding model such as openai/text-embedding-3-small.
For password-mode gateways, use auth_password or OPENCLAW_GATEWAY_PASSWORD.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.