-
Notifications
You must be signed in to change notification settings - Fork 4.9k
feat(provider): add CrossModel provider #12900
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
Open
hujuncheng
wants to merge
2
commits into
continuedev:main
Choose a base branch
from
hujuncheng:add-crossmodel-provider
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+199
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { LLMOptions } from "../../index.js"; | ||
| import { osModelsEditPrompt } from "../templates/edit.js"; | ||
|
|
||
| import OpenAI from "./OpenAI.js"; | ||
|
|
||
| /** | ||
| * CrossModel LLM provider. | ||
| * | ||
| * CrossModel (https://crossmodel.ai) is an OpenAI- and Anthropic-compatible | ||
| * multi-provider API gateway. A single API key and base URL routes to models | ||
| * from OpenAI, Anthropic, DeepSeek, Gemini, Qwen, Kimi, GLM and more, with | ||
| * unified billing and usage tracking. | ||
| * | ||
| * Uses the OpenAI-compatible Chat Completions API. The available models can be | ||
| * listed dynamically from the gateway's `/v1/models` endpoint, so users can | ||
| * fetch the current catalog after entering their API key. | ||
| * | ||
| * @see https://crossmodel.ai/docs | ||
| */ | ||
| class CrossModel extends OpenAI { | ||
| static providerName = "crossmodel"; | ||
|
|
||
| // CrossModel routes to reasoning-capable models and surfaces their | ||
| // reasoning content over the OpenAI-compatible wire format. | ||
| protected supportsReasoningField = true; | ||
| protected supportsReasoningDetailsField = true; | ||
|
|
||
| static defaultOptions: Partial<LLMOptions> = { | ||
| apiBase: "https://api.crossmodel.ai/v1/", | ||
| model: "anthropic/claude-sonnet-4-6", | ||
| promptTemplates: { | ||
| edit: osModelsEditPrompt, | ||
| }, | ||
| useLegacyCompletionsEndpoint: false, | ||
| }; | ||
| } | ||
|
|
||
| export default CrossModel; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import CrossModel from "./CrossModel"; | ||
|
|
||
| describe("CrossModel", () => { | ||
| it("should have correct provider name", () => { | ||
| expect(CrossModel.providerName).toBe("crossmodel"); | ||
| }); | ||
|
|
||
| it("should have correct default options", () => { | ||
| expect(CrossModel.defaultOptions.apiBase).toBe( | ||
| "https://api.crossmodel.ai/v1/", | ||
| ); | ||
| expect(CrossModel.defaultOptions.useLegacyCompletionsEndpoint).toBe(false); | ||
| }); | ||
|
|
||
| it("should support reasoning fields", () => { | ||
| const crossModel = new CrossModel({ | ||
| model: "anthropic/claude-sonnet-4-6", | ||
| }); | ||
|
|
||
| expect(crossModel["supportsReasoningField"]).toBe(true); | ||
| expect(crossModel["supportsReasoningDetailsField"]).toBe(true); | ||
| }); | ||
|
|
||
| it("should preserve the configured model id", () => { | ||
| const models = [ | ||
| "anthropic/claude-opus-4-8", | ||
| "openai/gpt-5.5", | ||
| "deepseek/deepseek-v4-pro", | ||
| ]; | ||
|
|
||
| for (const model of models) { | ||
| const crossModel = new CrossModel({ model }); | ||
| expect(crossModel.model).toBe(model); | ||
| } | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| --- | ||
| title: "How to Configure CrossModel with Continue" | ||
| sidebarTitle: "CrossModel" | ||
| --- | ||
|
|
||
| [CrossModel](https://crossmodel.ai) is an OpenAI- and Anthropic-compatible API gateway. Use one API key and base URL to call models from OpenAI, Anthropic, DeepSeek, Gemini, Qwen, Kimi, GLM and more, with unified billing and usage tracking. | ||
|
|
||
| <Info> | ||
| Sign up at [crossmodel.ai](https://crossmodel.ai) and create an API key from | ||
| the [console](https://www.crossmodel.ai/console/api-keys). | ||
| </Info> | ||
|
|
||
| ## Configuration | ||
|
|
||
| <Tabs> | ||
| <Tab title="YAML"> | ||
| ```yaml title="config.yaml" | ||
| name: My Config | ||
| version: 0.0.1 | ||
| schema: v1 | ||
|
|
||
| models: | ||
| - name: Claude Sonnet 4.6 | ||
| provider: crossmodel | ||
| model: anthropic/claude-sonnet-4-6 | ||
| apiKey: <YOUR_CROSSMODEL_API_KEY> | ||
| ``` | ||
| </Tab> | ||
| <Tab title="JSON (Deprecated)"> | ||
| ```json title="config.json" | ||
| { | ||
| "models": [ | ||
| { | ||
| "title": "Claude Sonnet 4.6", | ||
| "provider": "crossmodel", | ||
| "model": "anthropic/claude-sonnet-4-6", | ||
| "apiKey": "<YOUR_CROSSMODEL_API_KEY>" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| </Tab> | ||
| </Tabs> | ||
|
|
||
| ## Available Models | ||
|
|
||
| Model IDs follow the `<vendor>/<model>` convention (for example `anthropic/claude-opus-4-8`, `openai/gpt-5.5`, `deepseek/deepseek-v4-pro`, `gemini/gemini-3.5-flash`). The full, up-to-date catalog with pricing is at [crossmodel.ai/models](https://www.crossmodel.ai/models), and can also be listed from the gateway's OpenAI-compatible `/v1/models` endpoint. | ||
|
|
||
| ## Notes | ||
|
|
||
| - CrossModel uses an OpenAI-compatible API at `https://api.crossmodel.ai/v1` | ||
| - Set the `CROSSMODEL_API_KEY` environment variable or configure `apiKey` in your config | ||
| - An Anthropic-compatible endpoint is also available at the same host for tools that speak the Anthropic Messages API |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.