You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.0 KiB
37 lines
1.0 KiB
package router
|
|
|
|
import (
|
|
"api2gpt-mid/controller"
|
|
"api2gpt-mid/middleware"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func SetApiRouter(router *gin.Engine) {
|
|
modelsRouter := router.Group("/v1/models")
|
|
modelsRouter.Use(middleware.TokenAuth())
|
|
{
|
|
modelsRouter.GET("", controller.ListModels)
|
|
modelsRouter.GET("/:model", controller.RetrieveModel)
|
|
}
|
|
relayV1Router := router.Group("/v1")
|
|
relayV1Router.Use(middleware.TokenAuth())
|
|
{
|
|
relayV1Router.POST("/completions", controller.Completions)
|
|
relayV1Router.POST("/chat/completions", controller.Completions)
|
|
relayV1Router.POST("/embeddings", controller.Embeddings)
|
|
relayV1Router.POST("/edits", controller.Edit)
|
|
relayV1Router.POST("/images/generations", controller.Images)
|
|
}
|
|
dashboardRouter := router.Group("/dashboard")
|
|
dashboardRouter.Use(middleware.TokenAuth())
|
|
{
|
|
dashboardRouter.GET("/dashboard/billing/credit_grants", controller.Balance)
|
|
}
|
|
router.OPTIONS("/v1/*path", controller.HandleOptions)
|
|
router.GET("/ping", func(c *gin.Context) {
|
|
c.JSON(200, gin.H{
|
|
"message": "pong from api2gpt",
|
|
})
|
|
})
|
|
}
|