How it works
When you configure a variable with an API source, the system performs the following at prompt execution time:- Resolve placeholders — Any
{{column_name}}placeholders in the API configuration (URL, headers, body) are replaced with values from the current dataset row. - Execute the request — The HTTP request is sent to the configured endpoint.
- Inject the response — The API response replaces the variable in your prompt before it is sent to the model.
Set up an API variable
Create a variable
Add a
{{variable_name}} placeholder in your prompt, or create an image/PDF variable. The variable appears in the Variable Editor.Select API as the source
In the Variable Editor, click on the variable and select API as the source type.
Configure the endpoint
Set up the HTTP request configuration:
- URL — The endpoint to call (e.g.,
https://api.example.com/v1/details/{{userId}}) - Method — Choose from GET, POST, PUT, PATCH, or DELETE
- Headers — Set request headers (use
secretHeadersfor sensitive keys and tokens) - Body — Configure the request body for POST/PUT/PATCH requests

Use placeholders like
{{columnName}} within the API configuration (URL, headers, query parameters, or body). When you have a linked dataset, these placeholders are automatically resolved from the corresponding dataset columns at runtime.Configuration reference
API variables support comprehensive HTTP request configuration:| Feature | Details |
|---|---|
| HTTP Methods | GET, POST, PUT, PATCH, DELETE |
| Placeholder Injection | URL, headers, query parameters, request body |
| Response Types | JSON, plain text, images, and PDFs |
| Security | Use secretHeaders to obfuscate sensitive API keys and tokens |
| Timeout | 30 seconds per request |
| Retries | 3 automatic retries with exponential backoff (starting at 1 second) |
Dataset integration
When API variables are used with a linked dataset, they function as dynamic columns:- Row-level execution — Each dataset row triggers its own unique API request. For example, if your dataset has a
userIdcolumn and your API URL ishttps://api.example.com/v1/details/{{userId}}, each row makes a separate call with that row’suserIdvalue. - Variable resolution — Placeholders in your API configuration are replaced with values from the corresponding dataset row.
- Result persistence — API responses are stored in the dataset cells and can be used for subsequent evaluations.
Execution behavior
- Independent API variables execute in parallel to reduce latency.
- Dependent API variables (those that rely on the result of another variable) execute sequentially.
- Failed requests are automatically retried up to 3 times with exponential backoff.
Error handling
| Error type | Cause | Result |
|---|---|---|
| Missing Column | API URL or body references a dataset column that doesn’t exist. | Execution fails before the run starts. |
| API Failure | The endpoint returns a 4xx/5xx error or times out. | The parent prompt fails and the error propagates. |
| Invalid URL | The URL is malformed after placeholder resolution. | The API request fails. |
Securing credentials with secretHeaders
When your API requires authentication, usesecretHeaders to keep sensitive tokens out of logs and shared configurations. Secret headers are obfuscated in the UI and are never exposed in prompt history or evaluation results.
Example API configuration with secret headers:
Best practices
- Secure your credentials — Always mark authorization tokens and API keys as
secretHeadersto prevent exposure in logs and shared prompt configurations. - Use descriptive variable names — Name variables like
{{user_purchase_history}}rather than{{var1}}for clarity. - Test endpoints independently — Verify that your API endpoints return the expected data before integrating them into your prompts.
- Handle response size — Keep API responses concise. Large payloads increase token usage and may exceed context limits.
- Use caching where possible — If your backend supports it, cache frequently requested data to reduce latency and costs.
Next steps
Use Other Prompts in Prompts
Chain prompts together for agent-like workflows.
Link Datasets
Connect datasets to test API variables across many inputs.