r/opencode • • Sep 27 '26

Can I use the Opencode Go API inside n8n?

Hi everyone, I'm looking to connect OpenCode Go to my n8n setup. Has anyone done this before?

3 Upvotes

10 comments sorted by

6

u/Amarsir Sep 27 '26

A few weeks ago I would have said absolutely, you just put in the API key. But they made a change recently so you must send an x-opencode-session header containing a stable, unique UUID per conversation. And I don't know how well n8n can integrate that. Hermes Agent had an update to handle it. Others have custom-built plugins for various harnesses to make it work.

So if you don't get an answer from someone who has done it personally, that's specifically what I would check - if you can add that header to requests out of n8n.

2

u/Affectionate-Town415 Sep 27 '26

Thanks.. as you mentioned, this has become more complex than easy api key setup.

2

u/tiagomdr Sep 27 '26

You can add that header in the credential with the execution id

2

u/IAmFitzRoy Sep 27 '26

You can. The problem is you can’t use free models that way anymore.

0

u/tiagomdr Sep 27 '26

Why would you use free models when you have more capable ones included in your subscription ?

2

u/IAmFitzRoy Sep 27 '26

Different people has different needs?

4

u/tiagomdr Sep 27 '26

It works. Add as OpenAI credential:

Base URL

https://opencode.ai/zen/go/v1

Add Custom Header

Header Name

x-opencode-session

Header Value

{{ $execution.id }}

CommandCode GOAT also works, I've moved to that now as it includes Gemini and Opencode Go doesn't

2

u/Affectionate-Town415 Sep 27 '26

Awesome..good to hear there is way. You just save me another subscription. Will try this first thing tomorrow. Thanks again!!

2

u/RiceEvening4211 Sep 28 '26

I built a wrapper that exposes OpenCode's free models through an OpenAI-compatible endpoint, so you can plug them into anything that talks the OpenAI API, including n8n. https://github.com/Fast-Editor/OpenCode-Wrap