@opencode-ai/ai 0.0.0-next-16997 → 0.0.0-next-16999

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -368,11 +368,12 @@ Other provider exports listed above remain direct facades until they explicitly
368
368
 
369
369
  ## Provider options & HTTP overlays
370
370
 
371
- Three escape hatches in order of stability:
371
+ Request options in order of stability:
372
372
 
373
373
  1. **`generation`** — portable knobs (`maxTokens`, `temperature`, `topP`, `topK`, penalties, seed, stop).
374
- 2. **`providerOptions: { <provider>: {...} }`** — typed-at-the-facade provider-specific knobs (OpenAI `promptCacheKey`, Anthropic `thinking`, Gemini `thinkingConfig`, OpenRouter routing).
375
- 3. **`http: { body, headers, query }`** — last-resort serializable overlays merged into the final HTTP request. Reach for this only when a stable typed path doesn't yet exist.
374
+ 2. **`promptCacheKey`** — stable cache affinity lowered by every protocol that supports it.
375
+ 3. **`providerOptions: { <provider>: {...} }`** — typed-at-the-facade provider-specific knobs (OpenAI `store`, Anthropic `thinking`, Gemini `thinkingConfig`, OpenRouter routing).
376
+ 4. **`http: { body, headers, query }`** — last-resort serializable overlays merged into the final HTTP request. Reach for this only when a stable typed path doesn't yet exist.
376
377
 
377
378
  Route/provider defaults are overridden by request-level values for each axis.
378
379
 
@@ -483,8 +483,8 @@ export declare const fromRequest: (request: LLMRequest) => Effect.Effect<{
483
483
  readonly top_p?: number | undefined;
484
484
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
485
485
  readonly store?: boolean | undefined;
486
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
487
486
  readonly prompt_cache_key?: string | undefined;
487
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
488
488
  readonly max_output_tokens?: number | undefined;
489
489
  }, AIError, never>;
490
490
  export declare const providerMetadata: (state: ParserState, metadata: Record<string, unknown>) => ProviderMetadata;
@@ -763,8 +763,8 @@ export declare const protocol: Protocol<{
763
763
  readonly top_p?: number | undefined;
764
764
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
765
765
  readonly store?: boolean | undefined;
766
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
767
766
  readonly prompt_cache_key?: string | undefined;
767
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
768
768
  readonly max_output_tokens?: number | undefined;
769
769
  }, string, {
770
770
  readonly [x: string]: unknown;
@@ -900,8 +900,8 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
900
900
  readonly top_p?: number | undefined;
901
901
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
902
902
  readonly store?: boolean | undefined;
903
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
904
903
  readonly prompt_cache_key?: string | undefined;
904
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
905
905
  readonly max_output_tokens?: number | undefined;
906
906
  }, string>;
907
907
  export * as OpenResponses from "./open-responses";
@@ -392,7 +392,7 @@ const lowerOptions = (request) => {
392
392
  return {
393
393
  ...(options.instructions ? { instructions: options.instructions } : {}),
394
394
  ...(options.store !== undefined ? { store: options.store } : {}),
395
- ...(options.promptCacheKey ? { prompt_cache_key: options.promptCacheKey } : {}),
395
+ ...(request.promptCacheKey ? { prompt_cache_key: request.promptCacheKey } : {}),
396
396
  ...(options.include ? { include: options.include } : {}),
397
397
  ...(options.reasoningEffort || options.reasoningSummary
398
398
  ? { reasoning: { effort: options.reasoningEffort, summary: options.reasoningSummary } }
@@ -94,6 +94,7 @@ export declare const bodyFields: {
94
94
  readonly include_usage: Schema.Boolean;
95
95
  }>>;
96
96
  store: Schema.optional<Schema.Boolean>;
97
+ prompt_cache_key: Schema.optional<Schema.String>;
97
98
  reasoning_effort: Schema.optional<Schema.String>;
98
99
  max_completion_tokens: Schema.optional<Schema.Number>;
99
100
  max_tokens: Schema.optional<Schema.Number>;
@@ -187,6 +188,7 @@ declare const OpenAIChatBody: Schema.Struct<{
187
188
  readonly include_usage: Schema.Boolean;
188
189
  }>>;
189
190
  store: Schema.optional<Schema.Boolean>;
191
+ prompt_cache_key: Schema.optional<Schema.String>;
190
192
  reasoning_effort: Schema.optional<Schema.String>;
191
193
  max_completion_tokens: Schema.optional<Schema.Number>;
192
194
  max_tokens: Schema.optional<Schema.Number>;
@@ -262,6 +264,7 @@ interface LoweringOptions {
262
264
  }
263
265
  export declare const fromRequest: (request: LLMRequest, options?: LoweringOptions | undefined) => Effect.Effect<{
264
266
  reasoning_effort?: string | undefined;
267
+ prompt_cache_key?: string | undefined;
265
268
  store?: boolean | undefined;
266
269
  temperature: number | undefined;
267
270
  top_p: number | undefined;
@@ -356,6 +359,7 @@ export declare const fromRequest: (request: LLMRequest, options?: LoweringOption
356
359
  };
357
360
  } | {
358
361
  reasoning_effort?: string | undefined;
362
+ prompt_cache_key?: string | undefined;
359
363
  store?: boolean | undefined;
360
364
  temperature: number | undefined;
361
365
  top_p: number | undefined;
@@ -547,6 +551,7 @@ export declare const protocol: Protocol<{
547
551
  readonly stream_options?: {
548
552
  readonly include_usage: boolean;
549
553
  } | undefined;
554
+ readonly prompt_cache_key?: string | undefined;
550
555
  readonly reasoning_effort?: string | undefined;
551
556
  readonly frequency_penalty?: number | undefined;
552
557
  readonly presence_penalty?: number | undefined;
@@ -685,6 +690,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
685
690
  readonly stream_options?: {
686
691
  readonly include_usage: boolean;
687
692
  } | undefined;
693
+ readonly prompt_cache_key?: string | undefined;
688
694
  readonly reasoning_effort?: string | undefined;
689
695
  readonly frequency_penalty?: number | undefined;
690
696
  readonly presence_penalty?: number | undefined;
@@ -781,6 +787,7 @@ export declare const route: Route<{
781
787
  readonly stream_options?: {
782
788
  readonly include_usage: boolean;
783
789
  } | undefined;
790
+ readonly prompt_cache_key?: string | undefined;
784
791
  readonly reasoning_effort?: string | undefined;
785
792
  readonly frequency_penalty?: number | undefined;
786
793
  readonly presence_penalty?: number | undefined;
@@ -102,6 +102,7 @@ export const bodyFields = {
102
102
  stream: Schema.Literal(true),
103
103
  stream_options: Schema.optional(Schema.Struct({ include_usage: Schema.Boolean })),
104
104
  store: Schema.optional(Schema.Boolean),
105
+ prompt_cache_key: Schema.optional(Schema.String),
105
106
  reasoning_effort: Schema.optional(OpenAIOptions.OpenAIReasoningEffort),
106
107
  max_completion_tokens: Schema.optional(Schema.Number),
107
108
  max_tokens: Schema.optional(Schema.Number),
@@ -396,6 +397,7 @@ const lowerOptions = (request) => {
396
397
  const options = OpenAIOptions.resolve(request);
397
398
  return {
398
399
  ...(options.store !== undefined ? { store: options.store } : {}),
400
+ ...(request.promptCacheKey ? { prompt_cache_key: request.promptCacheKey } : {}),
399
401
  ...(options.reasoningEffort ? { reasoning_effort: options.reasoningEffort } : {}),
400
402
  };
401
403
  };
@@ -99,6 +99,7 @@ export declare const route: Route<{
99
99
  readonly stream_options?: {
100
100
  readonly include_usage: boolean;
101
101
  } | undefined;
102
+ readonly prompt_cache_key?: string | undefined;
102
103
  readonly reasoning_effort?: string | undefined;
103
104
  readonly frequency_penalty?: number | undefined;
104
105
  readonly presence_penalty?: number | undefined;
@@ -89,8 +89,8 @@ export declare const route: Route<{
89
89
  readonly top_p?: number | undefined;
90
90
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
91
91
  readonly store?: boolean | undefined;
92
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
93
92
  readonly prompt_cache_key?: string | undefined;
93
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
94
94
  readonly max_output_tokens?: number | undefined;
95
95
  }, import("../route/transport/http").HttpPrepared<string>>;
96
96
  export * as OpenAICompatibleResponses from "./openai-compatible-responses";
@@ -214,8 +214,8 @@ export declare const protocol: Protocol<{
214
214
  readonly top_p?: number | undefined;
215
215
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
216
216
  readonly store?: boolean | undefined;
217
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
218
217
  readonly prompt_cache_key?: string | undefined;
218
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
219
219
  readonly max_output_tokens?: number | undefined;
220
220
  }, string, {
221
221
  readonly [x: string]: unknown;
@@ -370,8 +370,8 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
370
370
  readonly top_p?: number | undefined;
371
371
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
372
372
  readonly store?: boolean | undefined;
373
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
374
373
  readonly prompt_cache_key?: string | undefined;
374
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
375
375
  readonly max_output_tokens?: number | undefined;
376
376
  }, string>;
377
377
  export declare const route: Route<{
@@ -477,8 +477,8 @@ export declare const route: Route<{
477
477
  readonly top_p?: number | undefined;
478
478
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
479
479
  readonly store?: boolean | undefined;
480
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
481
480
  readonly prompt_cache_key?: string | undefined;
481
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
482
482
  readonly max_output_tokens?: number | undefined;
483
483
  }, HttpTransport.HttpPrepared<string>>;
484
484
  export declare const webSocketTransport: import("../route/transport/websocket").JsonTransport<{
@@ -584,8 +584,8 @@ export declare const webSocketTransport: import("../route/transport/websocket").
584
584
  readonly top_p?: number | undefined;
585
585
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
586
586
  readonly store?: boolean | undefined;
587
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
588
587
  readonly prompt_cache_key?: string | undefined;
588
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
589
589
  readonly max_output_tokens?: number | undefined;
590
590
  }, {
591
591
  readonly [x: string]: unknown;
@@ -691,8 +691,8 @@ export declare const webSocketTransport: import("../route/transport/websocket").
691
691
  readonly top_p?: number | undefined;
692
692
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
693
693
  readonly store?: boolean | undefined;
694
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
695
694
  readonly prompt_cache_key?: string | undefined;
695
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
696
696
  readonly max_output_tokens?: number | undefined;
697
697
  }>;
698
698
  export declare const webSocketRoute: Route<{
@@ -798,8 +798,8 @@ export declare const webSocketRoute: Route<{
798
798
  readonly top_p?: number | undefined;
799
799
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
800
800
  readonly store?: boolean | undefined;
801
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
802
801
  readonly prompt_cache_key?: string | undefined;
802
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
803
803
  readonly max_output_tokens?: number | undefined;
804
804
  }, import("../route/transport/websocket").JsonPrepared>;
805
805
  export * as OpenAIResponses from "./openai-responses";
@@ -11,7 +11,6 @@ export declare const ServiceTierSchema: Schema.Literals<readonly ["auto", "defau
11
11
  export interface Resolved {
12
12
  readonly instructions?: string;
13
13
  readonly store?: boolean;
14
- readonly promptCacheKey?: string;
15
14
  readonly reasoningEffort?: string;
16
15
  readonly reasoningSummary?: "auto" | "concise" | "detailed";
17
16
  readonly include?: ReadonlyArray<ResponseIncludable>;
@@ -29,7 +29,6 @@ export const resolve = (request) => {
29
29
  return {
30
30
  instructions: typeof input?.instructions === "string" ? input.instructions : undefined,
31
31
  store: typeof input?.store === "boolean" ? input.store : undefined,
32
- promptCacheKey: typeof input?.promptCacheKey === "string" ? input.promptCacheKey : undefined,
33
32
  reasoningEffort: typeof input?.reasoningEffort === "string" ? input.reasoningEffort : undefined,
34
33
  reasoningSummary: reasoningSummary === "auto" || reasoningSummary === "concise" || reasoningSummary === "detailed"
35
34
  ? reasoningSummary
@@ -111,6 +111,7 @@ export declare const routes: (RouteDef<{
111
111
  readonly stream_options?: {
112
112
  readonly include_usage: boolean;
113
113
  } | undefined;
114
+ readonly prompt_cache_key?: string | undefined;
114
115
  readonly reasoning_effort?: string | undefined;
115
116
  readonly frequency_penalty?: number | undefined;
116
117
  readonly presence_penalty?: number | undefined;
@@ -217,8 +218,8 @@ export declare const routes: (RouteDef<{
217
218
  readonly top_p?: number | undefined;
218
219
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
219
220
  readonly store?: boolean | undefined;
220
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
221
221
  readonly prompt_cache_key?: string | undefined;
222
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
222
223
  readonly max_output_tokens?: number | undefined;
223
224
  }, import("../route/transport/http").HttpPrepared<string>>)[];
224
225
  export declare const configure: (input?: Config) => {
@@ -114,6 +114,7 @@ export declare const routes: (RouteDef<{
114
114
  readonly stream_options?: {
115
115
  readonly include_usage: boolean;
116
116
  } | undefined;
117
+ readonly prompt_cache_key?: string | undefined;
117
118
  readonly reasoning_effort?: string | undefined;
118
119
  readonly frequency_penalty?: number | undefined;
119
120
  readonly presence_penalty?: number | undefined;
@@ -220,8 +221,8 @@ export declare const routes: (RouteDef<{
220
221
  readonly top_p?: number | undefined;
221
222
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
222
223
  readonly store?: boolean | undefined;
223
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
224
224
  readonly prompt_cache_key?: string | undefined;
225
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
225
226
  readonly max_output_tokens?: number | undefined;
226
227
  }, import("../route/transport/http").HttpPrepared<string>>)[];
227
228
  export declare const configure: (input: Config) => {
@@ -120,6 +120,7 @@ export declare const aiGatewayRoute: import("../route").Route<{
120
120
  readonly stream_options?: {
121
121
  readonly include_usage: boolean;
122
122
  } | undefined;
123
+ readonly prompt_cache_key?: string | undefined;
123
124
  readonly reasoning_effort?: string | undefined;
124
125
  readonly frequency_penalty?: number | undefined;
125
126
  readonly presence_penalty?: number | undefined;
@@ -216,6 +217,7 @@ export declare const workersAIRoute: import("../route").Route<{
216
217
  readonly stream_options?: {
217
218
  readonly include_usage: boolean;
218
219
  } | undefined;
220
+ readonly prompt_cache_key?: string | undefined;
219
221
  readonly reasoning_effort?: string | undefined;
220
222
  readonly frequency_penalty?: number | undefined;
221
223
  readonly presence_penalty?: number | undefined;
@@ -312,6 +314,7 @@ export declare const routes: import("../route").Route<{
312
314
  readonly stream_options?: {
313
315
  readonly include_usage: boolean;
314
316
  } | undefined;
317
+ readonly prompt_cache_key?: string | undefined;
315
318
  readonly reasoning_effort?: string | undefined;
316
319
  readonly frequency_penalty?: number | undefined;
317
320
  readonly presence_penalty?: number | undefined;
@@ -101,6 +101,7 @@ export declare const routes: (import("../route").Route<{
101
101
  readonly stream_options?: {
102
102
  readonly include_usage: boolean;
103
103
  } | undefined;
104
+ readonly prompt_cache_key?: string | undefined;
104
105
  readonly reasoning_effort?: string | undefined;
105
106
  readonly frequency_penalty?: number | undefined;
106
107
  readonly presence_penalty?: number | undefined;
@@ -207,8 +208,8 @@ export declare const routes: (import("../route").Route<{
207
208
  readonly top_p?: number | undefined;
208
209
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
209
210
  readonly store?: boolean | undefined;
210
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
211
211
  readonly prompt_cache_key?: string | undefined;
212
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
212
213
  readonly max_output_tokens?: number | undefined;
213
214
  }, import("../route/transport/http").HttpPrepared<string>>)[];
214
215
  export declare const configure: (options: LanguageModelOptions) => {
@@ -110,6 +110,7 @@ export declare const routes: import("../route").Route<{
110
110
  readonly stream_options?: {
111
111
  readonly include_usage: boolean;
112
112
  } | undefined;
113
+ readonly prompt_cache_key?: string | undefined;
113
114
  readonly reasoning_effort?: string | undefined;
114
115
  readonly frequency_penalty?: number | undefined;
115
116
  readonly presence_penalty?: number | undefined;
@@ -102,8 +102,8 @@ export declare const routes: import("../route").Route<{
102
102
  readonly top_p?: number | undefined;
103
103
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
104
104
  readonly store?: boolean | undefined;
105
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
106
105
  readonly prompt_cache_key?: string | undefined;
106
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
107
107
  readonly max_output_tokens?: number | undefined;
108
108
  }, import("../route/transport/http").HttpPrepared<string>>[];
109
109
  export declare const configure: (input?: Config) => {
@@ -4,7 +4,6 @@ export interface OpenResponsesOptionsInput {
4
4
  readonly [key: string]: unknown;
5
5
  readonly instructions?: string;
6
6
  readonly store?: boolean;
7
- readonly promptCacheKey?: string;
8
7
  readonly reasoningEffort?: ReasoningEffort;
9
8
  readonly reasoningSummary?: "auto" | "concise" | "detailed";
10
9
  readonly include?: ReadonlyArray<ResponseIncludable>;
@@ -100,8 +100,8 @@ export declare const routes: import("../route").Route<{
100
100
  readonly top_p?: number | undefined;
101
101
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
102
102
  readonly store?: boolean | undefined;
103
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
104
103
  readonly prompt_cache_key?: string | undefined;
104
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
105
105
  readonly max_output_tokens?: number | undefined;
106
106
  }, import("../route/transport/http").HttpPrepared<string>>[];
107
107
  export declare const configure: (input: Config) => {
@@ -110,6 +110,7 @@ export declare const routes: import("../route").Route<{
110
110
  readonly stream_options?: {
111
111
  readonly include_usage: boolean;
112
112
  } | undefined;
113
+ readonly prompt_cache_key?: string | undefined;
113
114
  readonly reasoning_effort?: string | undefined;
114
115
  readonly frequency_penalty?: number | undefined;
115
116
  readonly presence_penalty?: number | undefined;
@@ -3,7 +3,6 @@ const definedEntries = (input) => Object.entries(input).filter((entry) => entry[
3
3
  const openAIProviderOptions = (options) => {
4
4
  const openai = Object.fromEntries(definedEntries({
5
5
  store: options?.store,
6
- promptCacheKey: options?.promptCacheKey,
7
6
  reasoningEffort: options?.reasoningEffort,
8
7
  reasoningSummary: options?.reasoningSummary,
9
8
  include: options?.include,
@@ -99,6 +99,7 @@ export declare const routes: (Route<{
99
99
  readonly stream_options?: {
100
100
  readonly include_usage: boolean;
101
101
  } | undefined;
102
+ readonly prompt_cache_key?: string | undefined;
102
103
  readonly reasoning_effort?: string | undefined;
103
104
  readonly frequency_penalty?: number | undefined;
104
105
  readonly presence_penalty?: number | undefined;
@@ -205,8 +206,8 @@ export declare const routes: (Route<{
205
206
  readonly top_p?: number | undefined;
206
207
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
207
208
  readonly store?: boolean | undefined;
208
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
209
209
  readonly prompt_cache_key?: string | undefined;
210
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
210
211
  readonly max_output_tokens?: number | undefined;
211
212
  }, import("../route/transport/http").HttpPrepared<string>> | Route<{
212
213
  readonly input: readonly ({
@@ -311,8 +312,8 @@ export declare const routes: (Route<{
311
312
  readonly top_p?: number | undefined;
312
313
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
313
314
  readonly store?: boolean | undefined;
314
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
315
315
  readonly prompt_cache_key?: string | undefined;
316
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
316
317
  readonly max_output_tokens?: number | undefined;
317
318
  }, import("../route/transport/websocket").JsonPrepared>)[];
318
319
  export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
@@ -59,7 +59,6 @@ export interface OpenRouterOptions {
59
59
  }>;
60
60
  readonly models?: ReadonlyArray<string>;
61
61
  readonly plugins?: ReadonlyArray<OpenRouterPlugin>;
62
- readonly promptCacheKey?: string;
63
62
  readonly provider?: OpenRouterProviderRouting;
64
63
  readonly reasoning?: Readonly<{
65
64
  enabled?: boolean;
@@ -172,6 +171,7 @@ declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
172
171
  readonly include_usage: Schema.Boolean;
173
172
  }>>;
174
173
  store: Schema.optional<Schema.Boolean>;
174
+ prompt_cache_key: Schema.optional<Schema.String>;
175
175
  reasoning_effort: Schema.optional<Schema.String>;
176
176
  max_completion_tokens: Schema.optional<Schema.Number>;
177
177
  max_tokens: Schema.optional<Schema.Number>;
@@ -276,6 +276,7 @@ export declare const protocol: Protocol<{
276
276
  readonly stream_options?: {
277
277
  readonly include_usage: boolean;
278
278
  } | undefined;
279
+ readonly prompt_cache_key?: string | undefined;
279
280
  readonly reasoning_effort?: string | undefined;
280
281
  readonly frequency_penalty?: number | undefined;
281
282
  readonly presence_penalty?: number | undefined;
@@ -415,6 +416,7 @@ export declare const route: Route<{
415
416
  readonly stream_options?: {
416
417
  readonly include_usage: boolean;
417
418
  } | undefined;
419
+ readonly prompt_cache_key?: string | undefined;
418
420
  readonly reasoning_effort?: string | undefined;
419
421
  readonly frequency_penalty?: number | undefined;
420
422
  readonly presence_penalty?: number | undefined;
@@ -512,6 +514,7 @@ export declare const routes: Route<{
512
514
  readonly stream_options?: {
513
515
  readonly include_usage: boolean;
514
516
  } | undefined;
517
+ readonly prompt_cache_key?: string | undefined;
515
518
  readonly reasoning_effort?: string | undefined;
516
519
  readonly frequency_penalty?: number | undefined;
517
520
  readonly presence_penalty?: number | undefined;
@@ -43,6 +43,7 @@ export const protocol = Protocol.make({
43
43
  ...body,
44
44
  messages,
45
45
  ...bodyOptions(request.providerOptions?.openrouter),
46
+ ...(request.promptCacheKey ? { prompt_cache_key: request.promptCacheKey } : {}),
46
47
  };
47
48
  })),
48
49
  },
@@ -79,7 +80,6 @@ const bodyOptions = (input) => {
79
80
  ...(isRecord(debug) ? { debug } : {}),
80
81
  ...(typeof user === "string" ? { user } : {}),
81
82
  ...(isRecord(reasoning) ? { reasoning } : {}),
82
- ...(typeof promptCacheKey === "string" ? { prompt_cache_key: promptCacheKey } : {}),
83
83
  };
84
84
  };
85
85
  export const route = Route.make({
@@ -109,6 +109,7 @@ export declare const routes: (Route<{
109
109
  readonly stream_options?: {
110
110
  readonly include_usage: boolean;
111
111
  } | undefined;
112
+ readonly prompt_cache_key?: string | undefined;
112
113
  readonly reasoning_effort?: string | undefined;
113
114
  readonly frequency_penalty?: number | undefined;
114
115
  readonly presence_penalty?: number | undefined;
@@ -215,8 +216,8 @@ export declare const routes: (Route<{
215
216
  readonly top_p?: number | undefined;
216
217
  readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
217
218
  readonly store?: boolean | undefined;
218
- readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
219
219
  readonly prompt_cache_key?: string | undefined;
220
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
220
221
  readonly max_output_tokens?: number | undefined;
221
222
  }, import("../route/transport/http").HttpPrepared<string>>)[];
222
223
  export declare const configure: (input?: LanguageModelOptions) => {
@@ -24,6 +24,7 @@ const chatRoute = Route.make({
24
24
  protocol: OpenAIChat.protocol,
25
25
  endpoint: Endpoint.path("/chat/completions", { baseURL: OpenAICompatibleProfiles.profiles.xai.baseURL }),
26
26
  transport: OpenAICompatibleChat.route.transport,
27
+ headers: ({ request }) => request.promptCacheKey ? { "x-grok-conv-id": request.promptCacheKey } : {},
27
28
  });
28
29
  export const routes = [responsesRoute, chatRoute];
29
30
  const auth = (options) => AuthOptions.bearer(options, "XAI_API_KEY");
@@ -368,6 +368,7 @@ declare const LLMRequest_base: Schema.Class<LLMRequest, Schema.Struct<{
368
368
  }>]>>;
369
369
  readonly ttlSeconds: Schema.optional<Schema.Number>;
370
370
  }>]>>;
371
+ readonly promptCacheKey: Schema.optional<Schema.String>;
371
372
  readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
372
373
  }>, {}>;
373
374
  export declare class LLMRequest extends LLMRequest_base {
@@ -211,6 +211,8 @@ export class LLMRequest extends Schema.Class("LLM.Request")({
211
211
  providerOptions: Schema.optional(ProviderOptions),
212
212
  http: Schema.optional(HttpOptions),
213
213
  cache: Schema.optional(CachePolicy),
214
+ // Stable cache affinity for protocols that support provider-managed prompt caching.
215
+ promptCacheKey: Schema.optional(Schema.String),
214
216
  metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
215
217
  }) {
216
218
  }
@@ -226,6 +228,7 @@ export class LLMRequest extends Schema.Class("LLM.Request")({
226
228
  providerOptions: request.providerOptions,
227
229
  http: request.http,
228
230
  cache: request.cache,
231
+ promptCacheKey: request.promptCacheKey,
229
232
  metadata: request.metadata,
230
233
  });
231
234
  LLMRequest.update = (request, patch) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-next-16997",
3
+ "version": "0.0.0-next-16999",
4
4
  "name": "@opencode-ai/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "devDependencies": {
31
31
  "@clack/prompts": "1.0.0-alpha.1",
32
32
  "@effect/platform-node": "4.0.0-beta.101",
33
- "@opencode-ai/http-recorder": "0.0.0-next-16997",
33
+ "@opencode-ai/http-recorder": "0.0.0-next-16999",
34
34
  "@tsconfig/bun": "1.0.9",
35
35
  "@types/bun": "1.3.13",
36
36
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@smithy/eventstream-codec": "4.2.14",
41
41
  "@smithy/util-utf8": "4.2.2",
42
- "@opencode-ai/schema": "0.0.0-next-16997",
42
+ "@opencode-ai/schema": "0.0.0-next-16999",
43
43
  "aws4fetch": "1.0.20",
44
44
  "effect": "4.0.0-beta.101",
45
45
  "google-auth-library": "10.5.0"