83 lines
2.7 KiB
TypeScript
83 lines
2.7 KiB
TypeScript
import { createLongcat } from 'longcat-ai-sdk-provider';
|
|
import { GatewayFetchError } from '~~/server/utils/ai-provider';
|
|
import { Err, Ok } from '~~/types/result';
|
|
import type { ProviderModule } from '.';
|
|
|
|
export default {
|
|
id: 'longcat',
|
|
baseUrl: 'https://api.longcat.chat/openai/v1',
|
|
modelsEndpoint: null,
|
|
|
|
createGateway({ apiKey, baseURL }) {
|
|
if (apiKey === undefined) {
|
|
return Err(GatewayFetchError.NoProviderApiKey);
|
|
}
|
|
|
|
return Ok({
|
|
gateway: createLongcat({ apiKey, baseURL }),
|
|
streamTransformer: undefined,
|
|
textTransformer: undefined,
|
|
});
|
|
},
|
|
|
|
getAuthHeaders(apiKey) {
|
|
return apiKey ? { Authorization: `Bearer ${apiKey}` } : {};
|
|
},
|
|
|
|
async fetchModels() {
|
|
// longcat doesn't have a model list endpoint so we hardcode them
|
|
return [
|
|
{
|
|
id: "LongCat-Flash-Chat",
|
|
name: "LongCat Flash Chat",
|
|
attributes: {
|
|
inputModalities: ['text'],
|
|
outputModalities: ['text'],
|
|
capabilities: ['tools'],
|
|
contextWindow: 256_000,
|
|
}
|
|
},
|
|
{
|
|
id: "LongCat-Flash-Thinking-2601",
|
|
name: "LongCat Flash Thinking (2601)",
|
|
attributes: {
|
|
inputModalities: ['text'],
|
|
outputModalities: ['text'],
|
|
capabilities: ['reasoning', 'tools'],
|
|
contextWindow: 256_000,
|
|
}
|
|
},
|
|
{
|
|
id: "LongCat-Flash-Omni-2603",
|
|
name: "LongCat Flash Omni",
|
|
attributes: {
|
|
inputModalities: ['text', 'image', 'audio', 'video'],
|
|
outputModalities: ['text', 'audio'],
|
|
capabilities: ['tools'],
|
|
contextWindow: 256_000,
|
|
}
|
|
},
|
|
{
|
|
id: "LongCat-2.0-Preview",
|
|
name: "LongCat 2.0 Preview",
|
|
attributes: {
|
|
inputModalities: ['text'],
|
|
outputModalities: ['text'],
|
|
capabilities: ['tools'],
|
|
contextWindow: 256_000,
|
|
}
|
|
},
|
|
{
|
|
id: "LongCat-Flash-Lite",
|
|
name: "LongCat Flash Lite",
|
|
attributes: {
|
|
inputModalities: ['text'],
|
|
outputModalities: ['text'],
|
|
capabilities: ['tools'],
|
|
contextWindow: 320_000,
|
|
}
|
|
}
|
|
];
|
|
},
|
|
} satisfies ProviderModule;
|