syntax = "v1"

type (
	AICompleteReq {
		Prompt string `json:"prompt"`
		Model  string `json:"model,optional"`
		Meter  string `json:"meter,optional"` // default ai_copy
	}

	AICompleteData {
		Text    string `json:"text"`
		KeyMode string `json:"key_mode"`
		Model   string `json:"model"`
	}

	SearchReq {
		Query string `json:"query"`
		Limit int    `json:"limit,optional"`
	}

	SearchHit {
		Title   string `json:"title"`
		Url     string `json:"url"`
		Snippet string `json:"snippet"`
	}

	SearchData {
		List    []SearchHit `json:"list"`
		KeyMode string      `json:"key_mode"`
	}
)

@server (
	jwt:        Auth
	group:      proxy
	prefix:     /api/v1/proxy
	middleware: AuthJWT
)
service gateway {
	@handler AIComplete
	post /ai/complete (AICompleteReq) returns (AICompleteData)

	@handler ExaSearch
	post /search (SearchReq) returns (SearchData)
}
