Skip to content
Open
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
2 changes: 2 additions & 0 deletions packages/api/src/endpoints/openai/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function getOpenAIConfig(
): t.OpenAIConfigResult {
const {
proxy,
vision,
addParams,
dropParams,
defaultQuery,
Expand Down Expand Up @@ -202,6 +203,7 @@ export function getOpenAIConfig(
defaultParams,
modelOptions,
useOpenRouter,
vision,
reasoningFormat: getReasoningFormat({
customFormat: options.customParams?.reasoningFormat,
isVercel: Boolean(isVercel),
Expand Down
32 changes: 32 additions & 0 deletions packages/api/src/endpoints/openai/llm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,38 @@ describe('getOpenAILLMConfig', () => {
expect(result.tools).toEqual([]);
});

it('should forward vision=false to llmConfig', () => {
const result = getOpenAILLMConfig({
apiKey: 'test-api-key',
streaming: true,
vision: false,
modelOptions: { model: 'gpt-4' },
});

expect(result.llmConfig).toHaveProperty('vision', false);
});

it('should forward vision=true to llmConfig', () => {
const result = getOpenAILLMConfig({
apiKey: 'test-api-key',
streaming: true,
vision: true,
modelOptions: { model: 'gpt-4' },
});

expect(result.llmConfig).toHaveProperty('vision', true);
});

it('should omit vision from llmConfig when not provided', () => {
const result = getOpenAILLMConfig({
apiKey: 'test-api-key',
streaming: true,
modelOptions: { model: 'gpt-4' },
});

expect(result.llmConfig).not.toHaveProperty('vision');
});

it('should handle model options including temperature and penalties', () => {
const result = getOpenAILLMConfig({
apiKey: 'test-api-key',
Expand Down
6 changes: 6 additions & 0 deletions packages/api/src/endpoints/openai/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ export function getOpenAILLMConfig({
dropParams,
defaultParams,
useOpenRouter,
vision,
reasoningFormat = ReasoningParameterFormat.reasoningEffort,
modelOptions: _modelOptions,
}: {
Expand All @@ -520,6 +521,7 @@ export function getOpenAILLMConfig({
dropParams?: string[];
defaultParams?: Record<string, unknown>;
useOpenRouter?: boolean;
vision?: boolean;
reasoningFormat?: ReasoningParameterFormat;
azure?: false | t.AzureOptions;
}): Pick<t.LLMConfigResult, 'llmConfig' | 'tools'> & {
Expand Down Expand Up @@ -555,6 +557,10 @@ export function getOpenAILLMConfig({
modelOptions,
) as OpenAILLMConfig;

if (vision != null) {
llmConfig.vision = vision;
}

if (frequency_penalty != null) {
llmConfig.frequencyPenalty = frequency_penalty;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/api/src/types/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export type OpenAIModelOptions = Partial<OpenAIParameters>;
*/
export interface OpenAIConfigOptions {
modelOptions?: OpenAIModelOptions;
/** When false, the client strips image content for models without vision support. */
vision?: boolean;
directEndpoint?: boolean;
reverseProxyUrl?: string | null;
baseURLIsUserProvided?: boolean;
Expand All @@ -34,6 +36,8 @@ export type OAIClientOptions = Omit<OpenAIClientOptions, 'verbosity'> & {
include_reasoning?: boolean;
/** Replays `reasoning_content` on tool-bearing turns (DeepSeek thinking-mode, #13366). */
includeReasoningContent?: boolean;
/** When false, the client strips image content for models without vision support. */
vision?: boolean;
promptCache?: boolean;
promptCacheTtl?: '5m' | '1h';
_lc_stream_delay?: number;
Expand Down