HttpTarget provides a flexible way to connect to any LLM API accessible through HTTP.
This is currently the only model type that can be fully utilized through the TrustTest web UI.
Overview
TheHttpTarget class allows you to:
- Connect to any REST API endpoint
- Configure custom headers, payloads, and authentication
- Handle multi-turn conversations
- Process various response formats (JSON, plain text)
- Implement error handling and retry mechanisms
Basic Usage
Here’s a simple example of how to configure an HttpTarget:Configuration Options
HttpTarget is configured from a small set of top-level fields plus nested config objects for the payload, auth, errors, and retries.
Top-Level Fields
url(required): The HTTP endpoint that receives the prompt.payload_config(required): Describes the request body and transport behavior.headers(optional): Static headers sent with every request.token_config(optional): Fetches a bearer token before the request.error_config(optional): Maps a specific error response into a normal model response.response_regex(optional): Applies a regex to the extracted response text.concatenate_field(optional): Extracts a nested field from JSON, JSON Lines, or SSE responses using dot notation such aschoices.0.message.content.retry_config(optional): Enables retries with exponential backoff.
PayloadConfig
PayloadConfig controls both the request body and how the HTTP request is sent:
format(required): JSON body template. TrustTest recursively replaces placeholders inside nested dicts and lists.message_regex: Placeholder replaced with the prompt text. Default:{{ test }}.date_regex: Placeholder replaced with the current date inYYYY-MM-DDformat. Default:{{ date }}.random_id_placeholder: Placeholder replaced with a UUID in both the payload and headers. Default:{{ random_id }}.params: Query string parameters added to the request URL.timeout: Request timeout in seconds. Default:10.rate_limit: Minimum seconds between requests. For example,0.1means 10 requests per second and2.0means one request every 2 seconds.proxy: Optional HTTP proxy URL.ssl_verify: Whether TLS certificates should be verified. Default:True.mtls: Enables mutual TLS using the certificates pointed to byMTLS_CERT_PATHandMTLS_KEY_PATH. Default:False.
Response Handling
Useconcatenate_field when the API returns structured data and you want TrustTest to extract a specific nested value:
response_regex if you still need to trim or normalize the extracted text.
TokenConfig
Use token_config when the target requires a token request before the main call:
url: Token endpoint URL.payload: Body sent to the token endpoint.headers: Headers for the token request.timeout: Token request timeout.secret: Optional shared secret for HMAC-signed token flows. When set, TrustTest signs the auth payload and reuses any returned cookies across the conversation.
ErrorHandelingConfig
Use error_config when an API returns useful text inside a known error response and you want to treat it like a model answer instead of raising:
status_code: HTTP status code to intercept.concatenate_field: Field extracted from that error body. Default:errors.0.message.
RetryConfig
Set up automatic retries for transient failures:
max_retries: Number of retries after the initial failed request.base_delay: Starting delay in seconds.max_delay: Maximum delay between attempts.exponential_base: Backoff multiplier applied after each failed attempt.
Example Implementation
This example shows how to create an HttpTarget for a chat API endpoint:Configure Web UI
In the TrustTest web UI, the Target field accepts the sameHttpTarget config in YAML form. The config is parsed with HttpTarget.from_dict, so the field names below should match your Python config one-to-one.
Standard HTTP Target
Azure OIDC in Web UI
If your target uses Azure OIDC, setpayload_config.auth_type: azure_oidc and provide the Azure credentials inside payload_config.azure_oidc_config. The backend loader converts that UI shape into an AzureOIDCTarget.
auth_flow to password or ropc and add username plus password inside azure_oidc_config.