@outputai/http package gives you an HTTP client that automatically shows up in your traces. Every request — URL, method, status code, timing — is recorded as a child node in the trace tree, so you can see exactly what API calls your steps made and how long they took.
Under the hood, it wraps ky, a lightweight HTTP client built on fetch.
Creating a Client
The typical pattern is to create a client per external service in your clients directory, then import it in your steps:clients/jina.ts
HTTP Methods
Using in Steps
Wrap HTTP calls in steps for automatic retry and tracing:steps.ts
Tracing
All requests made with@outputai/http are automatically traced — no configuration needed. In your trace files, HTTP calls appear as children of the step that made them:
Attaching Request Cost
When you know the dollar cost of an HTTP request (for example from provider billing headers), you can attach it to the HTTP trace event withaddRequestCost.
addRequestCost only works with responses created by @outputai/http (or its exported fetch). If the response did not come from this package, the function safely no-ops and logs a warning.
It also emits a cost:http:request hook event (same hooks system as cost:llm:request). For the payload and examples, see Cost Events — HTTP.
Error Handling
The client throwsHTTPError for non-2xx responses and TimeoutError for timeouts:
Environment Variables
| Variable | Description |
|---|---|
OUTPUT_TRACE_HTTP_VERBOSE | Set to true or 1 to include request/response headers and bodies in trace files (otherwise only method, URL, and status are recorded) |