Promptfoo

Promptfoo is a CLI and library for evaluating prompts, models, agents and retrieval applications

来源语言 · EN

先看实际效果

产品界面预览

Promptfoo: compare outputs and assertion failures side by side

Original documentation viewer image with twelve demonstration cases, Model A columns, outputs and assertion explanations. Passing percentages, token/latency figures and the 2025 eval ID belong to the author demo; they are not current-model rankings, real provider benchmarks or results of the separate recipes below.

Promptfoo: compare outputs and assertion failures side by side
查看完整图片
许可

Full original license retained. Author interface previews, usage recipes and illustrative/expected output remain distinct from independently reproduced results. No source instructions, scripts, installations, models, API requests, accounts, memory writes, schedules, mail or browser tasks were executed. Native-resolution source image converted to lossless WebP with complete decoded RGBA equality; no crop, retouch, upscaling or replacement of source labels.

Copyright (c) Promptfoo 2025

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
产品界面预览

Promptfoo: inspect pass rates and score distributions

Original documentation chart illustration for pass rate, score distribution and pairwise prompt scores. These figures explain viewer controls, not a measured benchmark or evidence that one named model is better. The complete source image is retained, with no invented underlying dataset.

Promptfoo: inspect pass rates and score distributions
查看完整图片
许可

Full original license retained. Author interface previews, usage recipes and illustrative/expected output remain distinct from independently reproduced results. No source instructions, scripts, installations, models, API requests, accounts, memory writes, schedules, mail or browser tasks were executed. Native-resolution source image converted to lossless WebP with complete decoded RGBA equality; no crop, retouch, upscaling or replacement of source labels.

Copyright (c) Promptfoo 2025

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
使用示例

Promptfoo: complete structured-output evaluation config

Complete author YAML for two math cases and alternative JSON response schemas. Keep only providers you can access, configure their keys and replace Azure host/deployment placeholders. Model names, API version and schema options are source configuration requiring current provider support; expected assertions are not passing test results. No evaluation was run.

示例输入

# yaml-language-server: $schema=https://promptfoo.dev/config-schema.json
description: Multi-provider structured JSON outputs with schema validation

prompts:
  # Schema output with `steps` array
  - label: 'With step-by-step'
    raw: 'You are a helpful math tutor. Solve {{problem}}'
    config:
      response_format:
        type: json_schema
        json_schema:
          name: math_response
          strict: true
          schema:
            type: object
            properties:
              steps:
                type: array
                items:
                  type: object
                  properties:
                    explanation:
                      type: string
                    output:
                      type: string
                  required:
                    - explanation
                    - output
                  additionalProperties: false
              final_answer:
                type: string
            required:
              - steps
              - final_answer
            additionalProperties: false

  # Schema output without `steps` array
  - label: 'Without step-by-step'
    raw: 'You are a helpful math tutor. Solve {{problem}}'
    config:
      response_format:
        type: json_schema
        json_schema:
          name: math_response
          strict: true
          schema:
            type: object
            properties:
              final_answer:
                type: string
            required:
              - final_answer
            additionalProperties: false

providers:
  # OpenAI with structured outputs (response_format)
  - openai:chat:gpt-4o-mini

  # Azure OpenAI with structured outputs (response_format)
  - id: azure:chat:gpt-4o-2024-08-06
    config:
      apiHost: 'YOUR_ORG.openai.azure.com'
      apiVersion: '2024-08-01-preview'
      deploymentName: 'YOUR_DEPLOYMENT_NAME'

  # Anthropic with structured outputs (output_format) - with steps
  - id: anthropic:messages:claude-sonnet-5
    label: 'Anthropic (with steps)'
    config:
      max_tokens: 2048
      output_format:
        type: json_schema
        schema:
          type: object
          properties:
            steps:
              type: array
              items:
                type: object
                properties:
                  explanation:
                    type: string
                  output:
                    type: string
                required:
                  - explanation
                  - output
                additionalProperties: false
            final_answer:
              type: string
          required:
            - steps
            - final_answer
          additionalProperties: false

  # Anthropic with structured outputs (output_format) - without steps
  - id: anthropic:messages:claude-sonnet-5
    label: 'Anthropic (without steps)'
    config:
      max_tokens: 2048
      output_format:
        type: json_schema
        schema:
          type: object
          properties:
            final_answer:
              type: string
          required:
            - final_answer
          additionalProperties: false

defaultTest:
  assert:
    - type: is-json
    - type: javascript
      value: typeof output === 'object'

tests:
  - description: Solving for the number of dragons in a cave
    vars:
      problem: 'If a wizard has 8x dragons and finds 31 more in a cave, but only has room for 2 total, how many dragons must the wizard release? (8x + 31 = 2)'
    assert:
      - type: contains-any
        value:
          - -3.625
          - -29/8
          - '-3.625'
          - '-29/8'
  - description: Calculating the area of a perfectly square pizza
    vars:
      problem: 'A perfectly square pizza has a side length of sqrt(x) meters. If the side length is 4.9 meters, what is the area in square meters? (sqrt(x) = 4.9)'
    assert:
      - type: contains-any
        value:
          - 24.01
          - '24.01'
许可

Full original license retained. Author interface previews, usage recipes and illustrative/expected output remain distinct from independently reproduced results. No source instructions, scripts, installations, models, API requests, accounts, memory writes, schedules, mail or browser tasks were executed. Complete source files/blocks retained. Only outer fences or documented indentation removed; multi-file recipes use editorial path labels and fences, with each separate binding in the review. Source versions/model aliases, template syntax and placeholders are unchanged.

Copyright (c) Promptfoo 2025

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
使用示例

Promptfoo: evaluate separate multi-turn conversation threads

Complete paired YAML and prompt.json Nunjucks template. Save both files together, configure provider access and run in the matching Promptfoo setup. The .json file intentionally contains template loops, not standalone JSON. Conversation IDs separate the example threads; no model answers, factual accuracy or current provider compatibility were verified here.

示例输入

examples/config-multi-turn/promptfooconfig.yaml

```yaml
# yaml-language-server: $schema=https://promptfoo.dev/config-schema.json
description: Multi-turn conversation evaluation and testing

prompts:
  - id: file://prompt.json
    label: multi-turn-conversation
providers:
  - openai:gpt-4.1-mini

# Set up the system message for all tests
defaultTest:
  vars:
    system_message: You are a helpful assistant

# Test out conversations with multiple turns
tests:
  # First conversation about Facebook
  - vars:
      question: Who founded Facebook?
    metadata:
      conversationId: facebook_thread
  - vars:
      question: Where does he live?
    metadata:
      conversationId: facebook_thread
  - vars:
      question: Which state is that in?
    metadata:
      conversationId: facebook_thread

  # Second conversation about weather (runs independently)
  - vars:
      question: What's the weather like in San Francisco?
    metadata:
      conversationId: weather_thread
  - vars:
      question: Do I need an umbrella today?
    metadata:
      conversationId: weather_thread

  # Third conversation about food (runs independently)
  - vars:
      question: Whats a good recipe for pasta?
    metadata:
      conversationId: food_thread
  - vars:
      question: How long should I cook it?
    metadata:
      conversationId: food_thread

```

examples/config-multi-turn/prompt.json

```text
[
  {
    "role": "system",
    "content": "{{ system_message }}"
  },
  {% for completion in _conversation %}
    {
      "role": "user",
      "content": "{{ completion.prompt[completion.prompt.length - 1].content }}"
    },
    {
      "role": "assistant",
      "content": "{{ completion.output }}"
    },
  {% endfor %}
  {
    "role": "user",
    "content": "{{ question }}"
  }
]

```
许可

Full original license retained. Author interface previews, usage recipes and illustrative/expected output remain distinct from independently reproduced results. No source instructions, scripts, installations, models, API requests, accounts, memory writes, schedules, mail or browser tasks were executed. Complete source files/blocks retained. Only outer fences or documented indentation removed; multi-file recipes use editorial path labels and fences, with each separate binding in the review. Source versions/model aliases, template syntax and placeholders are unchanged.

Copyright (c) Promptfoo 2025

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
主要功能

Promptfoo 能做什么

  1. 01Compare prompts and model outputs
  2. 02Define repeatable evaluation cases
  3. 03Run red-team checks and CI workflows
来源语言 · EN
差异特点

它有什么不同

It organizes test cases and checks; meaningful results depend on the chosen datasets, assertions and providers. Evaluations using external APIs can send data to those providers.

来源语言 · EN
适合人群

谁值得考虑

  • Developers evaluating AI applications
  • Teams maintaining repeatable model checks
来源语言 · EN
选择之前

需要核对的事项

  • 用一个真实任务试用,并对照自己的要求检查结果。
  • 核实服务会保存、共享或用于训练哪些数据。
  • 在官网确认当前价格、使用限额和取消条款。
相关用途

可探索的任务

官网核验日期

官网链接核查于 2026年10月21日;功能声明尚未经过独立测试。

按任务相关推荐

产品价格使用方式相关用途
Promptfoo未核实暂未提供生成可用于生产的代码 · 自动化工作流
Arize Phoenix未核实API生成可用于生产的代码 · 自动化工作流
Opik未核实暂未提供生成可用于生产的代码 · 自动化工作流
Archon未核实Web生成可用于生产的代码 · 自动化工作流
Claude Code付费Web, Windows, macOS, Linux, iOS, Android, API生成可用于生产的代码 · 自动化工作流