(log *zap.Logger, mode, privacyMode string, c cache, m KeyManager, rm routeManager, a authenticator, psm ProviderSettingsManager, cpm CustomProvidersManager, ks keyStorage, e estimator, ae anthropicEstimator, aoe azureEstimator, v validator, r recorder, pub publisher, rlm rateLimitManager, timeout time.Duration, ac accessCache, uac userAccessCache, pm PoliciesManager, scanner Scanner, cd CustomPolicyDetector, die deepinfraEstimator, um userManager, removeAgentHeaders bool)
| 80 | } |
| 81 | |
| 82 | func NewProxyServer(log *zap.Logger, mode, privacyMode string, c cache, m KeyManager, rm routeManager, a authenticator, psm ProviderSettingsManager, cpm CustomProvidersManager, ks keyStorage, e estimator, ae anthropicEstimator, aoe azureEstimator, v validator, r recorder, pub publisher, rlm rateLimitManager, timeout time.Duration, ac accessCache, uac userAccessCache, pm PoliciesManager, scanner Scanner, cd CustomPolicyDetector, die deepinfraEstimator, um userManager, removeAgentHeaders bool) (*ProxyServer, error) { |
| 83 | router := gin.New() |
| 84 | prod := mode == "production" |
| 85 | private := privacyMode == "strict" |
| 86 | |
| 87 | router.Use(CorsMiddleware()) |
| 88 | router.Use(getTimeoutMiddleware(timeout)) |
| 89 | router.Use(getMiddleware(cpm, rm, pm, a, prod, private, log, pub, "proxy", ac, uac, http.Client{}, scanner, cd, um, removeAgentHeaders)) |
| 90 | |
| 91 | client := http.Client{} |
| 92 | |
| 93 | // health check |
| 94 | router.POST("/api/health", getGetHealthCheckHandler()) |
| 95 | |
| 96 | // health check |
| 97 | router.GET("/api/health", getGetHealthCheckHandler()) |
| 98 | |
| 99 | // audios |
| 100 | router.POST("/api/providers/openai/v1/audio/speech", getSpeechHandler(prod, client)) |
| 101 | router.POST("/api/providers/openai/v1/audio/transcriptions", getTranscriptionsHandler(prod, client, e)) |
| 102 | router.POST("/api/providers/openai/v1/audio/translations", getTranslationsHandler(prod, client, e)) |
| 103 | |
| 104 | // completions |
| 105 | router.POST("/api/providers/openai/v1/chat/completions", getChatCompletionHandler(prod, private, client, e)) |
| 106 | |
| 107 | // embeddings |
| 108 | router.POST("/api/providers/openai/v1/embeddings", getEmbeddingHandler(prod, private, client, e)) |
| 109 | |
| 110 | // moderations |
| 111 | router.POST("/api/providers/openai/v1/moderations", getPassThroughHandler(prod, private, client)) |
| 112 | |
| 113 | // models |
| 114 | router.GET("/api/providers/openai/v1/models", getPassThroughHandler(prod, private, client)) |
| 115 | router.GET("/api/providers/openai/v1/models/:model", getPassThroughHandler(prod, private, client)) |
| 116 | router.DELETE("/api/providers/openai/v1/models/:model", getPassThroughHandler(prod, private, client)) |
| 117 | |
| 118 | // assistants |
| 119 | router.POST("/api/providers/openai/v1/assistants", getPassThroughHandler(prod, private, client)) |
| 120 | router.GET("/api/providers/openai/v1/assistants/:assistant_id", getPassThroughHandler(prod, private, client)) |
| 121 | router.POST("/api/providers/openai/v1/assistants/:assistant_id", getPassThroughHandler(prod, private, client)) |
| 122 | router.DELETE("/api/providers/openai/v1/assistants/:assistant_id", getPassThroughHandler(prod, private, client)) |
| 123 | router.GET("/api/providers/openai/v1/assistants", getPassThroughHandler(prod, private, client)) |
| 124 | |
| 125 | // assistant files |
| 126 | router.POST("/api/providers/openai/v1/assistants/:assistant_id/files", getPassThroughHandler(prod, private, client)) |
| 127 | router.GET("/api/providers/openai/v1/assistants/:assistant_id/files/:file_id", getPassThroughHandler(prod, private, client)) |
| 128 | router.DELETE("/api/providers/openai/v1/assistants/:assistant_id/files/:file_id", getPassThroughHandler(prod, private, client)) |
| 129 | router.GET("/api/providers/openai/v1/assistants/:assistant_id/files", getPassThroughHandler(prod, private, client)) |
| 130 | |
| 131 | // threads |
| 132 | router.POST("/api/providers/openai/v1/threads", getPassThroughHandler(prod, private, client)) |
| 133 | router.GET("/api/providers/openai/v1/threads/:thread_id", getPassThroughHandler(prod, private, client)) |
| 134 | router.POST("/api/providers/openai/v1/threads/:thread_id", getPassThroughHandler(prod, private, client)) |
| 135 | router.DELETE("/api/providers/openai/v1/threads/:thread_id", getPassThroughHandler(prod, private, client)) |
| 136 | |
| 137 | // messages |
| 138 | router.POST("/api/providers/openai/v1/threads/:thread_id/messages", getPassThroughHandler(prod, private, client)) |
| 139 | router.GET("/api/providers/openai/v1/threads/:thread_id/messages/:message_id", getPassThroughHandler(prod, private, client)) |
no test coverage detected