You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Add logging of LLM HTTP Requests (v2) #56066
Thanks for the request! You'd like OpenCode v2 to log outbound LLM HTTP requests (URL, headers and optionally payloads) so failed provider calls are easier to debug. The maintainers will consider it.
In the meantime, you can do this yourself with a plugin. The v2 plugin API has http.request and http.response session hooks that see every HTTP request sent to a model provider. Here is a small plugin that appends each request and response as one JSON line to a file. It hides auth headers, logs request bodies, and logs response bodies only for error responses, because successful responses are streams and are left alone. I've checked that it type-checks against the plugin API, but I haven't run it inside OpenCode yet.
Save it as .opencode/plugins/llm-http-log/index.ts in your project (plugins there are loaded automatically), or put it anywhere and add its path to plugins in opencode.json:
import{appendFile,mkdir}from"node:fs/promises"import{homedir}from"node:os"import{dirname,join}from"node:path"import{Plugin}from"@opencode/plugin"constSECRET=/^(authorization|x-api-key|api-key|x-goog-api-key|cookie|proxy-authorization)$/ifunctionheaders(input: Headers){constout: Record<string,string>={}input.forEach((value,key)=>{out[key]=SECRET.test(key) ? "[redacted]" : value})returnout}exportdefaultPlugin.define({id: "llm-http-log",asyncsetup(ctx){constfile=typeofctx.options.file==="string" ? ctx.options.file : join(homedir(),".local/share/opencode/llm-http.jsonl")constbodies=ctx.options.bodies!==falseawaitmkdir(dirname(file),{recursive: true})constwrite=(entry: Record<string,unknown>)=>appendFile(file,JSON.stringify({time: newDate().toISOString(), ...entry})+"\n").catch(()=>{})awaitctx.session.hook("http.request",async(event)=>{constreq=event.requestawaitwrite({type: "request",sessionID: event.sessionID,kind: event.kind,model: event.model,method: req.method,url: req.url,headers: headers(req.headers),body: bodies&&req.body ? awaitreq.clone().text() : undefined,})})awaitctx.session.hook("http.response",async(event)=>{constres=event.responseawaitwrite({type: "response",sessionID: event.sessionID,kind: event.kind,model: event.model,url: event.request.url,status: res.status,headers: headers(res.headers),// Only error bodies are read; successful bodies are streams and are left untouched.body: !res.ok ? awaitres.clone().text() : undefined,})})},})
The options are optional. Use them to change the log file or turn off request bodies:
Then run tail -f ~/.local/share/opencode/llm-http.jsonl while you reproduce the failing request. Request bodies can contain your prompts and file contents, so check the log before sharing it. Providers that use WebSocket transport won't show up here, because these hooks only cover HTTP.
Thanks for the suggestion. We're tracking built-in LLM request and response logging for debugging in #29186, so I'm closing this as a duplicate. Please follow that issue for updates.
Activity
opencode-agent commentedon Oct 16, 2026
Thanks for the request! You'd like OpenCode v2 to log outbound LLM HTTP requests (URL, headers and optionally payloads) so failed provider calls are easier to debug. The maintainers will consider it.
Related issues:
traceparenton outbound LLM requestsIn the meantime, you can do this yourself with a plugin. The v2 plugin API has
http.requestandhttp.responsesession hooks that see every HTTP request sent to a model provider. Here is a small plugin that appends each request and response as one JSON line to a file. It hides auth headers, logs request bodies, and logs response bodies only for error responses, because successful responses are streams and are left alone. I've checked that it type-checks against the plugin API, but I haven't run it inside OpenCode yet.Save it as
.opencode/plugins/llm-http-log/index.tsin your project (plugins there are loaded automatically), or put it anywhere and add its path topluginsinopencode.json:The options are optional. Use them to change the log file or turn off request bodies:
{ "plugins": [ { "package": "./.opencode/plugins/llm-http-log", "options": { "file": "/tmp/llm-http.jsonl", "bodies": false } } ] }Then run
tail -f ~/.local/share/opencode/llm-http.jsonlwhile you reproduce the failing request. Request bodies can contain your prompts and file contents, so check the log before sharing it. Providers that use WebSocket transport won't show up here, because these hooks only cover HTTP.neriousy commentedon Oct 20, 2026
Thanks for the suggestion. We're tracking built-in LLM request and response logging for debugging in #29186, so I'm closing this as a duplicate. Please follow that issue for updates.
mschfh commentedon Nov 2, 2026
@neriousy The linked issue was closed as stale by you. Will there be further updates? Is this available in v2?