AI Connections
AI Connections let you run evaluations directly on the platform by connecting to your AI app via an HTTPS endpoint. Instead of writing code, you can trigger evaluations with a click of a button—Confident AI will call your endpoint with data from your goldens and parse the response.
Setting Up an AI Connection
To create an AI connection:
- Navigate to Project Settings → AI Connections
- Click New AI Connection
- Give it a unique identifying name
- Click Save
Your AI connection won’t be usable yet—you still need to configure the endpoint, payload, and at minimum the actual output key path.
Configuring Your Endpoint
Point your AI connection at your AI app’s HTTPS endpoint. It must accept POST requests and return a response containing the actual output of your AI app.
Choose a response mode based on how your endpoint responds:
- HTTP Response: returns a single response containing the actual output (default).
- HTTP Streaming: returns a stream of newline-delimited chunks.
- SSE Streaming: returns a stream of Server-Sent Events.
For streaming endpoints, see Streaming to configure chunk formats, SSE event names, and accumulate mode.
Payload
The payload is the request body Confident AI sends to your endpoint when it calls it. JSON mode lets you map available variables into a JSON structure, while the Code editor lets you write a Python function for conditional logic, data transformation, or full programmatic control over the request body.
JSON
Code
JSON mode lets you define a payload using available variables. You can nest values to match your endpoint’s expected structure.
Available variables:
Use golden.* variables for single-turn evaluations and conversationalGolden.* variables for multi-turn evaluations. See Prompts for details on how to use the prompts dictionary, and Hyperparameters for passing hyperparameters to your endpoint.
Example payload:
The custom payload feature lets you structure the request to match your existing API contract—no need to modify your AI app to accept a specific format.
Output Parsing
Once your endpoint returns a response, Confident AI needs to know how to pull the relevant values out of it. Use key paths to point at specific values in your JSON response, or a transformer when you need custom logic to extract them:
- Actual Output Key Path: where to find the actual output (required)
- Retrieval Context Key Path: where to find the retrieval context (optional, for RAG metrics)
- Tool Call Key Path: where to find the tools called (optional, for tool-related metrics)
Actual Output Key Path
A list of strings or integers representing the path to the actual_output value in your JSON response. Use strings for JSON keys and integers for array indices. This is required for evaluation to work.
For example, if your endpoint returns:
Set the key path to ["response", "output"].
For nested arrays, use integers to specify the array index. For example, if your endpoint returns:
Set the key path to ["response", "output", "content", 0, "text"].
Retrieval Context Key Path
A list of strings or integers representing the path to the retrieval_context value in your JSON response. Use strings for JSON keys and integers for array indices. This is optional and only needed if you’re using RAG metrics. The value must be a list of strings.
For example, if your endpoint returns:
Set the key path to ["response", "retrieval_context"].
Tool Call Key Path
A list of strings or integers representing the path to the tools_called value in your JSON response. Use strings for JSON keys and integers for array indices. This is optional and only needed if you’re using metrics that require a tool call parameter. The value must be a list of ToolCall.
For example, if your endpoint returns:
Set the key path to ["response", "tools_called"].
For more information on the structure of a tool call, refer to the official DeepEval documentation.
Transformers
When a key path isn’t enough—for example, your endpoint returns a non-standard format that needs custom logic—use a transformer to extract the actual output with your own Python code.
Switch any parser from JSON Key Path to Transformer to select a transformer instead of a key path:
Add your own transformers by navigating to Project Settings → Transformers and clicking Create Transformer. See Transformers for details.
Headers
Add any custom headers your endpoint requires as key-value pairs—such as API keys, bearer tokens, or a Content-Type. Whatever you add here is sent with every request Confident AI makes to your AI app.
Common headers you might set:
Authorization— a static API key or bearer token (e.g.Bearer sk-...)Content-Type— the format of the request body (e.g.application/json)- A custom header your endpoint expects (e.g.
X-API-Key)
For authentication that needs a secrets manager or signed requests, use Authorization instead of hardcoding credentials into headers.
Testing Your Connection
Click Ping Endpoint to verify everything is set up correctly. You should receive a 200 status response—if not, check the error message and adjust your configuration accordingly.
✅ Done. Your AI connection is ready to run evaluations.
Next Steps
Now that your AI connection is set up, dive into the pieces that make it production-ready:
Attach prompt versions and hyperparameters, logged with every test run.
Stream output over HTTP Streaming or SSE, with event names and accumulate mode.
Secure requests with a secrets manager and Auth0 or HMAC authentication.
Tune request concurrency, timeouts, and retries for endpoint requests.
Sample your app multiple times per golden for statistically rigorous test runs.
Persist information across turns during multi-turn simulations.
Link test cases and turns to their traces for full observability.
Reach internal endpoints behind firewalls without opening inbound ports.