first commit

This commit is contained in:
Beyhan Ogur
2026-05-11 15:08:50 +03:00
commit a408821410
47 changed files with 4670 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
# Anthropic Flow
**Özet:** Anthropic Messages API formatındaki isteklerin gateway üzerinden Bifrost dönüşümüyle OpenAI formatına çevrilip upstream'e iletilmesi ve yanıtın geri Anthropic formatına dönüştürülmesi.
**Kütüphaneler:** Fiber v3, Go `net/http`, `encoding/json`
**Bağlantılar:** [[AnthropicHandler]], [[BifrostTransform]], [[ProxyEngine]], [[RequestLog]], [[Index]]
## Akış Diyagramı
```mermaid
sequenceDiagram
participant Client
participant Gateway
participant Bifrost as BifrostTransform
participant Proxy
participant Upstream
participant DB
Client->>Gateway: POST /anthropic/v1/messages
Note over Gateway: AnthropicHandler
Gateway->>Gateway: x-api-key → Authorization: Bearer
Gateway->>Gateway: API key auto-inject (gerekirse)
Gateway->>Bifrost: AnthropicToBifrost()
Bifrost-->>Gateway: OpenAI Chat Completions format
Gateway->>Proxy: Forward() to /v1/chat/completions
Proxy->>Upstream: POST <BACKEND>/v1/chat/completions
Upstream-->>Proxy: 200 OK + OpenAI format response
Proxy-->>Gateway: ForwardResult
Gateway->>Bifrost: BifrostToAnthropic()
Bifrost-->>Gateway: Anthropic Messages format
Gateway->>DB: go db.Create(logEntry)
Gateway-->>Client: 200 OK (Anthropic format)
```
## Edge Case'ler
| Senaryo | Davranış |
|---|---|
| **HEAD isteği** | 404 (DeepSeek uyumluluğu) |
| **Empty body** | Varsayılan "optoant gateway ready" yanıtı |
| **Geçersiz Anthropic formatı** | Raw passthrough + uyarı log'u |
| **Yanıt dönüşüm hatası** | Raw yanıtı forward et (passthrough) |
| **GET /v1/models** | DeepSeek model listesi (Anthropic formatında) |
| **Boş path /anthropic** | HTML info sayfası (`infoPage()`) |
| **Upstream hatası** | 502 Bad Gateway |