@opencode-ai/ai 0.0.0-beta-18219 → 0.0.0-beta-18269

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.
Files changed (32) hide show
  1. package/dist/cache-policy.js +1 -1
  2. package/dist/protocols/anthropic-messages.js +8 -4
  3. package/dist/protocols/open-responses.d.ts +231 -25
  4. package/dist/protocols/open-responses.js +98 -79
  5. package/dist/protocols/openai-chat.d.ts +1 -0
  6. package/dist/protocols/openai-chat.js +36 -17
  7. package/dist/protocols/openai-compatible-responses.d.ts +37 -3
  8. package/dist/protocols/openai-responses.d.ts +403 -50
  9. package/dist/protocols/openai-responses.js +30 -21
  10. package/dist/protocols/shared.d.ts +3 -4
  11. package/dist/protocols/shared.js +18 -5
  12. package/dist/protocols/utils/open-responses-options.d.ts +0 -1
  13. package/dist/protocols/utils/open-responses-options.js +0 -1
  14. package/dist/protocols/xai-responses.d.ts +52 -3
  15. package/dist/protocols/xai-responses.js +31 -1
  16. package/dist/provider-error.js +4 -2
  17. package/dist/providers/amazon-bedrock-mantle.d.ts +65 -3
  18. package/dist/providers/azure.d.ts +65 -3
  19. package/dist/providers/cerebras.d.ts +228 -0
  20. package/dist/providers/cerebras.js +35 -0
  21. package/dist/providers/deepinfra.d.ts +228 -0
  22. package/dist/providers/deepinfra.js +38 -0
  23. package/dist/providers/google-vertex-responses.d.ts +37 -3
  24. package/dist/providers/index.d.ts +3 -0
  25. package/dist/providers/index.js +3 -0
  26. package/dist/providers/openai-compatible-responses.d.ts +37 -3
  27. package/dist/providers/openai.d.ts +65 -3
  28. package/dist/providers/togetherai.d.ts +228 -0
  29. package/dist/providers/togetherai.js +35 -0
  30. package/dist/schema/options.d.ts +2 -0
  31. package/dist/schema/options.js +2 -0
  32. package/package.json +3 -3
@@ -162,12 +162,25 @@ export const errorText = (error) => {
162
162
  * `framing` step for Server-Sent Events. Decodes UTF-8, runs the SSE channel
163
163
  * decoder, optionally filters named events, and drops empty / `[DONE]`
164
164
  * keep-alive events so the protocol event schema sees one JSON string per
165
- * element. The SSE channel emits a
166
- * `Retry` control event on its error channel; we drop it here (we don't
167
- * implement client-driven retries). Decoder failures become provider output
168
- * errors so the public error channel stays `AIError`.
165
+ * element. Retry control events are ignored without interrupting the stream.
166
+ * Decoder failures become provider output errors so the public error channel
167
+ * stays `AIError`.
169
168
  */
170
- export const sseFraming = (bytes, events) => bytes.pipe(Stream.decodeText(), Stream.pipeThroughChannel(Sse.decode()), Stream.catchTag("Retry", () => Stream.empty), Stream.catchTag("SseError", (error) => Stream.fail(eventError("sse", error.message))), Stream.filter((event) => (events === undefined || events.has(event.event)) &&
169
+ export const sseFraming = (bytes, events) => bytes.pipe(Stream.decodeText(), Stream.mapAccumEffect(() => {
170
+ const output = [];
171
+ return {
172
+ output,
173
+ parser: Sse.makeParser((event) => {
174
+ if (event._tag === "Event")
175
+ output.push(event);
176
+ }),
177
+ };
178
+ }, (state, chunk) => Effect.gen(function* () {
179
+ const error = state.parser.feed(chunk);
180
+ if (error)
181
+ return yield* eventError("sse", error.message);
182
+ return [state, state.output.splice(0)];
183
+ })), Stream.filter((event) => (events === undefined || events.has(event.event)) &&
171
184
  event.data.length > 0 &&
172
185
  (event.data !== "[DONE]" || (events !== undefined && event.event !== "message"))), Stream.map((event) => event.data));
173
186
  /**
@@ -26,7 +26,6 @@ export declare const StreamOptions: Schema.Struct<{
26
26
  readonly includeObfuscation: Schema.optional<Schema.Boolean>;
27
27
  }>;
28
28
  export declare const Options: Schema.Struct<{
29
- readonly instructions: Schema.optional<Schema.String>;
30
29
  readonly store: Schema.optional<Schema.Boolean>;
31
30
  readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
32
31
  readonly safetyIdentifier: Schema.optional<Schema.String>;
@@ -28,7 +28,6 @@ export const StreamOptions = Schema.Struct({
28
28
  includeObfuscation: Schema.optional(Schema.Boolean),
29
29
  });
30
30
  export const Options = Schema.Struct({
31
- instructions: Schema.optional(Schema.String),
32
31
  store: Schema.optional(Schema.Boolean),
33
32
  metadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
34
33
  safetyIdentifier: Schema.optional(Schema.String),
@@ -2,6 +2,43 @@ import { Protocol } from "../route/protocol.js";
2
2
  import { OpenResponses } from "./open-responses.js";
3
3
  export declare const protocol: Protocol<{
4
4
  readonly input: readonly ({
5
+ readonly [x: string]: unknown;
6
+ readonly id: string;
7
+ readonly type: "web_search_call";
8
+ readonly status?: string | undefined;
9
+ readonly action?: {
10
+ readonly [x: string]: unknown;
11
+ } | null | undefined;
12
+ } | {
13
+ readonly [x: string]: unknown;
14
+ readonly id: string;
15
+ readonly type: "file_search_call";
16
+ readonly status?: string | undefined;
17
+ readonly queries?: readonly string[] | undefined;
18
+ readonly results?: readonly {
19
+ readonly [x: string]: unknown;
20
+ }[] | null | undefined;
21
+ } | {
22
+ readonly [x: string]: unknown;
23
+ readonly id: string;
24
+ readonly type: "code_interpreter_call";
25
+ readonly status?: string | undefined;
26
+ readonly code?: string | null | undefined;
27
+ readonly container_id?: string | null | undefined;
28
+ readonly outputs?: readonly {
29
+ readonly [x: string]: unknown;
30
+ }[] | null | undefined;
31
+ } | {
32
+ readonly [x: string]: unknown;
33
+ readonly id: string;
34
+ readonly type: "mcp_call";
35
+ readonly status?: string | undefined;
36
+ readonly name?: string | undefined;
37
+ readonly output?: string | null | undefined;
38
+ readonly error?: unknown;
39
+ readonly arguments?: string | undefined;
40
+ readonly server_label?: string | undefined;
41
+ } | {
5
42
  readonly type: "reasoning";
6
43
  readonly summary: readonly {
7
44
  readonly type: "summary_text";
@@ -9,9 +46,6 @@ export declare const protocol: Protocol<{
9
46
  }[];
10
47
  readonly id?: string | undefined;
11
48
  readonly encrypted_content?: string | null | undefined;
12
- } | {
13
- readonly type: "item_reference";
14
- readonly id: string;
15
49
  } | {
16
50
  readonly role: "system";
17
51
  readonly content: string;
@@ -65,6 +99,21 @@ export declare const protocol: Protocol<{
65
99
  readonly type: "input_video";
66
100
  readonly video_url: string;
67
101
  })[];
102
+ } | {
103
+ readonly [x: string]: unknown;
104
+ readonly id: string;
105
+ readonly type: "x_search_call";
106
+ readonly status?: string | undefined;
107
+ readonly action?: {
108
+ readonly [x: string]: unknown;
109
+ } | null | undefined;
110
+ } | {
111
+ readonly [x: string]: unknown;
112
+ readonly id: string;
113
+ readonly type: "image_generation_call";
114
+ readonly status?: string | undefined;
115
+ readonly error?: unknown;
116
+ readonly result?: unknown;
68
117
  })[];
69
118
  readonly model: string;
70
119
  readonly stream: true;
@@ -1,12 +1,39 @@
1
+ import { Effect, Schema } from "effect";
1
2
  import { Protocol } from "../route/protocol.js";
2
3
  import { OpenResponses } from "./open-responses.js";
4
+ import { JsonObject, optionalNull, ProviderShared } from "./shared.js";
3
5
  import { ResponsesHostedTools } from "./utils/responses-hosted-tools.js";
4
6
  const ADAPTER = "xai-responses";
5
7
  const NAME = "xAI Responses";
8
+ const XAIResponsesHostedToolItem = Schema.Union([
9
+ Schema.StructWithRest(Schema.Struct({
10
+ type: Schema.tag("x_search_call"),
11
+ id: Schema.String,
12
+ status: Schema.optional(Schema.String),
13
+ action: optionalNull(JsonObject),
14
+ }), [JsonObject]),
15
+ Schema.StructWithRest(Schema.Struct({
16
+ type: Schema.tag("image_generation_call"),
17
+ id: Schema.String,
18
+ status: Schema.optional(Schema.String),
19
+ result: Schema.optional(Schema.Unknown),
20
+ error: Schema.optional(Schema.Unknown),
21
+ }), [JsonObject]),
22
+ ]);
23
+ const XAIResponsesBody = Schema.Struct({
24
+ ...OpenResponses.coreFields,
25
+ input: Schema.Array(Schema.Union([OpenResponses.InputItem, XAIResponsesHostedToolItem])),
26
+ stream: Schema.Literal(true),
27
+ });
6
28
  const extension = {
7
29
  id: ADAPTER,
8
30
  name: NAME,
31
+ lowerHostedToolItem: (item) => (Schema.is(XAIResponsesHostedToolItem)(item) ? item : undefined),
9
32
  };
33
+ const decodeBody = ProviderShared.validateWith(Schema.decodeUnknownEffect(XAIResponsesBody));
34
+ const fromRequest = Effect.fn("XAIResponses.fromRequest")(function* (request) {
35
+ return yield* decodeBody(yield* OpenResponses.fromRequestWithExtension(request, extension));
36
+ });
10
37
  const HOSTED_TOOLS = {
11
38
  web_search_call: { name: "web_search", input: (item) => item.action ?? {} },
12
39
  x_search_call: { name: "x_search", input: (item) => item.action ?? {} },
@@ -30,7 +57,10 @@ const step = (state, event) => {
30
57
  };
31
58
  export const protocol = Protocol.make({
32
59
  id: ADAPTER,
33
- body: OpenResponses.protocol.body,
60
+ body: {
61
+ schema: XAIResponsesBody,
62
+ from: fromRequest,
63
+ },
34
64
  stream: {
35
65
  event: OpenResponses.protocol.stream.event,
36
66
  initial: (request) => OpenResponses.initial(request, extension),
@@ -26,11 +26,12 @@ const patterns = [
26
26
  /model_context_window_exceeded/i,
27
27
  /too many tokens/i,
28
28
  /token limit exceeded/i,
29
+ /request_too_large/i,
29
30
  ];
30
- const payloadPatterns = [/request_too_large/i, /request entity too large/i, /payload too large/i, /request too large/i];
31
+ const payloadPatterns = [/request entity too large/i, /payload too large/i, /request too large/i];
31
32
  const exclusions = [/^(throttling error|service unavailable):/i, /rate limit/i, /too many requests/i];
32
33
  export const isContextOverflow = (message) => !exclusions.some((pattern) => pattern.test(message)) &&
33
- (patterns.some((pattern) => pattern.test(message)) || /^400\s*(status code)?\s*\(no body\)/i.test(message));
34
+ (patterns.some((pattern) => pattern.test(message)) || /^4(?:00|13)\s*(status code)?\s*\(no body\)/i.test(message));
34
35
  export const isPayloadTooLarge = (message) => payloadPatterns.some((pattern) => pattern.test(message));
35
36
  export const isContextOverflowFailure = (failure) => failure instanceof AIError
36
37
  ? failure.reason._tag === "InvalidRequest" && failure.reason.classification === "context-overflow"
@@ -68,6 +69,7 @@ export function classifyProviderFailure(input) {
68
69
  if (clientScoped &&
69
70
  (codes.includes("context_length_exceeded") ||
70
71
  codes.includes("model_context_window_exceeded") ||
72
+ codes.includes("request_too_large") ||
71
73
  isContextOverflow(text)))
72
74
  return new InvalidRequestReason({ ...common, classification: "context-overflow" });
73
75
  if (input.status === 413 || isPayloadTooLarge(text))
@@ -119,6 +119,43 @@ export declare const routes: (RouteDef<{
119
119
  readonly presence_penalty?: number | undefined;
120
120
  }, import("../route/transport/http.js").HttpPrepared<string>> | RouteDef<{
121
121
  readonly input: readonly ({
122
+ readonly [x: string]: unknown;
123
+ readonly id: string;
124
+ readonly type: "web_search_call";
125
+ readonly status?: string | undefined;
126
+ readonly action?: {
127
+ readonly [x: string]: unknown;
128
+ } | null | undefined;
129
+ } | {
130
+ readonly [x: string]: unknown;
131
+ readonly id: string;
132
+ readonly type: "file_search_call";
133
+ readonly status?: string | undefined;
134
+ readonly queries?: readonly string[] | undefined;
135
+ readonly results?: readonly {
136
+ readonly [x: string]: unknown;
137
+ }[] | null | undefined;
138
+ } | {
139
+ readonly [x: string]: unknown;
140
+ readonly id: string;
141
+ readonly type: "code_interpreter_call";
142
+ readonly status?: string | undefined;
143
+ readonly code?: string | null | undefined;
144
+ readonly container_id?: string | null | undefined;
145
+ readonly outputs?: readonly {
146
+ readonly [x: string]: unknown;
147
+ }[] | null | undefined;
148
+ } | {
149
+ readonly [x: string]: unknown;
150
+ readonly id: string;
151
+ readonly type: "mcp_call";
152
+ readonly status?: string | undefined;
153
+ readonly name?: string | undefined;
154
+ readonly output?: string | null | undefined;
155
+ readonly error?: unknown;
156
+ readonly arguments?: string | undefined;
157
+ readonly server_label?: string | undefined;
158
+ } | {
122
159
  readonly type: "reasoning";
123
160
  readonly summary: readonly {
124
161
  readonly type: "summary_text";
@@ -126,9 +163,6 @@ export declare const routes: (RouteDef<{
126
163
  }[];
127
164
  readonly id?: string | undefined;
128
165
  readonly encrypted_content?: string | null | undefined;
129
- } | {
130
- readonly type: "item_reference";
131
- readonly id: string;
132
166
  } | {
133
167
  readonly role: "system";
134
168
  readonly content: string;
@@ -182,6 +216,34 @@ export declare const routes: (RouteDef<{
182
216
  readonly type: "input_video";
183
217
  readonly video_url: string;
184
218
  })[];
219
+ } | {
220
+ readonly [x: string]: unknown;
221
+ readonly id: string;
222
+ readonly type: "computer_call";
223
+ readonly status?: string | undefined;
224
+ readonly action?: {
225
+ readonly [x: string]: unknown;
226
+ } | null | undefined;
227
+ readonly call_id?: string | undefined;
228
+ readonly pending_safety_checks?: readonly {
229
+ readonly [x: string]: unknown;
230
+ }[] | undefined;
231
+ } | {
232
+ readonly [x: string]: unknown;
233
+ readonly id: string;
234
+ readonly type: "web_search_preview_call";
235
+ readonly status?: string | undefined;
236
+ readonly action?: {
237
+ readonly [x: string]: unknown;
238
+ } | null | undefined;
239
+ } | {
240
+ readonly [x: string]: unknown;
241
+ readonly id: string;
242
+ readonly type: "image_generation_call";
243
+ readonly status?: string | undefined;
244
+ readonly result?: string | null | undefined;
245
+ readonly revised_prompt?: string | null | undefined;
246
+ readonly output_format?: "png" | "jpeg" | "webp" | undefined;
185
247
  })[];
186
248
  readonly model: string;
187
249
  readonly stream: true;
@@ -122,6 +122,43 @@ export declare const routes: (RouteDef<{
122
122
  readonly presence_penalty?: number | undefined;
123
123
  }, import("../route/transport/http.js").HttpPrepared<string>> | RouteDef<{
124
124
  readonly input: readonly ({
125
+ readonly [x: string]: unknown;
126
+ readonly id: string;
127
+ readonly type: "web_search_call";
128
+ readonly status?: string | undefined;
129
+ readonly action?: {
130
+ readonly [x: string]: unknown;
131
+ } | null | undefined;
132
+ } | {
133
+ readonly [x: string]: unknown;
134
+ readonly id: string;
135
+ readonly type: "file_search_call";
136
+ readonly status?: string | undefined;
137
+ readonly queries?: readonly string[] | undefined;
138
+ readonly results?: readonly {
139
+ readonly [x: string]: unknown;
140
+ }[] | null | undefined;
141
+ } | {
142
+ readonly [x: string]: unknown;
143
+ readonly id: string;
144
+ readonly type: "code_interpreter_call";
145
+ readonly status?: string | undefined;
146
+ readonly code?: string | null | undefined;
147
+ readonly container_id?: string | null | undefined;
148
+ readonly outputs?: readonly {
149
+ readonly [x: string]: unknown;
150
+ }[] | null | undefined;
151
+ } | {
152
+ readonly [x: string]: unknown;
153
+ readonly id: string;
154
+ readonly type: "mcp_call";
155
+ readonly status?: string | undefined;
156
+ readonly name?: string | undefined;
157
+ readonly output?: string | null | undefined;
158
+ readonly error?: unknown;
159
+ readonly arguments?: string | undefined;
160
+ readonly server_label?: string | undefined;
161
+ } | {
125
162
  readonly type: "reasoning";
126
163
  readonly summary: readonly {
127
164
  readonly type: "summary_text";
@@ -129,9 +166,6 @@ export declare const routes: (RouteDef<{
129
166
  }[];
130
167
  readonly id?: string | undefined;
131
168
  readonly encrypted_content?: string | null | undefined;
132
- } | {
133
- readonly type: "item_reference";
134
- readonly id: string;
135
169
  } | {
136
170
  readonly role: "system";
137
171
  readonly content: string;
@@ -185,6 +219,34 @@ export declare const routes: (RouteDef<{
185
219
  readonly type: "input_video";
186
220
  readonly video_url: string;
187
221
  })[];
222
+ } | {
223
+ readonly [x: string]: unknown;
224
+ readonly id: string;
225
+ readonly type: "computer_call";
226
+ readonly status?: string | undefined;
227
+ readonly action?: {
228
+ readonly [x: string]: unknown;
229
+ } | null | undefined;
230
+ readonly call_id?: string | undefined;
231
+ readonly pending_safety_checks?: readonly {
232
+ readonly [x: string]: unknown;
233
+ }[] | undefined;
234
+ } | {
235
+ readonly [x: string]: unknown;
236
+ readonly id: string;
237
+ readonly type: "web_search_preview_call";
238
+ readonly status?: string | undefined;
239
+ readonly action?: {
240
+ readonly [x: string]: unknown;
241
+ } | null | undefined;
242
+ } | {
243
+ readonly [x: string]: unknown;
244
+ readonly id: string;
245
+ readonly type: "image_generation_call";
246
+ readonly status?: string | undefined;
247
+ readonly result?: string | null | undefined;
248
+ readonly revised_prompt?: string | null | undefined;
249
+ readonly output_format?: "png" | "jpeg" | "webp" | undefined;
188
250
  })[];
189
251
  readonly model: string;
190
252
  readonly stream: true;
@@ -0,0 +1,228 @@
1
+ import type { ProviderPackage } from "../provider-package.js";
2
+ import { type ProviderAuthOption } from "../route/auth-options.js";
3
+ import type { RouteDefaultsInput } from "../route/client.js";
4
+ import { type ModelID } from "../schema/index.js";
5
+ import type { OpenAIProviderOptionsInput } from "./openai-options.js";
6
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
+ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
8
+ readonly baseURL?: string;
9
+ readonly providerOptions?: OpenAIProviderOptionsInput;
10
+ };
11
+ export interface Settings extends ProviderPackage.Settings {
12
+ readonly apiKey?: string;
13
+ readonly baseURL?: string;
14
+ readonly providerOptions?: OpenAIProviderOptionsInput;
15
+ }
16
+ export declare const route: import("../route/client.js").Route<{
17
+ readonly model: string;
18
+ readonly messages: readonly ({
19
+ readonly role: "system";
20
+ readonly content: string | readonly ({
21
+ readonly type: "text";
22
+ readonly text: string;
23
+ readonly cache_control?: {
24
+ readonly type: "ephemeral";
25
+ readonly ttl?: string | undefined;
26
+ } | undefined;
27
+ } | {
28
+ readonly type: "image_url";
29
+ readonly image_url: {
30
+ readonly url: string;
31
+ };
32
+ })[];
33
+ } | {
34
+ readonly role: "user";
35
+ readonly content: string | readonly ({
36
+ readonly type: "text";
37
+ readonly text: string;
38
+ readonly cache_control?: {
39
+ readonly type: "ephemeral";
40
+ readonly ttl?: string | undefined;
41
+ } | undefined;
42
+ } | {
43
+ readonly type: "image_url";
44
+ readonly image_url: {
45
+ readonly url: string;
46
+ };
47
+ })[];
48
+ } | {
49
+ readonly [x: string]: unknown;
50
+ readonly content: string | null;
51
+ readonly role: "assistant";
52
+ readonly reasoning?: string | undefined;
53
+ readonly reasoning_content?: string | undefined;
54
+ readonly reasoning_text?: string | undefined;
55
+ readonly cache_control?: {
56
+ readonly type: "ephemeral";
57
+ readonly ttl?: string | undefined;
58
+ } | undefined;
59
+ readonly tool_calls?: readonly {
60
+ readonly id: string;
61
+ readonly type: "function";
62
+ readonly function: {
63
+ readonly name: string;
64
+ readonly arguments: string;
65
+ };
66
+ }[] | undefined;
67
+ readonly reasoning_details?: unknown;
68
+ } | {
69
+ readonly content: string;
70
+ readonly role: "tool";
71
+ readonly tool_call_id: string;
72
+ readonly cache_control?: {
73
+ readonly type: "ephemeral";
74
+ readonly ttl?: string | undefined;
75
+ } | undefined;
76
+ })[];
77
+ readonly stream: true;
78
+ readonly max_completion_tokens?: number | undefined;
79
+ readonly max_tokens?: number | undefined;
80
+ readonly tools?: readonly {
81
+ readonly function: {
82
+ readonly description: string;
83
+ readonly name: string;
84
+ readonly parameters: {
85
+ readonly [x: string]: unknown;
86
+ };
87
+ readonly strict?: boolean | undefined;
88
+ };
89
+ readonly type: "function";
90
+ readonly cache_control?: {
91
+ readonly type: "ephemeral";
92
+ readonly ttl?: string | undefined;
93
+ } | undefined;
94
+ }[] | undefined;
95
+ readonly stop?: readonly string[] | undefined;
96
+ readonly temperature?: number | undefined;
97
+ readonly seed?: number | undefined;
98
+ readonly tool_choice?: "required" | "auto" | "none" | {
99
+ readonly type: "function";
100
+ readonly function: {
101
+ readonly name: string;
102
+ };
103
+ } | undefined;
104
+ readonly top_p?: number | undefined;
105
+ readonly store?: boolean | undefined;
106
+ readonly stream_options?: {
107
+ readonly include_usage: boolean;
108
+ } | undefined;
109
+ readonly prompt_cache_key?: string | undefined;
110
+ readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
111
+ readonly tool_stream?: boolean | undefined;
112
+ readonly frequency_penalty?: number | undefined;
113
+ readonly presence_penalty?: number | undefined;
114
+ }, import("../route/transport/http.js").HttpPrepared<string>>;
115
+ export declare const routes: import("../route/client.js").Route<{
116
+ readonly model: string;
117
+ readonly messages: readonly ({
118
+ readonly role: "system";
119
+ readonly content: string | readonly ({
120
+ readonly type: "text";
121
+ readonly text: string;
122
+ readonly cache_control?: {
123
+ readonly type: "ephemeral";
124
+ readonly ttl?: string | undefined;
125
+ } | undefined;
126
+ } | {
127
+ readonly type: "image_url";
128
+ readonly image_url: {
129
+ readonly url: string;
130
+ };
131
+ })[];
132
+ } | {
133
+ readonly role: "user";
134
+ readonly content: string | readonly ({
135
+ readonly type: "text";
136
+ readonly text: string;
137
+ readonly cache_control?: {
138
+ readonly type: "ephemeral";
139
+ readonly ttl?: string | undefined;
140
+ } | undefined;
141
+ } | {
142
+ readonly type: "image_url";
143
+ readonly image_url: {
144
+ readonly url: string;
145
+ };
146
+ })[];
147
+ } | {
148
+ readonly [x: string]: unknown;
149
+ readonly content: string | null;
150
+ readonly role: "assistant";
151
+ readonly reasoning?: string | undefined;
152
+ readonly reasoning_content?: string | undefined;
153
+ readonly reasoning_text?: string | undefined;
154
+ readonly cache_control?: {
155
+ readonly type: "ephemeral";
156
+ readonly ttl?: string | undefined;
157
+ } | undefined;
158
+ readonly tool_calls?: readonly {
159
+ readonly id: string;
160
+ readonly type: "function";
161
+ readonly function: {
162
+ readonly name: string;
163
+ readonly arguments: string;
164
+ };
165
+ }[] | undefined;
166
+ readonly reasoning_details?: unknown;
167
+ } | {
168
+ readonly content: string;
169
+ readonly role: "tool";
170
+ readonly tool_call_id: string;
171
+ readonly cache_control?: {
172
+ readonly type: "ephemeral";
173
+ readonly ttl?: string | undefined;
174
+ } | undefined;
175
+ })[];
176
+ readonly stream: true;
177
+ readonly max_completion_tokens?: number | undefined;
178
+ readonly max_tokens?: number | undefined;
179
+ readonly tools?: readonly {
180
+ readonly function: {
181
+ readonly description: string;
182
+ readonly name: string;
183
+ readonly parameters: {
184
+ readonly [x: string]: unknown;
185
+ };
186
+ readonly strict?: boolean | undefined;
187
+ };
188
+ readonly type: "function";
189
+ readonly cache_control?: {
190
+ readonly type: "ephemeral";
191
+ readonly ttl?: string | undefined;
192
+ } | undefined;
193
+ }[] | undefined;
194
+ readonly stop?: readonly string[] | undefined;
195
+ readonly temperature?: number | undefined;
196
+ readonly seed?: number | undefined;
197
+ readonly tool_choice?: "required" | "auto" | "none" | {
198
+ readonly type: "function";
199
+ readonly function: {
200
+ readonly name: string;
201
+ };
202
+ } | undefined;
203
+ readonly top_p?: number | undefined;
204
+ readonly store?: boolean | undefined;
205
+ readonly stream_options?: {
206
+ readonly include_usage: boolean;
207
+ } | undefined;
208
+ readonly prompt_cache_key?: string | undefined;
209
+ readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
210
+ readonly tool_stream?: boolean | undefined;
211
+ readonly frequency_penalty?: number | undefined;
212
+ readonly presence_penalty?: number | undefined;
213
+ }, import("../route/transport/http.js").HttpPrepared<string>>[];
214
+ export declare const configure: (input?: LanguageModelOptions) => {
215
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
216
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
217
+ configure: (input?: LanguageModelOptions) => /*elided*/ any;
218
+ };
219
+ export declare const provider: {
220
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
221
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
222
+ configure: (input?: LanguageModelOptions) => {
223
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
224
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
225
+ configure: /*elided*/ any;
226
+ };
227
+ };
228
+ export declare const model: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
@@ -0,0 +1,35 @@
1
+ import { OpenAICompatibleChat } from "../protocols/openai-compatible-chat.js";
2
+ import { AuthOptions } from "../route/auth-options.js";
3
+ import { ProviderID } from "../schema/index.js";
4
+ import { profiles } from "./openai-compatible-profile.js";
5
+ export const id = ProviderID.make("cerebras");
6
+ export const route = OpenAICompatibleChat.route.with({
7
+ id: "cerebras-chat",
8
+ provider: id,
9
+ endpoint: { baseURL: profiles.cerebras.baseURL },
10
+ });
11
+ export const routes = [route];
12
+ export const configure = (input = {}) => {
13
+ const { apiKey: _apiKey, auth: _auth, baseURL, ...defaults } = input;
14
+ const configured = route.with({
15
+ ...defaults,
16
+ endpoint: { baseURL: baseURL ?? profiles.cerebras.baseURL },
17
+ auth: AuthOptions.bearer(input, "CEREBRAS_API_KEY"),
18
+ });
19
+ return {
20
+ id,
21
+ model: (modelID) => configured.model({
22
+ id: modelID,
23
+ compatibility: { maxTokensField: "max_tokens", reasoningField: "reasoning", supportsStore: false },
24
+ }),
25
+ configure,
26
+ };
27
+ };
28
+ export const provider = configure();
29
+ export const model = (modelID, settings) => configure({
30
+ apiKey: settings.apiKey,
31
+ baseURL: settings.baseURL,
32
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
33
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
34
+ providerOptions: settings.providerOptions,
35
+ }).model(modelID);