AI SDK Telemetry Saw Your API Keys in Request URLs
On November 7, 2026 a fix landed in the Vercel AI SDK with a title that reads like plumbing and behaves like a security advisory: sanitize request URLs before telemetry observes provider results. It shipped in ai 7.0.165. If you run the AI SDK with tracing enabled, and your model endpoint carries a credential anywhere in its path or query string, your traces have been carrying it too.
The problem: a sanitizer that ran one step too late
The SDK already treated a provider request URL as something not to hand around freely. It reduced that URL down to its origin before returning it to the caller. The catch is when: that reduction happened only after executeLanguageModelCall had returned.
Telemetry does not wait for a return value. The SDK publishes to a Node diagnostics tracing channel named ai:telemetry, and subscribers attach to phases including start and asyncEnd, for message types such as generateText, streamText, step, and languageModelCall. Every asyncEnd subscriber — the SDK's own telemetry integrations, an OpenTelemetry exporter, a homegrown logger — observed result.request.url while it was still the full URL.
The regression test added with the fix makes the shape concrete. Point a provider at a base URL shaped like https://host/endpoint-credential/v1?api_key=query-credential, and before the fix the value telemetry received was the whole thing: path segment, query parameter, credential and all.
What changed
The fix moves sanitization inside the provider execution callbacks for generateText and the streaming path, so request metadata is reduced to its origin before any telemetry wrapper sees it. It is a patch release in the strict sense: no provider interfaces, no dependencies, and no public APIs changed. Upgrade, and the behavior is simply correct.
Worth seeing where the value was visible, because this is also how you audit your own subscribers:
import diagnostics_channel from 'node:diagnostics_channel';
const channel = diagnostics_channel.tracingChannel('ai:telemetry');
channel.subscribe({
asyncEnd(message) {
// Before 7.0.165 this could be the full URL, credential included.
// From 7.0.165 on, it is reduced to the origin.
console.log(message.result?.request?.url);
},
});The real fix is upstream of the sanitizer
A sanitizer is a safety net. The design decision is to keep the secret out of the URL in the first place, so that no sink — traces, logs, error bodies, retry metadata — ever has a copy to lose.
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
// Avoid: the credential is part of the URL, so every observer inherits it.
const leaky = createOpenAICompatible({
name: 'gateway',
baseURL: 'https://gateway.internal/team-7/v1?api_key=' + process.env.KEY,
});
// Prefer: the URL is routing information, the header is the credential.
const safe = createOpenAICompatible({
name: 'gateway',
baseURL: 'https://gateway.internal/v1',
headers: { authorization: `Bearer ${process.env.GATEWAY_KEY}` },
});Real-world caveats
Upgrading fixes future spans, not past ones. Anything already exported to a tracing backend is still sitting there, readable by everyone with dashboard access. If a credential ever lived in a base URL, rotate it — do not reason about whether a span was sampled.
`recordInputs` and `recordOutputs` would not have saved you. Those switches govern prompt and completion content. Endpoint metadata is a different field, and it travelled regardless.
Telemetry is one sink among several. The same string can reach provider error bodies, retry metadata, and nested step records. The pattern is not closed: a follow-up pull request, #24712, proposes redacting Code Interpreter domain secrets from telemetry copies, and as of November 9, 2026 it is still open.
Self-hosted gateways are where this bites. A hosted provider takes its key in a header. An internal proxy, a per-team route, or a quick signed-query shortcut is where credentials drift into paths.
Takeaway
Treat the observability pipeline as a trust boundary, not as a passive mirror. A value is only as private as its least careful subscriber, and in an agentic stack those subscribers multiply: tracing exporters, evaluation harnesses, replay tooling. Keeping secrets in headers instead of URLs costs one line of configuration and removes the whole class of leak. Secret handling for agents is becoming its own discipline — the same instinct behind real auth for AI agents in MCP.
Primary source: vercel/ai pull request #24708.