Prompt Chain

Integrate Truefoundry with Promptfoo for Code Testing

Promptfoo examples for TrueFoundry AI Gateway - multi-provider model comparison, MCP tool use, embeddings.

Works with truefoundry

76
Spark score
out of 100
Updated 3 days ago
Version 0.121.19
Models

Add to Favorites

Why it matters

Streamline your code generation and testing processes by integrating Truefoundry's AI Gateway with promptfoo. This asset helps automate the evaluation of AI-generated code against your specific requirements.

Outcomes

What it gets done

01

Configure promptfoo to connect with Truefoundry's LLM, MCP, and Agent Gateways.

02

Automate the testing and evaluation of AI-generated code.

03

Debug and refine code generation pipelines using promptfoo's capabilities.

04

Ensure code quality and adherence to standards through automated checks.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/pfoo-provider-truefoundry | bash

Steps

Steps in the chain

01
Obtain TrueFoundry API Key
02
Set Environment Variable
03
Initialize Example Project
04
Navigate to Project Directory
05
Run Basic Configuration Example
06
View Results
07
Run MCP Servers Example

Overview

Provider Truefoundry

Demonstrates Promptfoo configs for TrueFoundry's AI Gateway, covering multi-provider model comparison, MCP server tool integration, embedding models, and request logging for cost and performance tracking. Use when routing LLM, embedding, or MCP-agent calls through TrueFoundry's gateway rather than calling a provider directly.

What it does

A Promptfoo example collection for using TrueFoundry's AI Gateway (LLM, MCP, and Agent Gateway) as a unified provider. It covers two configurations: a basic one comparing GPT-4 via OpenAI and Claude 3.5 Sonnet via Anthropic with custom metadata and logging, and an advanced one exercising TrueFoundry's MCP (Model Context Protocol) server integration - web search, code execution tools, multi-step tool-use reasoning, and configurable iteration limits. Every model is addressed through a provider-account/model-name identifier format, where the provider-account is the name of that provider's integration inside TrueFoundry, such as openai-main or anthropic-main. It documents the specific models available through each backing provider: OpenAI (gpt-5, gpt-4o, gpt-4o-mini, o1, o1-mini), Anthropic (claude-sonnet-4.5, claude-3-5-sonnet-20241022, claude-3-opus-20240229), Google Gemini via Vertex AI (gemini-2.5-pro, gemini-2.5-flash, gemini-1.5-pro), and others like Groq's llama-3.3-70b-versatile and Mistral's mistral-large-latest. TrueFoundry also proxies embedding models, including OpenAI's text-embedding-3-large and Cohere's embed-english-v3.0, the latter requiring an explicit input_type of search_query, search_document, classification, or clustering. MCP server configuration lets you name an integration_fqn such as common-tools, selectively enable specific tools like web_search and code_executor rather than all available tools, and cap the agent's iteration_limit. When loggingConfig.enabled is set, every request is logged to the TrueFoundry dashboard for monitoring request and response logs, tracking performance metrics, analyzing cost, debugging, and filtering by the custom metadata attached to each config.

When to use - and when NOT to

Use when routing LLM, embedding, or MCP-agent calls through TrueFoundry's AI Gateway from Promptfoo - comparing models across providers behind one gateway, testing MCP tool-use workflows, or setting up centralized observability and cost tracking for LLM calls. Not the right example for calling a provider directly without TrueFoundry's gateway layer, since the model-ID format and config options here are specific to how TrueFoundry names and routes its provider integrations.

Inputs and outputs

Input is a TRUEFOUNDRY_API_KEY environment variable plus a chosen config, either the basic multi-model or the MCP-server example. Output, after running the eval, is per-model comparison results viewable via the Promptfoo UI, plus, when logging is enabled, full request and response logs, performance metrics, and cost data in the TrueFoundry dashboard.

providers:
  - id: truefoundry:openai-main/gpt-5
    config:
      temperature: 0.7
      max_completion_tokens: 500

Integrations

Built on TrueFoundry's AI Gateway via Promptfoo's TrueFoundry provider, fronting OpenAI, Anthropic, Google Vertex AI, Groq, Mistral, and Cohere models and embeddings, with MCP server tool integration and a TrueFoundry dashboard for observability.

Who it's for

Teams standardizing LLM access behind a gateway who want to evaluate multiple providers' models, MCP tool-use behavior, and embedding models through one consistent TrueFoundry configuration with built-in logging and cost tracking.

Source README

provider-truefoundry (TrueFoundry Examples)

This directory contains example configurations for using TrueFoundry's AI Gateway (LLM, MCP, and Agent Gateway) with promptfoo.

Prerequisites

  1. TrueFoundry API Key: Obtain your API key from the TrueFoundry Console

  2. Set Environment Variable:

    export TRUEFOUNDRY_API_KEY=your_api_key_here
    

Quick Start

To quickly set up this example:

npx promptfoo@latest init --example provider-truefoundry
cd provider-truefoundry

Examples

1. Basic Configuration (promptfooconfig.yaml)

A simple example demonstrating basic TrueFoundry usage with multiple models:

  • GPT-4 via OpenAI
  • Claude 3.5 Sonnet via Anthropic
  • Custom metadata and logging configuration

Run the example:

npx promptfoo eval -c promptfooconfig.yaml

View results:

npx promptfoo view

2. MCP Servers (promptfooconfig-mcp.yaml)

An advanced example showcasing TrueFoundry's MCP (Model Context Protocol) server integration:

  • Web search capabilities
  • Code execution tools
  • Multi-step reasoning with tool use
  • Custom iteration limits

Run the example:

npx promptfoo eval -c promptfooconfig-mcp.yaml

Configuration Options

Basic Options

providers:
  - id: truefoundry:openai-main/gpt-5
    config:
      temperature: 0.7
      max_completion_tokens: 500

Note: The model identifier format is provider-account/model-name. The provider-account is the name of your provider integration in TrueFoundry (e.g., openai-main, anthropic-main).

Metadata and Logging

config:
  metadata:
    user_id: 'your-user-id'
    environment: 'development'
    custom_key: 'custom_value'
  loggingConfig:
    enabled: true

MCP Servers

config:
  mcp_servers:
    - integration_fqn: 'common-tools'
      enable_all_tools: false
      tools:
        - name: 'web_search'
        - name: 'code_executor'
  iteration_limit: 20

Supported Models

TrueFoundry provides access to models from multiple providers. Use the format provider-account/model-name:

OpenAI

- truefoundry:openai-main/gpt-5
- truefoundry:openai-main/gpt-4o
- truefoundry:openai-main/gpt-4o-mini
- truefoundry:openai-main/o1
- truefoundry:openai-main/o1-mini

Anthropic

- truefoundry:anthropic-main/claude-sonnet-4.5
- truefoundry:anthropic-main/claude-3-5-sonnet-20241022
- truefoundry:anthropic-main/claude-3-opus-20240229

Google Gemini

- truefoundry:vertex-ai-main/gemini-2.5-pro
- truefoundry:vertex-ai-main/gemini-2.5-flash
- truefoundry:vertex-ai-main/gemini-1.5-pro

Other Providers

- truefoundry:groq-main/llama-3.3-70b-versatile
- truefoundry:mistral-main/mistral-large-latest

Embeddings

TrueFoundry also supports embedding models:

providers:
  - id: truefoundry:openai-main/text-embedding-3-large
    config:
      metadata:
        user_id: 'embedding-user'
      loggingConfig:
        enabled: true

Cohere Embeddings

When using Cohere models, specify the input_type:

providers:
  - id: truefoundry:cohere-main/embed-english-v3.0
    config:
      input_type: 'search_query' # Options: search_query, search_document, classification, clustering

Observability

When loggingConfig.enabled is set to true, all requests are logged in the TrueFoundry dashboard where you can:

  • Monitor request/response logs
  • Track performance metrics
  • Analyze costs
  • Debug issues
  • Filter by custom metadata

Resources

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.