Skip to content

Commit 52a6b06

Browse files
committed
fix(providers): filter non-chat model types from Together model list
1 parent 43bff43 commit 52a6b06

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

apps/sim/app/api/providers/together/models/route.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,24 @@ describe('GET /api/providers/together/models', () => {
236236
'together/Qwen/Qwen2.5-72B-Instruct-Turbo',
237237
])
238238
})
239+
240+
it('filters out non-chat model types (image, embedding, rerank, etc.)', async () => {
241+
mutableEnv.TOGETHER_API_KEY = 'env-together-key'
242+
mockFetch.mockResolvedValue(
243+
okResponse([
244+
{ id: 'meta-llama/Llama-3.3-70B-Instruct-Turbo', type: 'chat' },
245+
{ id: 'black-forest-labs/FLUX.1-schnell', type: 'image' },
246+
{ id: 'BAAI/bge-large-en-v1.5', type: 'embedding' },
247+
{ id: 'Salesforce/Llama-Rank-V1', type: 'rerank' },
248+
{ id: 'openai/whisper-large-v3', type: 'transcribe' },
249+
])
250+
)
251+
252+
const res = await GET(requestWithWorkspace())
253+
254+
expect(res.status).toBe(200)
255+
expect(await res.json()).toEqual({
256+
models: ['together/meta-llama/Llama-3.3-70B-Instruct-Turbo'],
257+
})
258+
})
239259
})

apps/sim/app/api/providers/together/models/route.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ import { filterBlacklistedModels, isProviderBlacklisted } from '@/providers/util
1616

1717
const logger = createLogger('TogetherModelsAPI')
1818

19+
/** Together's catalog includes non-text models; only chat models work with chat completions. */
20+
const NON_CHAT_MODEL_TYPES = new Set([
21+
'image',
22+
'video',
23+
'audio',
24+
'transcribe',
25+
'embedding',
26+
'moderation',
27+
'rerank',
28+
])
29+
1930
export const GET = withRouteHandler(async (request: NextRequest) => {
2031
if (isProviderBlacklisted('together')) {
2132
logger.info('Together provider is blacklisted, returning empty models')
@@ -72,6 +83,7 @@ export const GET = withRouteHandler(async (request: NextRequest) => {
7283

7384
const allModels: string[] = []
7485
for (const model of data) {
86+
if (model.type && NON_CHAT_MODEL_TYPES.has(model.type)) continue
7587
allModels.push(`together/${model.id}`)
7688
}
7789

0 commit comments

Comments
 (0)