close
Skip to content

feat: Add model listing functionality#3900

Open
Zephyroam wants to merge 8 commits intocamel-ai:masterfrom
Zephyroam:3899-feature-request-support-retrieve-model-list-for-providers
Open

feat: Add model listing functionality#3900
Zephyroam wants to merge 8 commits intocamel-ai:masterfrom
Zephyroam:3899-feature-request-support-retrieve-model-list-for-providers

Conversation

@Zephyroam
Copy link
Copy Markdown
Collaborator

@Zephyroam Zephyroam commented Mar 4, 2026

Related Issue

Closes #3899

Description

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Checklist

  • I have read and agree to the AI-Generated Code Policy (required)
  • I have linked this PR to an issue (required)
  • I have checked if any dependencies need to be added or updated in pyproject.toml and run uv lock
  • I have updated the tests accordingly (required for a bug fix or a new feature)
  • I have updated the documentation if needed
  • I have added examples if this is a new feature

If you are unsure about any of these, don't hesitate to ask. We are here to help!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 4, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 18380822-e3e8-459b-8522-1ef605efdee4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Zephyroam
Copy link
Copy Markdown
Collaborator Author

Due to the API key limitation, I only tested with the following providers:
anthropic, openai, deepseek, gemini, aihubmix.

@Zephyroam
Copy link
Copy Markdown
Collaborator Author

Zephyroam commented Mar 4, 2026

AIMLAPI and CometAPI need to be further tested as their getting model api endpoints are at /models and/api/models, respectively, not /v1/models (OpenAI and most OpenAI compatible providers do)

@Zephyroam Zephyroam added the Review Required PR need to be reviewed label Mar 4, 2026
Comment thread camel/models/aihubmix_model.py
_API_KEY_ENV_VAR: str = "INTERNLM_API_KEY"
_BASE_URL_ENV_VAR: str = "INTERNLM_API_BASE_URL"
_DEFAULT_BASE_URL: str = "https://internlm.intern-ai.org.cn/api/v1"

Copy link
Copy Markdown
Collaborator

@nitpicker55555 nitpicker55555 Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the default URL changed from https://internlm.intern-ai.org.cn/api/tokens to https://internlm.intern-ai.org.cn/api/v1 — why has this been changed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the old one should be wrong, according to https://internlm.intern-ai.org.cn/api/document?lang=en.

Comment thread camel/models/openai_model.py
@Zephyroam
Copy link
Copy Markdown
Collaborator Author

API_KEY hardcoding and list_available_models duplication are done. Thanks @nitpicker55555. Please check again.

@Zephyroam Zephyroam requested a review from nitpicker55555 March 6, 2026 01:08
Copy link
Copy Markdown
Collaborator

@fengju0213 fengju0213 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @Zephyroam left some comments

api_version = os.environ.get(cls._API_VERSION_ENV_VAR)
azure_ad_token = os.environ.get(cls._AZURE_AD_TOKEN_ENV_VAR)

client = AzureOpenAI(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we directly use the client we init when init?

Comment thread camel/models/_utils.py
Comment on lines +106 to +107
api_key: Optional[str],
url: Optional[str],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we don't need api_key and url here?


return cast(AsyncStream[ChatCompletionChunk], _generate_chunks())

@classmethod
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an instance method would be a better fit here, since it can directly reuse the
client initialized in init.

@Zephyroam
Copy link
Copy Markdown
Collaborator Author

Making list_available_models an instance method requires the user to pass a model_type to create the instance first, but generally, the purpose of this method is to find out what models are available — so the user has to know a model before they can list the models.

@fengju0213 How do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review Required PR need to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Support retrieve model list for providers.

3 participants