mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 16:04:01 +00:00
OpenCode Zen publishes System One models (jev-1.13, jev-1.13-free) on a /v1/systemone endpoint. A request pairs a free-form state with typed questions and the reply carries typed answers, so the payload shares no shape with the chat/responses bridge and cannot be translated. - protocol: add SystemOne with its endpoint path. - discovery: read "systemone" rows from the upstream endpoint tables so those models stop being bucketed as unsupported. - gateway: add POST /v1/systemone, which relays the body verbatim through the existing tier and anonymous machinery and returns the answer document unchanged. Models on another protocol are rejected with a clear error instead of being forwarded to a message API. - anonymous lane: keep System One bodies verbatim. Forcing streaming or injecting the core agent tools, which the free tier requires for chat traffic, would invalidate a decision request. Verified end-to-end against the live upstream: jev-1.13-free answers through the gateway with cost 0, chat and responses models keep working, and the endpoint rejects mismatched payloads.
34 lines
908 B
Go
34 lines
908 B
Go
// Package protocol translates Chat, Responses, and Anthropic payloads and
|
|
// streams, and carries the opaque System One decision payloads.
|
|
package protocol
|
|
|
|
type Protocol string
|
|
|
|
const (
|
|
Chat Protocol = "chat"
|
|
Responses Protocol = "responses"
|
|
Anthropic Protocol = "anthropic"
|
|
// SystemOne is OpenCode Zen's structured decision endpoint. A request pairs
|
|
// a free-form state with typed questions and the reply carries typed
|
|
// answers, so the payload shares no shape with the chat/responses bridge and
|
|
// is forwarded as-is.
|
|
SystemOne Protocol = "systemone"
|
|
)
|
|
|
|
func Valid(p Protocol) bool {
|
|
return p == Chat || p == Responses || p == Anthropic || p == SystemOne
|
|
}
|
|
|
|
func Path(protocol Protocol) string {
|
|
switch protocol {
|
|
case Responses:
|
|
return "/v1/responses"
|
|
case Anthropic:
|
|
return "/v1/messages"
|
|
case SystemOne:
|
|
return "/v1/systemone"
|
|
default:
|
|
return "/v1/chat/completions"
|
|
}
|
|
}
|