summaryrefslogtreecommitdiff
path: root/libpanto/src/config.zig
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-06-13 12:22:18 -0600
committert <t@tjp.lol>2026-06-15 15:08:32 -0600
commiteb19fd812e15de5a6930daf2fcd0b2b0757687c7 (patch)
treeace85c641e48836fe45b289141213fe8984ccb52 /libpanto/src/config.zig
parent9f983c5d0ecc1c12f15eadf1add123e24995b660 (diff)
auth: openai_responses provider for Codex subscription (Tier 2)
Add the OpenAI Responses API wire dialect (openai_responses APIStyle + OpenAIResponsesConfig), a request serializer (instructions/input items, flat function tools, reasoning, store:false, include encrypted reasoning), and a streaming state machine over the typed response.* SSE events mapping to the shared block model. Wire dispatch, buildProviderConfig, the C-ABI free switch, and the reasoning selectors. Ship a commented Codex example in the default config. Implemented from the Responses API docs + the open-source Codex client and covered by fixture tests; live verification against a ChatGPT plan is still required (documented).
Diffstat (limited to 'libpanto/src/config.zig')
-rw-r--r--libpanto/src/config.zig24
1 files changed, 24 insertions, 0 deletions
diff --git a/libpanto/src/config.zig b/libpanto/src/config.zig
index 09aaec8..c48cefc 100644
--- a/libpanto/src/config.zig
+++ b/libpanto/src/config.zig
@@ -24,6 +24,9 @@ const Io = std.Io;
pub const APIStyle = enum {
openai_chat,
anthropic_messages,
+ /// OpenAI Responses API (`/responses`). Used by the ChatGPT-subscription
+ /// Codex backend, whose request/stream shape differs from Chat Completions.
+ openai_responses,
};
/// A single HTTP request header (name/value). Used for provider
@@ -133,10 +136,25 @@ pub const AnthropicMessagesConfig = struct {
extra_headers: []const Header = &.{},
};
+/// OpenAI Responses API config. Same transport knobs as `openai_chat`, but a
+/// distinct request body (`input` items, `reasoning`, `store`, `include`) and
+/// streaming event shape. Auth-derived headers (`chatgpt-account-id`) and the
+/// static Codex identity headers (`OpenAI-Beta`, `originator`) ride on
+/// `extra_headers`.
+pub const OpenAIResponsesConfig = struct {
+ api_key: []const u8,
+ base_url: []const u8,
+ model: []const u8,
+ reasoning: ReasoningEffort = .default,
+ max_tokens: u32 = 64_000,
+ extra_headers: []const Header = &.{},
+};
+
/// Per-provider transport/auth/model configuration. Tagged by `APIStyle`.
pub const ProviderConfig = union(APIStyle) {
openai_chat: OpenAIChatConfig,
anthropic_messages: AnthropicMessagesConfig,
+ openai_responses: OpenAIResponsesConfig,
pub fn style(self: ProviderConfig) APIStyle {
return @as(APIStyle, self);
@@ -163,6 +181,12 @@ pub const ProviderConfig = union(APIStyle) {
.thinking_budget_tokens = c.thinking_budget_tokens,
.thinking_interleaved = c.thinking_interleaved,
},
+ .openai_responses => |c| .{
+ .api_style = .openai_responses,
+ .base_url = c.base_url,
+ .model = c.model,
+ .reasoning = c.reasoning,
+ },
};
}
};