vtcode_llm/providers/openai/types.rs
1//! OpenAI provider types and constants.
2//!
3//! This module contains shared types used across the OpenAI provider implementation.
4
5use serde_json::Value;
6
7/// Responses API availability state for a given model.
8#[derive(Clone, Copy, PartialEq, Eq, Debug)]
9pub enum ResponsesApiState {
10 /// Responses API is required for this model (e.g., GPT-5 Codex).
11 Required,
12 /// Responses API is allowed but not required.
13 Allowed,
14 /// Responses API is disabled (use Chat Completions).
15 Disabled,
16}
17
18/// Payload structure for OpenAI Responses API requests.
19pub(crate) struct OpenAIResponsesPayload {
20 /// The input messages/items for the request.
21 pub(crate) input: Vec<Value>,
22 /// Optional system instructions.
23 pub(crate) instructions: Option<String>,
24 /// Per-segment provenance for `instructions`, in wire order.
25 ///
26 /// `None` when `instructions` is `None` or when the composition is
27 /// all-static (single stable segment). Consumers that need to relocate
28 /// volatile content use this instead of guessing at a joined-string
29 /// layout, which breaks the moment segment order varies.
30 pub(crate) instruction_segments: Option<Vec<(InstructionSegmentKind, String)>>,
31}
32
33/// Provenance kind for one segment of the composed `instructions` string.
34#[derive(Debug, Clone, Copy, PartialEq, Eq)]
35pub(crate) enum InstructionSegmentKind {
36 /// The request-level system prompt (session-stable).
37 SystemPrompt,
38 /// A `System`-role message from conversation history (per-turn).
39 HistorySystem,
40 /// Assistant/tool history folded into instructions (non-structured path).
41 FoldedHistory,
42}
43
44/// Maximum completion tokens field name for Chat Completions API.
45pub(crate) const MAX_COMPLETION_TOKENS_FIELD: &str = "max_completion_tokens";