summaryrefslogtreecommitdiff
path: root/libpanto/src/provider_anthropic_messages.zig
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-06-15 20:51:54 -0600
committert <t@tjp.lol>2026-06-15 20:52:24 -0600
commit8206642d3a1736aaf928a5b9a732e747f5294228 (patch)
tree35920604adaa037fc2e12923066271804dec9500 /libpanto/src/provider_anthropic_messages.zig
parent9f8719929dbd1326d9b327885c4da319c6d2673c (diff)
models.dev list validation against actual provider's /models
Diffstat (limited to 'libpanto/src/provider_anthropic_messages.zig')
-rw-r--r--libpanto/src/provider_anthropic_messages.zig15
1 files changed, 8 insertions, 7 deletions
diff --git a/libpanto/src/provider_anthropic_messages.zig b/libpanto/src/provider_anthropic_messages.zig
index 5721e4a..258ddbd 100644
--- a/libpanto/src/provider_anthropic_messages.zig
+++ b/libpanto/src/provider_anthropic_messages.zig
@@ -5,10 +5,10 @@
//!
//! Responsibilities:
//! - Convert `Conversation` → request JSON (delegated to anthropic_messages_json.zig)
-//! - POST to `{base_url}/messages` with `stream: true`
-//! (caller is responsible for the `/v1` version segment; panto will
-//! introduce a new `anthropic_messages_v2` API style for v2 rather than
-//! pulling the version into the provider)
+//! - POST to `{base_url}/v1/messages` with `stream: true`
+//! (the provider owns the current `/v1` suffix; a future wire revision
+//! would add a new `anthropic_messages_v2` API style rather than guessing
+//! from the configured base URL)
//! - Read the chunked body, feed bytes through SSEParser
//! - Parse each event payload, drive a thin assembly loop, and emit Receiver
//! callbacks. Anthropic gives us explicit block boundaries, so no
@@ -72,10 +72,11 @@ pub const AnthropicMessagesRequest = struct {
rr.state.deinit();
}
+ const trimmed_base = std.mem.trim(u8, self.config.base_url, "/");
const url = try std.fmt.allocPrint(
self.allocator,
- "{s}/messages",
- .{self.config.base_url},
+ "{s}/v1/messages",
+ .{trimmed_base},
);
defer self.allocator.free(url);
@@ -1270,7 +1271,7 @@ test "oauth-backed anthropic auth uses bearer auth" {
test "plain anthropic auth uses x-api-key" {
const cfg: config_mod.AnthropicMessagesConfig = .{
.api_key = "k",
- .base_url = "https://api.anthropic.com/v1",
+ .base_url = "https://api.anthropic.com",
.model = "claude-sonnet-4-5",
};
try testing.expect(!headerSliceUsesBearerAuth(&cfg));