Session affinity
Pin a conversation for prompt caching.
Send a stable session identifier to keep requests from the same conversation on the same provider. This preserves provider-side prompt caching, which lowers cost and latency.
How
Set the x-opencode-session header:
x-opencode-session: my-session-id
Or pass session_id / sessionId in the JSON body. If neither is present the gateway derives one from the first two messages.
The pin is best-effort: if the pinned provider is unhealthy or rate-limited the router fails over to another provider rather than failing the request.