Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/common/orpc/schemas/providerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const MuxProviderOptionsSchema = z.object({
.optional(),
openai: z
.object({
serviceTier: z.enum(["auto", "default", "flex", "priority"]).optional().meta({
description:
"OpenAI service tier: priority (low-latency), flex (50% cheaper, higher latency), auto/default (standard)",
}),
disableAutoTruncation: z
.boolean()
.optional()
Expand Down
5 changes: 3 additions & 2 deletions src/common/utils/ai/providerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,12 @@ export function buildProviderOptions(
disableAutoTruncation,
});

const serviceTier = muxProviderOptions?.openai?.serviceTier ?? "priority";

const options: ProviderOptions = {
openai: {
parallelToolCalls: true, // Always enable concurrent tool execution
// TODO: allow this to be configured
serviceTier: "auto", // Use "auto" to automatically select the best service tier
serviceTier,
// Automatically truncate conversation to fit context window, unless disabled for testing
truncation: disableAutoTruncation ? "disabled" : "auto",
// Conditionally add reasoning configuration
Expand Down
10 changes: 10 additions & 0 deletions src/node/services/aiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,16 @@ export class AIService extends EventEmitter {
provider: providerName,
});
}

// Extract serviceTier from config to pass through to buildProviderOptions
const configServiceTier = providerConfig.serviceTier as string | undefined;
if (configServiceTier && muxProviderOptions) {
muxProviderOptions.openai = {
...muxProviderOptions.openai,
serviceTier: configServiceTier as "auto" | "default" | "flex" | "priority",
};
}

const baseFetch = getProviderFetch(providerConfig);

// Wrap fetch to force truncation: "auto" for OpenAI Responses API calls.
Expand Down
Loading