1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Xybrid Gateway - OpenAI-Compatible Cloud Adapter
//!
//! The Gateway provides a unified, secure endpoint for cloud AI services.
//! It speaks OpenAI's API format and routes requests to the appropriate backend.
//!
//! ## Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────────────┐
//! │ Xybrid Gateway │
//! │ https://api.xybrid.dev/v1 │
//! ├─────────────────────────────────────────────────────────────────────────┤
//! │ │
//! │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
//! │ │ /chat/ │ │ /embeddings │ │ /audio/ │ │
//! │ │ completions │ │ │ │ transcriptions│ │
//! │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
//! │ │ │ │ │
//! │ ▼ ▼ ▼ │
//! │ ┌─────────────────────────────────────────────────────────────┐ │
//! │ │ Request Router │ │
//! │ │ • API Key Validation • Rate Limiting │ │
//! │ │ • Usage Tracking • Request Logging │ │
//! │ │ • Safety Filtering • Cost Metering │ │
//! │ └─────────────────────────────────────────────────────────────┘ │
//! │ │ │
//! │ ┌────────────────────┼────────────────────┐ │
//! │ │ │ │ │
//! │ ▼ ▼ ▼ │
//! │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
//! │ │ OpenAI │ │ Anthropic │ │ Groq │ │
//! │ │ Backend │ │ Backend │ │ Backend │ │
//! │ └──────────────┘ └──────────────┘ └──────────────┘ │
//! │ │
//! └─────────────────────────────────────────────────────────────────────────┘
//! ```
//!
//! ## Endpoints
//!
//! ### Chat Completions
//! `POST /v1/chat/completions`
//!
//! OpenAI-compatible chat completions endpoint. Supports:
//! - Standard messages format (system, user, assistant)
//! - Streaming responses (SSE)
//! - Function calling / Tools
//! - Multiple model backends
//!
//! ### Embeddings (Future)
//! `POST /v1/embeddings`
//!
//! ### Audio Transcriptions (Future)
//! `POST /v1/audio/transcriptions`
//!
//! ## Security
//!
//! The Gateway provides several security benefits:
//!
//! 1. **API Key Protection**: Users don't expose their provider API keys to clients
//! 2. **Usage Control**: Rate limiting and quota management
//! 3. **Content Safety**: Optional content filtering and moderation
//! 4. **Audit Logging**: Complete request/response logging for compliance
//! 5. **Cost Management**: Per-user cost tracking and limits
//!
//! ## Authentication
//!
//! Requests use Bearer token authentication:
//! ```text
//! Authorization: Bearer xybrid_sk_...
//! ```
//!
//! Users can either:
//! - Use Xybrid-managed API keys (we handle provider keys)
//! - Bring their own provider keys (stored securely, used per-request)
pub use ;
pub use ;
pub use GatewayError;
pub use ;