Files
opantoantro/docs/wiki/AnthropicHandler.md
T
Beyhan Ogur a408821410 first commit
2026-05-11 15:08:50 +03:00

50 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AnthropicHandler
**Özet:** `/anthropic/*` route'unu karşılar (`handlers/anthropic.go:75`). Anthropic Messages API formatını OpenAI Chat Completions formatına çevirir (Bifrost), upstream'e iletir ve yanıtı geri Anthropic formatına dönüştürür.
**Kütüphaneler:** Fiber v3, GORM, Go `encoding/json`
**Bağlantılar:** [[Main]], [[BifrostTransform]], [[ProxyEngine]], [[RequestLog]], [[Config]], [[Anthropic Flow]]
## Davranış
1. `GET /v1/models` → [[AnthropicHandler#modelsList|modelleri listele]]
2. `HEAD` → 404 (DeepSeek uyumluluğu)
3. Empty body → varsayılan "optoant gateway ready" yanıtı
4. `x-api-key``Authorization: Bearer` dönüşümü (Claude Code uyumluluğu)
5. Gerekirse `OPENAI_KEY`'den auto-inject
6. [[BifrostTransform#AnthropicToBifrost|AnthropicToBifrost()]] ile dönüşüm
7. [[ProxyEngine]] ile `OPENAI_BACKEND/v1/chat/completions`'a forward
8. Başarılıysa (200): [[BifrostTransform#BifrostToAnthropic|BifrostToAnthropic()]] → Anthropic format
9. Hata durumunda: raw passthrough
10. DB log (fire-and-forget)
## Endpoint
```
POST /anthropic/v1/messages
x-api-key: <api-key>
# veya
Authorization: Bearer <api-key>
```
## Modeller (`modelsList()`)
| ID | Display Name |
|---|---|
| `deepseek-v4-flash` | DeepSeek V4 Flash |
| `deepseek-v4-pro` | DeepSeek V4 Pro |
## Ek Fonksiyonlar
| Fonksiyon | Açıklama |
|---|---|
| `infoPage()` | `GET /anthropic` (boş path) için HTML bilgi sayfası |
| `modelsList()` | `GET /anthropic/v1/models` için model listesi |
## Edge Case'ler
- Geçersiz Anthropic formatı → uyarı log'u + raw passthrough
- Upstream hatası`502 Bad Gateway`
- Yanıt dönüşüm hatası → raw yanıtı forward et