Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/providers/gateway/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! - **Platform mode**: uses `Authorization: Bearer <token>`. Activated by
//! setting `GATEWAY_PLATFORM_TOKEN` env var, or by passing
//! `platform_token` in `ProviderConfig::extra`.
//! - **Non-platform mode**: uses the `X-AnyLLM-Key: Bearer <key>` header.
//! - **Non-platform mode**: uses the `AnyLLM-Key: Bearer <key>` header.
//! The key is optional (the gateway may allow unauthenticated access).

use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION, CONTENT_TYPE};
Expand All @@ -26,7 +26,7 @@ use models::request::GatewayRequest;
use models::response::GatewayResponse;
use models::stream::GatewayStream;

const GATEWAY_HEADER_NAME: &str = "X-AnyLLM-Key";
const GATEWAY_HEADER_NAME: &str = "AnyLLM-Key";
const GATEWAY_PLATFORM_TOKEN_ENV: &str = "GATEWAY_PLATFORM_TOKEN";
const GATEWAY_API_BASE_ENV: &str = "GATEWAY_API_BASE";

Expand Down Expand Up @@ -154,7 +154,7 @@ impl Provider for Gateway {
/// This mirrors the Python `GatewayProvider.__init__` logic:
/// 1. Explicit `platform_mode=true` -> platform mode, needs a token
/// 2. `GATEWAY_PLATFORM_TOKEN` set + no explicit api_key -> auto-detect platform
/// 3. Otherwise -> non-platform mode with optional X-AnyLLM-Key header
/// 3. Otherwise -> non-platform mode with optional AnyLLM-Key header
fn resolve_auth(
api_key: Option<String>,
platform_token: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ async fn platform_mode_sends_authorization_header() {
}

#[tokio::test]
async fn non_platform_mode_sends_x_anyllm_key_header() {
async fn non_platform_mode_sends_anyllm_key_header() {
let server = MockServer::start().await;

Mock::given(method("POST"))
.and(path("/v1/chat/completions"))
.and(header("X-AnyLLM-Key", "Bearer my-api-key"))
.and(header("AnyLLM-Key", "Bearer my-api-key"))
.respond_with(ResponseTemplate::new(200).set_body_json(chat_completion_json()))
.expect(1)
.mount(&server)
Expand Down
Loading