Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

text-provider-options.ts

151 lines4.6 KB

1/**
2 * BytePlus ModelArk chat provider options.
3 *
4 * Ark's `/chat/completions` is OpenAI-compatible, so most of this is the
5 * familiar sampling surface; `thinking`, `reasoning_effort`,
6 * `repetition_penalty` and `service_tier` are the Ark-only additions.
7 *
8 * Every field below was accepted by a live request against
9 * `https://ark.ap-southeast.bytepluses.com/api/v3` on 2026-07-31. Two probe
10 * results are encoded as TSDoc warnings rather than types because they are
11 * cross-field constraints TypeScript can't express: `max_tokens` and
12 * `max_completion_tokens` are mutually exclusive, and `reasoning_effort`
13 * combined with `thinking: {type: 'disabled'}` is a 400.
14 *
15 * `response_format` is deliberately absent — the chat activity owns it via
16 * `outputSchema` / structured output, and Ark rejects `json_object` outright
17 * on every model.
18 */
19​
20/**
21 * Reasoning ("deep thinking") switch.
22 *
23 * - `enabled` — the model reasons before answering (default on every model
24 * except `deepseek-v3-2-251201`, where reasoning defaults to off).
25 * - `disabled` — skip reasoning.
26 * - `auto` — let the model decide. Only accepted by `gpt-oss-120b-250805`.
27 */
28export interface BytePlusThinkingOption {
29 type: 'enabled' | 'disabled' | 'auto'
31​
32/**
33 * Reasoning budget hint. `none` and `xhigh` are only accepted by
34 * `glm-5-2-260617`; `max` by `glm-5-2-260617` and the `deepseek-v4-*` models.
35 *
36 * Cannot be combined with `thinking: {type: 'disabled'}` — Ark rejects the
37 * pair with `400 InvalidParameter` ("Invalid combination of reasoning_effort
38 * and thinking type").
39 */
40export type BytePlusReasoningEffort =
41 | 'none'
42 | 'minimal'
43 | 'low'
44 | 'medium'
45 | 'high'
46 | 'xhigh'
47 | 'max'
48​
49/**
50 * Request routing tier. `flex` routes to the batch queue at a lower price with
51 * no latency guarantee; `default` is the standard online tier.
52 */
53export type BytePlusServiceTier = 'default' | 'flex'
54​
55/**
56 * Forces the model to call one specific function.
57 */
58export interface BytePlusNamedToolChoice {
59 type: 'function'
60 function: { name: string }
62​
63/**
64 * Controls which (if any) tool the model calls.
65 */
66export type BytePlusToolChoice =
67 | 'none'
68 | 'auto'
69 | 'required'
70 | BytePlusNamedToolChoice
71​
72/**
73 * Provider options for BytePlus chat models.
74 */
75export interface BytePlusTextProviderOptions {
76 // --------------------------------------------------------------------
77 // Ark-only
78 // --------------------------------------------------------------------
79​
80 /** Reasoning switch — see {@link BytePlusThinkingOption}. */
81 thinking?: BytePlusThinkingOption
82​
83 /** Reasoning budget hint — see {@link BytePlusReasoningEffort}. */
84 reasoning_effort?: BytePlusReasoningEffort
85​
86 /**
87 * Penalty applied to repeated tokens. Values above 1 discourage repetition.
88 */
89 repetition_penalty?: number
90​
91 /** Request routing tier — see {@link BytePlusServiceTier}. */
92 service_tier?: BytePlusServiceTier
93​
94 // --------------------------------------------------------------------
95 // OpenAI-compatible sampling surface
96 // --------------------------------------------------------------------
97​
98 /** Sampling temperature. Higher values produce more varied output. */
99 temperature?: number
100​
101 /** Nucleus sampling cutoff. */
102 top_p?: number
103​
104 /** Restricts sampling to the `k` most likely tokens. */
105 top_k?: number
106​
107 /**
108 * Maximum tokens to generate. Mutually exclusive with
109 * `max_completion_tokens` — sending both is a 400.
110 */
111 max_tokens?: number
112​
113 /**
114 * OpenAI's newer name for {@link BytePlusTextProviderOptions.max_tokens}.
115 * Mutually exclusive with it.
116 */
117 max_completion_tokens?: number
118​
119 /** Penalizes tokens by how often they have already appeared. */
120 frequency_penalty?: number
121​
122 /** Penalizes tokens that have appeared at all, regardless of count. */
123 presence_penalty?: number
124​
125 /** Up to four strings that stop generation when produced. */
126 stop?: string | Array<string>
127​
128 /** Number of completions to generate. */
129 n?: number
130​
131 /** Best-effort determinism hint for repeated identical requests. */
132 seed?: number
133​
134 /** Return log probabilities for the generated tokens. */
135 logprobs?: boolean
136​
137 /** How many alternatives to report per token. Requires `logprobs`. */
138 top_logprobs?: number
139​
140 /** Additive bias per token id, applied before sampling. */
141 logit_bias?: Record<string, number>
142​
143 /** Opaque end-user identifier forwarded for abuse monitoring. */
144 user?: string
145​
146 /** Whether the model may emit several tool calls in one turn. */
147 parallel_tool_calls?: boolean
148​
149 /** Tool-selection strategy — see {@link BytePlusToolChoice}. */
150 tool_choice?: BytePlusToolChoice