@opencode/ai 0.0.0-dev-1311 → 0.0.0-dev-1313

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 (58) hide show
  1. package/dist/decision.d.ts +4 -3
  2. package/dist/decision.js +3 -2
  3. package/dist/embedding.d.ts +4 -3
  4. package/dist/embedding.js +3 -2
  5. package/dist/experimental/cloudflare-run-extraction.js +1 -2
  6. package/dist/experimental/realtime.d.ts +2 -1
  7. package/dist/experimental/realtime.js +8 -8
  8. package/dist/image.js +1 -1
  9. package/dist/media-model.d.ts +5 -4
  10. package/dist/media-model.js +5 -4
  11. package/dist/media.js +4 -17
  12. package/dist/protocols/open-responses-continuation.js +2 -0
  13. package/dist/protocols/utils/responses-compaction.js +3 -3
  14. package/dist/providers/alibaba.js +2 -3
  15. package/dist/providers/assemblyai.d.ts +2 -4
  16. package/dist/providers/azure.js +5 -11
  17. package/dist/providers/baseten.js +2 -3
  18. package/dist/providers/byteplus.d.ts +2 -4
  19. package/dist/providers/cartesia.d.ts +2 -4
  20. package/dist/providers/cloudflare-ai-gateway.js +3 -3
  21. package/dist/providers/cloudflare-workers-ai.js +2 -3
  22. package/dist/providers/cohere.js +2 -3
  23. package/dist/providers/deepgram.d.ts +2 -4
  24. package/dist/providers/deepinfra.js +2 -3
  25. package/dist/providers/digitalocean.js +3 -5
  26. package/dist/providers/elevenlabs.d.ts +2 -4
  27. package/dist/providers/fireworks.js +2 -3
  28. package/dist/providers/google-vertex.js +6 -2
  29. package/dist/providers/google.js +7 -4
  30. package/dist/providers/openai-compatible.js +3 -5
  31. package/dist/providers/openai.js +4 -10
  32. package/dist/providers/opencode.d.ts +2 -4
  33. package/dist/providers/opencode.js +2 -3
  34. package/dist/providers/openrouter.js +3 -5
  35. package/dist/providers/typesafe-ai.d.ts +2 -4
  36. package/dist/providers/typesafe-ai.js +2 -3
  37. package/dist/providers/vercel-ai-gateway.js +3 -5
  38. package/dist/providers/volcengine.d.ts +2 -4
  39. package/dist/route/decision.d.ts +4 -7
  40. package/dist/route/decision.js +8 -10
  41. package/dist/route/embedding.d.ts +4 -7
  42. package/dist/route/embedding.js +4 -7
  43. package/dist/route/executor-service.d.ts +20 -3
  44. package/dist/route/executor-service.js +72 -2
  45. package/dist/route/executor.d.ts +5 -5
  46. package/dist/route/executor.js +68 -73
  47. package/dist/route/media-protocol.d.ts +2 -1
  48. package/dist/route/media-protocol.js +2 -10
  49. package/dist/route/media.d.ts +6 -8
  50. package/dist/route/media.js +8 -8
  51. package/dist/route/transport/http.d.ts +1 -2
  52. package/dist/route/transport/http.js +5 -28
  53. package/dist/schema/errors.js +2 -1
  54. package/dist/schema/options.d.ts +1 -1
  55. package/dist/speech.js +1 -1
  56. package/dist/transcription.js +1 -1
  57. package/dist/video.js +1 -1
  58. package/package.json +3 -3
@@ -1,7 +1,7 @@
1
1
  import { Effect, Schema } from "effect";
2
2
  import { Service, type Execute } from "./decision-client.js";
3
3
  import { Media } from "./media.js";
4
- import { AIError, type BaseRequest, type HttpOptions, ModelID, ProviderID, ProviderOptions, type OpenString } from "./schema/index.js";
4
+ import { AIError, type BaseRequest, type TransportOptions, ModelID, ProviderID, ProviderOptions, type OpenString } from "./schema/index.js";
5
5
  export declare const DecisionTextPart: Schema.Struct<{
6
6
  readonly type: Schema.Literal<"text">;
7
7
  readonly text: Schema.String;
@@ -285,7 +285,8 @@ export declare class DecisionModel<Options extends DecisionOptions = DecisionOpt
285
285
  readonly id: ModelID;
286
286
  readonly provider: ProviderID;
287
287
  readonly route: DecisionModelRoute<Options>;
288
- readonly http?: HttpOptions;
288
+ /** Deployment headers, timeouts and `http` overlays, below each request's own. */
289
+ readonly transport?: TransportOptions;
289
290
  readonly compatibility?: DecisionModelCompatibility;
290
291
  /** Defaults under each request's `providerOptions`, such as options a provider package reads from its settings. */
291
292
  readonly providerOptions?: ProviderOptions;
@@ -297,7 +298,7 @@ export declare namespace DecisionModel {
297
298
  readonly id: ModelID;
298
299
  readonly provider: ProviderID;
299
300
  readonly route: DecisionModelRoute<Options>;
300
- readonly http?: HttpOptions;
301
+ readonly transport?: TransportOptions;
301
302
  readonly compatibility?: DecisionModelCompatibility;
302
303
  readonly providerOptions?: ProviderOptions;
303
304
  }
package/dist/decision.js CHANGED
@@ -93,7 +93,8 @@ export class DecisionModel {
93
93
  id;
94
94
  provider;
95
95
  route;
96
- http;
96
+ /** Deployment headers, timeouts and `http` overlays, below each request's own. */
97
+ transport;
97
98
  compatibility;
98
99
  /** Defaults under each request's `providerOptions`, such as options a provider package reads from its settings. */
99
100
  providerOptions;
@@ -101,7 +102,7 @@ export class DecisionModel {
101
102
  this.id = input.id;
102
103
  this.provider = input.provider;
103
104
  this.route = input.route;
104
- this.http = input.http;
105
+ this.transport = input.transport;
105
106
  this.compatibility = input.compatibility;
106
107
  this.providerOptions = input.providerOptions;
107
108
  }
@@ -1,7 +1,7 @@
1
1
  import { Effect, Schema } from "effect";
2
2
  import { Service, type Execute } from "./embedding-client.js";
3
3
  import { Media } from "./media.js";
4
- import { type AIError, type BaseRequest, type HttpOptions, ModelID, ProviderID, ProviderOptions } from "./schema/index.js";
4
+ import { type AIError, type BaseRequest, type TransportOptions, ModelID, ProviderID, ProviderOptions } from "./schema/index.js";
5
5
  /** One value to embed: text, or a media asset for hosts that embed images, audio or documents. */
6
6
  export declare const EmbeddingValue: Schema.Union<readonly [Schema.String, Schema.decodeTo<Schema.declare<Media.Asset, Media.Asset>, Schema.Struct<{
7
7
  readonly source: Schema.Union<readonly [Schema.Struct<{
@@ -53,7 +53,8 @@ export declare class EmbeddingModel<Options extends EmbeddingOptions = Embedding
53
53
  readonly id: ModelID;
54
54
  readonly provider: ProviderID;
55
55
  readonly route: EmbeddingModelRoute<Options>;
56
- readonly http?: HttpOptions;
56
+ /** Deployment headers, timeouts and `http` overlays, below each request's own. */
57
+ readonly transport?: TransportOptions;
57
58
  /** Defaults under each request's `providerOptions`, such as options a provider package reads from its settings. */
58
59
  readonly providerOptions?: ProviderOptions;
59
60
  constructor(input: EmbeddingModel.Input<Options>);
@@ -64,7 +65,7 @@ export declare namespace EmbeddingModel {
64
65
  readonly id: ModelID;
65
66
  readonly provider: ProviderID;
66
67
  readonly route: EmbeddingModelRoute<Options>;
67
- readonly http?: HttpOptions;
68
+ readonly transport?: TransportOptions;
68
69
  readonly providerOptions?: ProviderOptions;
69
70
  }
70
71
  interface MakeInput<Options extends EmbeddingOptions = EmbeddingOptions> extends Omit<Input<Options>, "id" | "provider"> {
package/dist/embedding.js CHANGED
@@ -12,14 +12,15 @@ export class EmbeddingModel {
12
12
  id;
13
13
  provider;
14
14
  route;
15
- http;
15
+ /** Deployment headers, timeouts and `http` overlays, below each request's own. */
16
+ transport;
16
17
  /** Defaults under each request's `providerOptions`, such as options a provider package reads from its settings. */
17
18
  providerOptions;
18
19
  constructor(input) {
19
20
  this.id = input.id;
20
21
  this.provider = input.provider;
21
22
  this.route = input.route;
22
- this.http = input.http;
23
+ this.transport = input.transport;
23
24
  this.providerOptions = input.providerOptions;
24
25
  }
25
26
  static make(input) {
@@ -73,14 +73,13 @@ export const protocol = MediaProtocol.inline(route, {
73
73
  export const model = (input) => new ExtractionModel({
74
74
  id: input.id,
75
75
  provider: route.provider,
76
- http: input.http,
76
+ transport: input.transport,
77
77
  route: MediaRoute.inline({
78
78
  protocol,
79
79
  endpoint: Endpoint.path(({ request }) => `/${request.model.id}`, {
80
80
  baseURL: input.baseURL,
81
81
  }),
82
82
  auth: input.auth,
83
- headers: input.headers,
84
83
  }),
85
84
  });
86
85
  export const CloudflareRunExtraction = { protocol, model };
@@ -1,6 +1,6 @@
1
1
  import { Effect, Redacted } from "effect";
2
2
  import { RequestExecutor } from "../route/executor.js";
3
- import { AIError } from "../schema/index.js";
3
+ import { AIError, type RequestTimeout } from "../schema/index.js";
4
4
  export type RealtimeTransportInput = {
5
5
  readonly type: "webrtc";
6
6
  readonly sdp: string;
@@ -26,6 +26,7 @@ export interface RealtimeConnectInput {
26
26
  readonly baseURL?: string;
27
27
  /** Headers that host needs besides the API key, such as OpenCode's workspace. */
28
28
  readonly headers?: Readonly<Record<string, string>>;
29
+ readonly timeout?: RequestTimeout;
29
30
  readonly session?: RealtimeSession;
30
31
  readonly transport: RealtimeTransportInput;
31
32
  }
@@ -35,7 +35,7 @@ export const connect = Effect.fn("Realtime.connect")(function* (input) {
35
35
  const session = { ...input.session, model: input.model };
36
36
  switch (resolved.id) {
37
37
  case "openai-live": {
38
- const data = yield* post(resolved.id, `${input.baseURL ?? OPENAI_BASE_URL}/live/sessions`, input.apiKey, { session, transport: input.transport }, LiveSessionResponse, { headers: input.headers });
38
+ const data = yield* post(resolved.id, `${input.baseURL ?? OPENAI_BASE_URL}/live/sessions`, input.apiKey, { session, transport: input.transport }, LiveSessionResponse, { headers: input.headers, timeout: input.timeout });
39
39
  return { type: "webrtc", sdp: data.transport.sdp };
40
40
  }
41
41
  case "openai-realtime": {
@@ -43,18 +43,18 @@ export const connect = Effect.fn("Realtime.connect")(function* (input) {
43
43
  return yield* clientSecret(resolved.id, OPENAI_BASE_URL, input.model, input.apiKey, {
44
44
  expires_after: { anchor: "created_at", seconds: 60 },
45
45
  session,
46
- });
46
+ }, input.timeout);
47
47
  const form = new FormData();
48
48
  form.append("sdp", input.transport.sdp);
49
49
  form.append("session", encodeJson(session));
50
50
  const query = input.transport.dcid === undefined ? "" : `?dcid=${input.transport.dcid}`;
51
- const sdp = yield* post(resolved.id, `${OPENAI_BASE_URL}/realtime/calls${query}`, input.apiKey, form, Schema.String);
51
+ const sdp = yield* post(resolved.id, `${OPENAI_BASE_URL}/realtime/calls${query}`, input.apiKey, form, Schema.String, { timeout: input.timeout });
52
52
  return { type: "webrtc", sdp };
53
53
  }
54
54
  case "xai-realtime":
55
55
  return yield* clientSecret(resolved.id, XAI_BASE_URL, input.model, input.apiKey, {
56
56
  expires_after: { seconds: 60 },
57
- });
57
+ }, input.timeout);
58
58
  case "gemini-live": {
59
59
  const now = yield* Clock.currentTimeMillis;
60
60
  const expiresAt = now + 60_000;
@@ -63,7 +63,7 @@ export const connect = Effect.fn("Realtime.connect")(function* (input) {
63
63
  expireTime: new Date(now + 30 * 60_000).toISOString(),
64
64
  newSessionExpireTime: new Date(expiresAt).toISOString(),
65
65
  bidiGenerateContentSetup: { ...input.session, model: `models/${input.model}` },
66
- }, AuthTokenResponse, { authHeader: "x-goog-api-key" });
66
+ }, AuthTokenResponse, { authHeader: "x-goog-api-key", timeout: input.timeout });
67
67
  return {
68
68
  type: "websocket",
69
69
  url: "wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContentConstrained",
@@ -94,17 +94,17 @@ const AuthTokenResponse = Schema.fromJsonString(Schema.Struct({
94
94
  const invalidRequest = (message) => new AIError({ reason: new InvalidRequestError({ message }) });
95
95
  const post = (route, url, apiKey, body, response, options = {}) => Effect.gen(function* () {
96
96
  const executor = yield* RequestExecutor.Service;
97
- const res = yield* executor.execute(HttpClientRequest.post(url).pipe(HttpClientRequest.setHeaders(options.headers ?? {}), options.authHeader
97
+ const res = yield* RequestExecutor.withTimeout(executor.execute, options.timeout)(HttpClientRequest.post(url).pipe(HttpClientRequest.setHeaders(options.headers ?? {}), options.authHeader
98
98
  ? HttpClientRequest.setHeader(options.authHeader, Redacted.value(apiKey))
99
99
  : HttpClientRequest.bearerToken(apiKey), body instanceof FormData
100
100
  ? HttpClientRequest.bodyFormData(body)
101
101
  : HttpClientRequest.bodyText(encodeJson(body), "application/json")));
102
102
  const http = RequestExecutor.responseHttp(res);
103
103
  const fail = (message, cause, raw) => new AIError({ reason: new InvalidProviderOutputError({ route, message, body: raw, http, cause }) });
104
- const text = yield* res.text.pipe(Effect.mapError((cause) => fail(`Failed to read ${route} response`, cause)));
104
+ const text = yield* RequestExecutor.responseText(res);
105
105
  return yield* Schema.decodeEffect(response)(text).pipe(Effect.mapError((cause) => fail(`${route} returned an invalid response`, cause, text)));
106
106
  });
107
- const clientSecret = (route, baseURL, model, apiKey, body) => post(route, `${baseURL}/realtime/client_secrets`, apiKey, body, ClientSecretResponse).pipe(Effect.map((data) => ({
107
+ const clientSecret = (route, baseURL, model, apiKey, body, timeout) => post(route, `${baseURL}/realtime/client_secrets`, apiKey, body, ClientSecretResponse, { timeout }).pipe(Effect.map((data) => ({
108
108
  type: "websocket",
109
109
  url: `${baseURL.replace(/^http/, "ws")}/realtime?model=${encodeURIComponent(model)}`,
110
110
  token: data.value,
package/dist/image.js CHANGED
@@ -10,7 +10,7 @@ export class ImageModel extends MediaModel {
10
10
  return new ImageModel({
11
11
  id: input.id,
12
12
  provider: route.protocol.provider,
13
- http: input.http,
13
+ transport: input.transport,
14
14
  providerOptions: input.providerOptions,
15
15
  route: composeRoute(route, input, collectResponse),
16
16
  });
@@ -2,9 +2,9 @@ import { Effect } from "effect";
2
2
  import { Endpoint } from "./route/endpoint.js";
3
3
  import { MediaRoute } from "./route/media.js";
4
4
  import type { MediaProtocol } from "./route/media-protocol.js";
5
- import { AIError, ModelID, ProviderID, type HttpOptions, type ProviderOptions } from "./schema/index.js";
5
+ import { AIError, ModelID, ProviderID, type ProviderOptions, type TransportOptions } from "./schema/index.js";
6
6
  /**
7
- * What every media model carries: ids, the configured route, and deployment `http` overlays. Modality classes
7
+ * What every media model carries: ids, the configured route, and deployment transport overlays. Modality classes
8
8
  * (`ImageModel`, `VideoModel`, `SpeechModel`, `TranscriptionModel`) extend it with their route type and a nominal
9
9
  * marker so one cannot stand in for the other in requests.
10
10
  */
@@ -13,7 +13,8 @@ export declare class MediaModel<Route, Options> {
13
13
  readonly id: ModelID;
14
14
  readonly provider: ProviderID;
15
15
  readonly route: Route;
16
- readonly http?: HttpOptions;
16
+ /** Deployment headers, timeouts and `http` overlays, below each request's own. */
17
+ readonly transport?: TransportOptions;
17
18
  /** Defaults under each request's `providerOptions`, such as options a provider package reads from its settings. */
18
19
  readonly providerOptions?: ProviderOptions;
19
20
  constructor(input: MediaModel.Input<Route>);
@@ -24,7 +25,7 @@ export declare namespace MediaModel {
24
25
  readonly id: string | ModelID;
25
26
  readonly provider: string | ProviderID;
26
27
  readonly route: Route;
27
- readonly http?: HttpOptions;
28
+ readonly transport?: TransportOptions;
28
29
  readonly providerOptions?: ProviderOptions;
29
30
  }
30
31
  /** A protocol plus its canonical start path; `ModelInput.baseURL` overrides `baseURL` per deployment. */
@@ -3,7 +3,7 @@ import { Endpoint } from "./route/endpoint.js";
3
3
  import { MediaRoute } from "./route/media.js";
4
4
  import { AIError, InvalidRequestError, ModelID, ProviderID, } from "./schema/index.js";
5
5
  /**
6
- * What every media model carries: ids, the configured route, and deployment `http` overlays. Modality classes
6
+ * What every media model carries: ids, the configured route, and deployment transport overlays. Modality classes
7
7
  * (`ImageModel`, `VideoModel`, `SpeechModel`, `TranscriptionModel`) extend it with their route type and a nominal
8
8
  * marker so one cannot stand in for the other in requests.
9
9
  */
@@ -11,14 +11,15 @@ export class MediaModel {
11
11
  id;
12
12
  provider;
13
13
  route;
14
- http;
14
+ /** Deployment headers, timeouts and `http` overlays, below each request's own. */
15
+ transport;
15
16
  /** Defaults under each request's `providerOptions`, such as options a provider package reads from its settings. */
16
17
  providerOptions;
17
18
  constructor(input) {
18
19
  this.id = ModelID.make(input.id);
19
20
  this.provider = ProviderID.make(input.provider);
20
21
  this.route = input.route;
21
- this.http = input.http;
22
+ this.transport = input.transport;
22
23
  this.providerOptions = input.providerOptions;
23
24
  }
24
25
  }
@@ -36,7 +37,7 @@ const composition = (route, input) => ({
36
37
  protocol: route.protocol,
37
38
  endpoint: Endpoint.path(route.path, { baseURL: input.baseURL ?? route.baseURL }),
38
39
  auth: input.auth,
39
- headers: route.headers === undefined && input.headers === undefined ? undefined : { ...route.headers, ...input.headers },
40
+ headers: route.headers,
40
41
  });
41
42
  const isStreamInput = (route) => route.protocol.kind === "stream";
42
43
  const isQueuedInput = (route) => route.protocol.kind === "queued";
package/dist/media.js CHANGED
@@ -3,9 +3,9 @@ import { Effect, FileSystem, Result, Schema, SchemaGetter, Stream } from "effect
3
3
  import { Base64 } from "effect/encoding";
4
4
  import { HttpClientRequest } from "effect/http";
5
5
  import { ProviderID } from "./schema/ids.js";
6
- import { AIError, InvalidProviderOutputError, InvalidRequestError } from "./schema/errors.js";
6
+ import { AIError, InvalidRequestError } from "./schema/errors.js";
7
7
  import { ProviderMetadata } from "./schema/options.js";
8
- import { CurrentMiddleware, responseHttp, Service } from "./route/executor-service.js";
8
+ import { CurrentMiddleware, responseBytes, responseStream, Service, } from "./route/executor-service.js";
9
9
  import { detectMediaType, fileMediaType } from "./utils/media-type.js";
10
10
  export { detectMediaType } from "./utils/media-type.js";
11
11
  const OCTET_STREAM = "application/octet-stream";
@@ -193,27 +193,14 @@ const download = Effect.fn("Media.download")(function* (source, headers, middlew
193
193
  const response = yield* executor
194
194
  .execute(HttpClientRequest.get(source.url).pipe(HttpClientRequest.setHeaders(headers ?? {})))
195
195
  .pipe(Effect.provideService(CurrentMiddleware, middleware));
196
- const buffer = yield* response.arrayBuffer.pipe(Effect.mapError((cause) => new AIError({
197
- reason: new InvalidProviderOutputError({
198
- message: `Failed to read media from ${source.url}`,
199
- http: responseHttp(response),
200
- cause,
201
- }),
202
- })));
203
- return new Uint8Array(buffer);
196
+ return yield* responseBytes(response);
204
197
  });
205
198
  const downloadStream = Effect.fn("Media.downloadStream")(function* (source, headers, middleware) {
206
199
  const executor = yield* Service;
207
200
  const response = yield* executor
208
201
  .execute(HttpClientRequest.get(source.url).pipe(HttpClientRequest.setHeaders(headers ?? {})))
209
202
  .pipe(Effect.provideService(CurrentMiddleware, middleware));
210
- return response.stream.pipe(Stream.mapError((cause) => new AIError({
211
- reason: new InvalidProviderOutputError({
212
- message: `Failed to read media from ${source.url}`,
213
- http: responseHttp(response),
214
- cause,
215
- }),
216
- })));
203
+ return responseStream(response);
217
204
  });
218
205
  export const from = (source, options) => new Asset({ ...options, source });
219
206
  export const bytes = (data, mediaType, options) => from({ type: "bytes", data, mediaType: mediaType ?? detectMediaType(data) ?? OCTET_STREAM }, options);
@@ -57,6 +57,8 @@ const comparable = (value) => {
57
57
  name: value.name,
58
58
  arguments: json(value.arguments),
59
59
  };
60
+ if (value.type === "custom_tool_call")
61
+ return { type: value.type, call_id: value.call_id, name: value.name, input: value.input };
60
62
  if (value.type === "reasoning")
61
63
  return {
62
64
  type: value.type,
@@ -1,4 +1,4 @@
1
- import { Effect, Schema, Stream } from "effect";
1
+ import { Effect, Schema } from "effect";
2
2
  import { AIError, InvalidProviderOutputError, CompactionPart, CompactionResponse, Message, mergeJsonRecords, } from "../../schema/index.js";
3
3
  import { stripEffortUpdates } from "../../effort-updates.js";
4
4
  import { foldToolUpdates } from "../../tool-updates.js";
@@ -96,13 +96,13 @@ export const make = (adapter, lowerTools) => Effect.fn("ResponsesCompaction.exec
96
96
  auth: route.auth,
97
97
  encodeBody: Schema.encodeSync(Schema.fromJsonString(Body)),
98
98
  });
99
- const response = yield* RequestExecutor.withTls(executor.execute, request.http?.tls)(ProviderShared.jsonPost({
99
+ const response = yield* RequestExecutor.withTimeout(RequestExecutor.withTls(executor.execute, request.http?.tls), request.timeout)(ProviderShared.jsonPost({
100
100
  url: parts.url,
101
101
  body: parts.bodyText,
102
102
  headers: parts.headers,
103
103
  encoding: request.http?.encoding,
104
104
  }), RequestExecutor.withFetch(request.fetch, options?.http));
105
- const text = yield* RequestExecutor.responseStream(response).pipe(Stream.decodeText(), Stream.runFold(() => "", (text, chunk) => text + chunk));
105
+ const text = yield* RequestExecutor.responseText(response);
106
106
  const invalid = (message, cause) => new AIError({
107
107
  reason: new InvalidProviderOutputError({
108
108
  route: route.id,
@@ -9,7 +9,7 @@ import { Route } from "../route/client.js";
9
9
  import { Endpoint } from "../route/endpoint.js";
10
10
  import { Framing } from "../route/framing.js";
11
11
  import { MediaRoute } from "../route/media.js";
12
- import { ProviderConfigurationError, ProviderID, ToolDefinition, } from "../schema/index.js";
12
+ import { mergeTransport, ProviderConfigurationError, ProviderID, ToolDefinition, } from "../schema/index.js";
13
13
  export const id = ProviderID.make("alibaba");
14
14
  const hosts = new Map([
15
15
  ["ap-southeast-1", "dashscope-intl.aliyuncs.com"],
@@ -77,8 +77,7 @@ export const configure = (input) => {
77
77
  provider: id,
78
78
  endpoint: common.endpoint,
79
79
  auth: opts.auth,
80
- headers: input.headers,
81
- http: input.http,
80
+ ...mergeTransport(input),
82
81
  });
83
82
  const embedding = (id, providerOptions) => embeddingRoute.model({ id, providerOptions });
84
83
  return { id, model: chat, chat, messages, responses, image, embedding, configure };
@@ -1,12 +1,10 @@
1
1
  import { type ProviderAuthOption } from "../route/auth-options.js";
2
- import { type HttpOptions, type ModelID } from "../schema/index.js";
2
+ import { type ModelID, type TransportOptions } from "../schema/index.js";
3
3
  export type { AssemblyAITranscriptionOptions } from "../protocols/assemblyai-transcription.js";
4
4
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
5
- export type Config = ProviderAuthOption<"optional"> & {
5
+ export type Config = TransportOptions & ProviderAuthOption<"optional"> & {
6
6
  /** `https://api.eu.assemblyai.com` for the EU region. */
7
7
  readonly baseURL?: string;
8
- readonly headers?: Record<string, string>;
9
- readonly http?: HttpOptions;
10
8
  };
11
9
  export declare const configure: (input?: Config) => {
12
10
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -2,7 +2,7 @@ import { Auth } from "../route/auth.js";
2
2
  import { AuthOptions } from "../route/auth-options.js";
3
3
  import { Endpoint } from "../route/endpoint.js";
4
4
  import { MediaRoute } from "../route/media.js";
5
- import { ProviderConfigurationError, ProviderID, } from "../schema/index.js";
5
+ import { mergeTransport, ProviderConfigurationError, ProviderID, } from "../schema/index.js";
6
6
  import { AnthropicMessages } from "../protocols/anthropic-messages.js";
7
7
  import { OpenAIImages } from "../protocols/openai-images.js";
8
8
  import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
@@ -92,22 +92,16 @@ export const configure = (input) => {
92
92
  .model({ id: modelID });
93
93
  const image = (modelID, providerOptions) => {
94
94
  const target = endpoint(input, modelID);
95
- const media = MediaRoute.deployment({ ...input, baseURL: target.baseURL }, auth(input));
96
- return OpenAIImages.model({
97
- ...media,
98
- id: modelID,
99
- provider: id,
100
- providerOptions,
101
- http: { ...media.http, query: { ...media.http?.query, ...target.query } },
102
- });
95
+ const transport = mergeTransport(input, { http: { query: target.query } });
96
+ const media = MediaRoute.deployment({ ...transport, baseURL: target.baseURL }, auth(input));
97
+ return OpenAIImages.model({ ...media, id: modelID, provider: id, providerOptions });
103
98
  };
104
99
  const embedding = (modelID, providerOptions) => OpenAIEmbeddings.route
105
100
  .with({
106
101
  provider: id,
107
102
  endpoint: endpoint(input, modelID),
108
103
  auth: auth(input),
109
- headers: input.headers,
110
- http: input.http,
104
+ ...mergeTransport(input),
111
105
  })
112
106
  .model({ id: modelID, providerOptions });
113
107
  return {
@@ -4,7 +4,7 @@ import { SystemOne } from "../protocols/system-one.js";
4
4
  import { Route } from "../route/client.js";
5
5
  import { DecisionRoute } from "../route/decision.js";
6
6
  import { Endpoint } from "../route/endpoint.js";
7
- import { ProviderID } from "../schema/index.js";
7
+ import { mergeTransport, ProviderID } from "../schema/index.js";
8
8
  import { bearerRouteDefaults, toConfig } from "./settings.js";
9
9
  export const id = ProviderID.make("baseten");
10
10
  const baseURL = "https://inference.baseten.co/v1";
@@ -36,8 +36,7 @@ export const configure = (input = {}) => {
36
36
  protocol: decisionProtocol,
37
37
  endpoint: Endpoint.path("/systemone", { baseURL: options.endpoint.baseURL }),
38
38
  auth: options.auth,
39
- headers: input.headers,
40
- http: input.http,
39
+ ...mergeTransport(input),
41
40
  });
42
41
  const decision = (modelID, providerOptions) => decisionRoute.model({ id: modelID, providerOptions });
43
42
  return {
@@ -1,11 +1,9 @@
1
1
  import type { ProviderPackage } from "../provider-package.js";
2
2
  import { type ProviderAuthOption } from "../route/auth-options.js";
3
- import { type HttpOptions, type ModelID, type ProviderOptions } from "../schema/index.js";
3
+ import { type ModelID, type ProviderOptions, type TransportOptions } from "../schema/index.js";
4
4
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
5
- export type Config = ProviderAuthOption<"optional"> & {
5
+ export type Config = TransportOptions & ProviderAuthOption<"optional"> & {
6
6
  readonly baseURL?: string;
7
- readonly headers?: Record<string, string>;
8
- readonly http?: HttpOptions;
9
7
  };
10
8
  export type Settings = ProviderPackage.Settings & {
11
9
  readonly apiKey?: string | false;
@@ -1,11 +1,9 @@
1
1
  import { type ProviderAuthOption } from "../route/auth-options.js";
2
- import { type HttpOptions, type ModelID } from "../schema/index.js";
2
+ import { type ModelID, type TransportOptions } from "../schema/index.js";
3
3
  export type { CartesiaEncoding, CartesiaSpeechOptions } from "../protocols/cartesia-speech.js";
4
4
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
5
- export type Config = ProviderAuthOption<"optional"> & {
5
+ export type Config = TransportOptions & ProviderAuthOption<"optional"> & {
6
6
  readonly baseURL?: string;
7
- readonly headers?: Record<string, string>;
8
- readonly http?: HttpOptions;
9
7
  };
10
8
  export declare const configure: (input?: Config) => {
11
9
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -2,7 +2,7 @@ import { CloudflareRunDecisions } from "../protocols/cloudflare-run-decisions.js
2
2
  import { AnthropicMessages, OpenAIChat, OpenAIResponses } from "../protocols/index.js";
3
3
  import { Auth } from "../route/auth.js";
4
4
  import { AuthOptions } from "../route/auth-options.js";
5
- import { ProviderID } from "../schema/index.js";
5
+ import { mergeTransport, ProviderID } from "../schema/index.js";
6
6
  import { encodeJson } from "../utils/json.js";
7
7
  import { CloudflareShared } from "./cloudflare-shared.js";
8
8
  export const id = ProviderID.make("cloudflare-ai-gateway");
@@ -45,6 +45,7 @@ export const configure = (input) => {
45
45
  endpoint: { baseURL: baseURL(input) },
46
46
  auth: custom ?? credential(input, (credential) => credential.bearer()),
47
47
  headers: { "cf-aig-gateway-id": gatewayId(input), ...headers(input) },
48
+ timeout: input.timeout,
48
49
  http: input.http,
49
50
  providerOptions: input.providerOptions,
50
51
  };
@@ -74,8 +75,7 @@ export const configure = (input) => {
74
75
  provider: id,
75
76
  endpoint: { baseURL: runBaseURL(input) },
76
77
  auth: rest.auth,
77
- headers: rest.headers,
78
- http: input.http,
78
+ ...mergeTransport(input, { headers: rest.headers }),
79
79
  })
80
80
  .model({ id: value, providerOptions });
81
81
  return {
@@ -6,7 +6,7 @@ import { AuthOptions } from "../route/auth-options.js";
6
6
  import { Route } from "../route/client.js";
7
7
  import { Endpoint } from "../route/endpoint.js";
8
8
  import { MediaRoute } from "../route/media.js";
9
- import { ProviderID } from "../schema/index.js";
9
+ import { mergeTransport, ProviderID } from "../schema/index.js";
10
10
  import { CloudflareShared } from "./cloudflare-shared.js";
11
11
  export const id = ProviderID.make("cloudflare-workers-ai");
12
12
  export const authEnvVars = ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN", "CLOUDFLARE_API_TOKEN"];
@@ -33,8 +33,7 @@ export const configure = (input) => {
33
33
  provider: id,
34
34
  endpoint: { baseURL: runBaseURL(input) },
35
35
  auth: auth,
36
- headers: input.headers,
37
- http: input.http,
36
+ ...mergeTransport(input),
38
37
  })
39
38
  .model({ id: modelID, providerOptions });
40
39
  return {
@@ -3,7 +3,7 @@ import { OpenAIChat } from "../protocols/openai-chat.js";
3
3
  import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
4
4
  import { Route } from "../route/client.js";
5
5
  import { Endpoint } from "../route/endpoint.js";
6
- import { ProviderID } from "../schema/index.js";
6
+ import { mergeTransport, ProviderID } from "../schema/index.js";
7
7
  import { bearerRouteDefaults, toConfig } from "./settings.js";
8
8
  export const id = ProviderID.make("cohere");
9
9
  const COMPATIBILITY_BASE_URL = "https://api.cohere.ai/compatibility/v1";
@@ -26,8 +26,7 @@ export const configure = (input = {}) => {
26
26
  provider: id,
27
27
  endpoint: compatibility.endpoint,
28
28
  auth: options.auth,
29
- headers: input.headers,
30
- http: input.http,
29
+ ...mergeTransport(input),
31
30
  });
32
31
  return {
33
32
  id,
@@ -1,12 +1,10 @@
1
1
  import { type ProviderAuthOption } from "../route/auth-options.js";
2
- import { type HttpOptions, type ModelID } from "../schema/index.js";
2
+ import { type ModelID, type TransportOptions } from "../schema/index.js";
3
3
  export type { DeepgramEncoding, DeepgramSpeechOptions } from "../protocols/deepgram-speech.js";
4
4
  export type { DeepgramTranscriptionOptions } from "../protocols/deepgram-transcription.js";
5
5
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
6
- export type Config = ProviderAuthOption<"optional"> & {
6
+ export type Config = TransportOptions & ProviderAuthOption<"optional"> & {
7
7
  readonly baseURL?: string;
8
- readonly headers?: Record<string, string>;
9
- readonly http?: HttpOptions;
10
8
  };
11
9
  export declare const configure: (input?: Config) => {
12
10
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -2,7 +2,7 @@ import { OpenAIChat } from "../protocols/openai-chat.js";
2
2
  import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
3
3
  import { Route } from "../route/client.js";
4
4
  import { Endpoint } from "../route/endpoint.js";
5
- import { ProviderID } from "../schema/index.js";
5
+ import { mergeTransport, ProviderID } from "../schema/index.js";
6
6
  import { bearerRouteDefaults, toConfig } from "./settings.js";
7
7
  export const id = ProviderID.make("deepinfra");
8
8
  const baseURL = "https://api.deepinfra.com/v1/openai";
@@ -28,8 +28,7 @@ export const configure = (input = {}) => {
28
28
  provider: id,
29
29
  endpoint: options.endpoint,
30
30
  auth: options.auth,
31
- headers: input.headers,
32
- http: input.http,
31
+ ...mergeTransport(input),
33
32
  });
34
33
  return {
35
34
  id,
@@ -8,7 +8,7 @@ import { Route } from "../route/client.js";
8
8
  import { Endpoint } from "../route/endpoint.js";
9
9
  import { MediaRoute } from "../route/media.js";
10
10
  import { Protocol } from "../route/protocol.js";
11
- import { ProviderID } from "../schema/index.js";
11
+ import { mergeTransport, ProviderID } from "../schema/index.js";
12
12
  import { bearerRouteDefaults } from "./settings.js";
13
13
  export const id = ProviderID.make("digitalocean");
14
14
  const baseURL = "https://inference.do-ai.run/v1";
@@ -48,8 +48,7 @@ export const configure = (input = {}) => {
48
48
  endpoint: options.endpoint,
49
49
  auth: options.auth,
50
50
  // DigitalOcean serves TypeSafe's Jev, which needs this header for images.
51
- headers: { "TypeSafe-Danger-Zone-Images": "true", ...input.headers },
52
- http: input.http,
51
+ ...mergeTransport({ headers: { "TypeSafe-Danger-Zone-Images": "true" } }, input),
53
52
  });
54
53
  const decision = (modelID, providerOptions) => decisionRoute.model({ id: modelID, providerOptions });
55
54
  const media = MediaRoute.deployment({ ...input, baseURL: options.endpoint.baseURL }, options.auth);
@@ -58,8 +57,7 @@ export const configure = (input = {}) => {
58
57
  provider: id,
59
58
  endpoint: options.endpoint,
60
59
  auth: options.auth,
61
- headers: input.headers,
62
- http: input.http,
60
+ ...mergeTransport(input),
63
61
  });
64
62
  const embedding = (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions });
65
63
  const chat = (modelID) => configured.model({
@@ -1,12 +1,10 @@
1
1
  import { type ProviderAuthOption } from "../route/auth-options.js";
2
- import { type HttpOptions, type ModelID } from "../schema/index.js";
2
+ import { type ModelID, type TransportOptions } from "../schema/index.js";
3
3
  export type { ElevenLabsOutputFormat, ElevenLabsSpeechOptions } from "../protocols/elevenlabs-speech.js";
4
4
  export type { ElevenLabsTranscriptionOptions } from "../protocols/elevenlabs-transcription.js";
5
5
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
6
- export type Config = ProviderAuthOption<"optional"> & {
6
+ export type Config = TransportOptions & ProviderAuthOption<"optional"> & {
7
7
  readonly baseURL?: string;
8
- readonly headers?: Record<string, string>;
9
- readonly http?: HttpOptions;
10
8
  };
11
9
  export declare const configure: (input?: Config) => {
12
10
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;