Skip to content

feat(base): add model discovery convenience layer - #220

Draft
yamaceay wants to merge 4 commits into
mainfrom
76-enhance-model-discovery-endpoint
Draft

yamaceay wants to merge 4 commits into
mainfrom
76-enhance-model-discovery-endpoint

Conversation

@yamaceay

@yamaceay yamaceay commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Context

Closes SAP/ai-sdk-python-backlog#76.

What this PR does and why it is needed

This PR proposes a new utility function contributing to a more convenient model discovery using the base model client. The new function wraps the .query(...) method and returns the list of models directly.

Definition of Done

  • Code is tested (Unit, Integration, E2E)
  • Error handling created / updated & covered by the tests above
  • Documentation updated
    • Only Public APIs are allowed to be used in documentation/tutorials/sample code
  • (Optional) Aligned changes with the JS/TS and Java SDK
  • (Optional) Release notes updated -->

@yamaceay yamaceay self-assigned this Nov 3, 2026
@yamaceay
yamaceay marked this pull request as draft November 3, 2026 15:19
@yamaceay

yamaceay commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Below is a quick demo of the new model discovery helpers. Given that the new base version is released and reused by core package, and we initialize the base client as follows:

from ai_core_sdk.ai_core_v2_client import AICoreV2Client
from ai_api_client_sdk.helpers.llm_helper import (
    filter_foundation_models_by_capability,
    filter_foundation_models_non_deprecated,
    get_foundation_model_latest_versions,
)

client = AICoreV2Client.from_env()

List all available models

models = client.get_models()

Filter by capability

vision_models = filter_foundation_models_by_capability(models, "vision")

Filter out deprecated versions

active_models = filter_foundation_models_non_deprecated(models)

print(f"Models before: {len(models)}")
print(f"Models after removing deprecated: {len(active_models)}\n")

Get latest versions per model

latest = get_foundation_model_latest_versions(models)

print(f"Latest versions for first 5 models:\n")
for entry in latest[:5]:
    version_names = [v.name for v in entry["latest_versions"]]
    print(f"  {entry['model']} ({entry['executable_id']}): {version_names}")

Resolve orchestration deployment

from ai_api_client_sdk.models.status import Status

orch_deployments = client.deployment.query(
    scenario_id="orchestration",
    status=Status.RUNNING,
).resources

Resolve a foundation model deployment

fm_deployments = client.deployment.query(
    scenario_id="foundation-models",
    status=Status.RUNNING,
).resources

if fm_deployments:
    d = fm_deployments[0]
    model_info = (d.details or {}).get("resources", {}).get("backend_details", {}).get("model", {})
    print(f"Deployment ID:  {d.id}")
    print(f"Model:          {model_info.get('name', 'unknown')}")
    print(f"Deployment URL: {d.deployment_url}")
else:
    print("No running foundation model deployment found.")

@OscarDDD OscarDDD left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall good and I think this worths an alignment in the team. Just few nitpicks.

[q] In general I also see proxy_client supports some deployment-related functionalities. Will there be any duplicates between ?

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants