Skip to content

opencode

Route opencode’s built-in openai provider through the proxy: set its base URL to the proxy’s openai path and add your Milgram API key as a header. Your OpenAI API key stays opencode’s credential and is forwarded to OpenAI.

Merge the provider.openai entry into ~/.config/opencode/opencode.json. It applies to every project.

~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openai": {
"options": {
"baseURL": "https://api.milgram.dev/v1/proxy/openai/v1",
"apiKey": "{env:OPENAI_API_KEY}",
"headers": {
"X-Milgram-API-Key": "mlg_YOUR_KEY"
}
}
}
}
}

Start opencode, pick an OpenAI model and send a prompt. The session appears in the console under Sessions.