Canonical docs: https://apidoc.cometapi.com/integrations/promptfoo
Use this guide to configure Promptfoo with CometAPI by setting the base URL, API key, and model or provider options.
Promptfoo is a framework for prompt evaluation, regression testing, and AI red teaming. Promptfoo includes a cometapi provider that calls CometAPI through OpenAI-compatible endpoints.
- Node.js 18+
- Promptfoo installed locally or run through
npx - A CometAPI account with an active API key — get yours in the dashboard
- A model ID from the CometAPI Models page
Set COMETAPI_KEY before you run evaluations:
read -rsp "CometAPI API key: " COMETAPI_KEY
printf '\n'
export COMETAPI_KEYPromptfoo uses the following provider ID format for CometAPI:
providers:
- cometapi:<type>:<model>Use these provider types:
| Type | Use case |
|---|---|
chat |
Chat completions, vision, and multimodal prompts |
completion |
Text completion models |
embedding |
Text embedding evaluations |
image |
Image generation evaluations |
You can also use cometapi:your-model-id for the default chat mode.
The following command runs a one-prompt chat evaluation:
npx promptfoo@latest eval \
--prompts "Write a concise release note for {{feature}}" \
--vars feature="a unified API dashboard" \
-r cometapi:chat:your-model-idThe following promptfooconfig.yaml evaluates the same prompt against a CometAPI model:
prompts:
- "Classify this support request: {{message}}"
providers:
- id: cometapi:chat:your-model-id
config:
temperature: 0.2
max_tokens: 256
tests:
- vars:
message: "The API key works locally but fails in production."
assert:
- type: contains-any
value:
- authentication
- configurationRun the config file with Promptfoo:
npx promptfoo@latest eval -c promptfooconfig.yamlUse a provider type that matches the model behavior that you want to evaluate:
providers:
- cometapi:chat:your-model-id
- cometapi:completion:your-model-id
- cometapi:embedding:your-model-id
- cometapi:image:your-model-idFor multimodal tests, keep the chat provider type and pass image variables through Promptfoo test variables.
Confirm that COMETAPI_KEY is exported in the same shell session that runs promptfoo eval.
Use chat for conversational and multimodal models, embedding for embedding models, and image for image generation models.
Replace your-model-id with an exact model ID from the CometAPI Models page.