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

text-provider-options.ts

115 lines3.4 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; `repetition_penalty` and `service_tier` are
6 * the Ark-only additions. Thinking is set with `chat({ reasoning })`.
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 constraint TypeScript can't express: `max_tokens` and
12 * `max_completion_tokens` are mutually exclusive.
13 *
14 * `response_format` is deliberately absent — the chat activity owns it via
15 * `outputSchema` / structured output, and Ark rejects `json_object` outright
16 * on every model.
17 */
18​
19/**
20 * Request routing tier. `flex` routes to the batch queue at a lower price with
21 * no latency guarantee; `default` is the standard online tier.
22 */
23export type BytePlusServiceTier = 'default' | 'flex'
24​
25/**
26 * Forces the model to call one specific function.
27 */
28export interface BytePlusNamedToolChoice {
29 type: 'function'
30 function: { name: string }
32​
33/**
34 * Controls which (if any) tool the model calls.
35 */
36export type BytePlusToolChoice =
37 | 'none'
38 | 'auto'
39 | 'required'
40 | BytePlusNamedToolChoice
41​
42/**
43 * Provider options for BytePlus chat models.
44 */
45export interface BytePlusTextProviderOptions {
46 // --------------------------------------------------------------------
47 // Ark-only
48 // --------------------------------------------------------------------
49​
50 /**
51 * Penalty applied to repeated tokens. Values above 1 discourage repetition.
52 */
53 repetition_penalty?: number
54​
55 /** Request routing tier — see {@link BytePlusServiceTier}. */
56 service_tier?: BytePlusServiceTier
57​
58 // --------------------------------------------------------------------
59 // OpenAI-compatible sampling surface
60 // --------------------------------------------------------------------
61​
62 /** Sampling temperature. Higher values produce more varied output. */
63 temperature?: number
64​
65 /** Nucleus sampling cutoff. */
66 top_p?: number
67​
68 /** Restricts sampling to the `k` most likely tokens. */
69 top_k?: number
70​
71 /**
72 * Maximum tokens to generate. Mutually exclusive with
73 * `max_completion_tokens` — sending both is a 400.
74 */
75 max_tokens?: number
76​
77 /**
78 * OpenAI's newer name for {@link BytePlusTextProviderOptions.max_tokens}.
79 * Mutually exclusive with it.
80 */
81 max_completion_tokens?: number
82​
83 /** Penalizes tokens by how often they have already appeared. */
84 frequency_penalty?: number
85​
86 /** Penalizes tokens that have appeared at all, regardless of count. */
87 presence_penalty?: number
88​
89 /** Up to four strings that stop generation when produced. */
90 stop?: string | Array<string>
91​
92 /** Number of completions to generate. */
93 n?: number
94​
95 /** Best-effort determinism hint for repeated identical requests. */
96 seed?: number
97​
98 /** Return log probabilities for the generated tokens. */
99 logprobs?: boolean
100​
101 /** How many alternatives to report per token. Requires `logprobs`. */
102 top_logprobs?: number
103​
104 /** Additive bias per token id, applied before sampling. */
105 logit_bias?: Record<string, number>
106​
107 /** Opaque end-user identifier forwarded for abuse monitoring. */
108 user?: string
109​
110 /** Whether the model may emit several tool calls in one turn. */
111 parallel_tool_calls?: boolean
112​
113 /** Tool-selection strategy — see {@link BytePlusToolChoice}. */
114 tool_choice?: BytePlusToolChoice