Template Endpoint
The template endpoint provides a flexible way to benchmark custom APIs that don’t match standard OpenAI formats. You define request payloads using Jinja2 templates and optionally specify how to extract responses using JMESPath queries.
When to Use
Use the template endpoint when:
- Your API has a custom request/response format
- Standard endpoints (chat, completions, embeddings, rankings) don’t fit your use case
Basic Example
Benchmark an API that accepts text in a custom format:
Sample Output (Successful Run):
Configuration
Configure the template endpoint using --extra-inputs:
Required
payload_template: Jinja2 template defining the request payload format- Named template:
nv-embedqa - File path:
/path/to/template.json - Inline string:
'{"text": {{ text|tojson }}}'
- Named template:
Optional
response_field: JMESPath query to extract data from responses- Auto-detection is used if not provided
- Example:
data[0].embedding
Any other --extra-inputs fields are merged into every request payload:
Template Variables
Content Variables
text: First text content (orNone)texts: List of all text contentsimage,audio,video: First media content (orNone)images,audios,videos: Lists of all media contents
Named Content Variables
query: First query textqueries: All query textspassage: First passage textpassages: All passage textstexts_by_name: Dict mapping content names to text listsimages_by_name,audios_by_name,videos_by_name: Dicts for media
Request Metadata
model: Model namemax_tokens: Output token limitstream: Whether streaming is enabledrole: Message roleturn: Current turn objectturns: List of all turnsrequest_info: Full request context
Response Parsing
Auto-detection tries to extract in this order: embeddings, rankings, then text.
Text Responses
- Fields:
text,content,response,output,result - OpenAI:
choices[0].text,choices[0].message.content
Embedding Responses
- OpenAI:
data[].embedding - Simple:
embeddings,embedding
Ranking Responses
- Lists:
rankings,results
Custom Extraction
Specify a JMESPath query to extract specific fields:
Examples
Custom Embedding API
Named Template
Using the built-in nv-embedqa template:
Note: The nv-embedqa template expands to {"text": {{ texts|tojson }}}.
Template from File
Create chat_template.json:
Use it:
Multi-Modal Request
Tips
- Always use
|tojsonfor string/list values to properly escape JSON - Use
-vor-vvto see debug logs with formatted payloads - Check
artifacts/<run-name>/inputs.jsonto see all formatted request payloads - Let auto-detection work first before specifying
response_field
Troubleshooting
Template didn’t render valid JSON
- Use
|tojsonfilter for string or nullable values
Response not parsed correctly
- Use
-vvto see raw responses in logs - Specify
response_fieldwith a JMESPath query
Variables not available
- Verify your input dataset includes the required fields
- Use
request_infoandturnobjects for nested data