-
Couldn't load subscription status.
- Fork 2.4k
feat: update OpenRouter API to support input/output modalities and filter image generation models #7492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update OpenRouter API to support input/output modalities and filter image generation models #7492
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -280,7 +280,8 @@ describe("OpenRouter API", () => { | |
| const result = parseOpenRouterModel({ | ||
| id: "openrouter/horizon-alpha", | ||
| model: mockModel, | ||
| modality: "text", | ||
| inputModality: ["text"], | ||
| outputModality: ["text"], | ||
| maxTokens: 128000, | ||
| }) | ||
|
|
||
|
|
@@ -303,7 +304,8 @@ describe("OpenRouter API", () => { | |
| const result = parseOpenRouterModel({ | ||
| id: "openrouter/horizon-beta", | ||
| model: mockModel, | ||
| modality: "text", | ||
| inputModality: ["text"], | ||
| outputModality: ["text"], | ||
| maxTokens: 128000, | ||
| }) | ||
|
|
||
|
|
@@ -326,12 +328,59 @@ describe("OpenRouter API", () => { | |
| const result = parseOpenRouterModel({ | ||
| id: "openrouter/other-model", | ||
| model: mockModel, | ||
| modality: "text", | ||
| inputModality: ["text"], | ||
| outputModality: ["text"], | ||
| maxTokens: 64000, | ||
| }) | ||
|
|
||
| expect(result.maxTokens).toBe(64000) | ||
| expect(result.contextWindow).toBe(128000) | ||
| }) | ||
|
|
||
| it("filters out image generation models", () => { | ||
| const mockImageModel = { | ||
| name: "Image Model", | ||
| description: "Test image generation model", | ||
| context_length: 128000, | ||
| max_completion_tokens: 64000, | ||
| pricing: { | ||
| prompt: "0.000003", | ||
| completion: "0.000015", | ||
| }, | ||
| } | ||
|
|
||
| const mockTextModel = { | ||
| name: "Text Model", | ||
| description: "Test text generation model", | ||
| context_length: 128000, | ||
| max_completion_tokens: 64000, | ||
| pricing: { | ||
| prompt: "0.000003", | ||
| completion: "0.000015", | ||
| }, | ||
| } | ||
|
|
||
| // Model with image output should be filtered out - we only test parseOpenRouterModel | ||
| // since the filtering happens in getOpenRouterModels/getOpenRouterModelEndpoints | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good test coverage for the |
||
| const textResult = parseOpenRouterModel({ | ||
| id: "test/text-model", | ||
| model: mockTextModel, | ||
| inputModality: ["text"], | ||
| outputModality: ["text"], | ||
| maxTokens: 64000, | ||
| }) | ||
|
|
||
| const imageResult = parseOpenRouterModel({ | ||
| id: "test/image-model", | ||
| model: mockImageModel, | ||
| inputModality: ["text"], | ||
| outputModality: ["image"], | ||
| maxTokens: 64000, | ||
| }) | ||
|
|
||
| // Both should parse successfully (filtering happens at a higher level) | ||
| expect(textResult.maxTokens).toBe(64000) | ||
| expect(imageResult.maxTokens).toBe(64000) | ||
| }) | ||
| }) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment here explaining why image generation models are being filtered out. This would help future maintainers understand the business logic behind this decision.