Skip to content

datarobot_genai.dragent.deployment_urls

deployment_urls

Shared URL construction utilities for DataRobot deployment endpoints.

These helpers are the single source of truth for the URL patterns used to reach a DataRobot-hosted A2A agent and to look up its agent card from the central registry. Both the server side (advertising its own URL in the agent card) and the client side (deriving the RPC base URL from a deployment_id) use these functions so that the patterns stay in sync automatically.

resolve_datarobot_endpoint

resolve_datarobot_endpoint(require: bool = False) -> str | None

Return the effective DataRobot API endpoint from the environment.

Checks environment variables in priority order:

  1. DATAROBOT_PUBLIC_API_ENDPOINT — preferred for externally reachable URLs (on-prem deployments often set DATAROBOT_ENDPOINT to an internal k8s address while DATAROBOT_PUBLIC_API_ENDPOINT holds the public URL).
  2. DATAROBOT_ENDPOINT — standard SDK variable.
  3. Built-in default (https://app.datarobot.com/api/v2) when require is False.
Parameters

require: When True, raises :class:ValueError if neither env var is set. When False (default), falls back to the built-in default endpoint.

Returns

str | None The resolved endpoint string, or None only when require is False and both env vars are unset (returns the default instead, so in practice this always returns a non-None value when require=False).

Raises

ValueError If require=True and neither DATAROBOT_PUBLIC_API_ENDPOINT nor DATAROBOT_ENDPOINT is set.

Source code in datarobot_genai/dragent/deployment_urls.py
def resolve_datarobot_endpoint(require: bool = False) -> str | None:
    """Return the effective DataRobot API endpoint from the environment.

    Checks environment variables in priority order:

    1. ``DATAROBOT_PUBLIC_API_ENDPOINT`` — preferred for externally reachable URLs
       (on-prem deployments often set ``DATAROBOT_ENDPOINT`` to an internal k8s
       address while ``DATAROBOT_PUBLIC_API_ENDPOINT`` holds the public URL).
    2. ``DATAROBOT_ENDPOINT`` — standard SDK variable.
    3. Built-in default (``https://app.datarobot.com/api/v2``) when ``require``
       is *False*.

    Parameters
    ----------
    require:
        When *True*, raises :class:`ValueError` if neither env var is set.
        When *False* (default), falls back to the built-in default endpoint.

    Returns
    -------
    str | None
        The resolved endpoint string, or *None* only when ``require`` is
        *False* **and** both env vars are unset (returns the default instead,
        so in practice this always returns a non-None value when
        ``require=False``).

    Raises
    ------
    ValueError
        If ``require=True`` and neither ``DATAROBOT_PUBLIC_API_ENDPOINT`` nor
        ``DATAROBOT_ENDPOINT`` is set.
    """
    endpoint = os.getenv("DATAROBOT_PUBLIC_API_ENDPOINT") or os.getenv("DATAROBOT_ENDPOINT")
    if endpoint:
        return endpoint
    if require:
        raise ValueError("DATAROBOT_PUBLIC_API_ENDPOINT or DATAROBOT_ENDPOINT must be set.")
    return _DEFAULT_DATAROBOT_ENDPOINT

build_deployment_a2a_url

build_deployment_a2a_url(endpoint: str, deployment_id: str) -> str

Construct the A2A direct-access URL for a DataRobot deployment.

Parameters

endpoint: DataRobot API endpoint base URL, e.g. https://app.datarobot.com/api/v2. A trailing slash is stripped before composing the URL. deployment_id: The DataRobot deployment ID.

Returns

str A URL of the form {endpoint}/deployments/{deployment_id}/directAccess/a2a/.

Source code in datarobot_genai/dragent/deployment_urls.py
def build_deployment_a2a_url(endpoint: str, deployment_id: str) -> str:
    """Construct the A2A direct-access URL for a DataRobot deployment.

    Parameters
    ----------
    endpoint:
        DataRobot API endpoint base URL, e.g. ``https://app.datarobot.com/api/v2``.
        A trailing slash is stripped before composing the URL.
    deployment_id:
        The DataRobot deployment ID.

    Returns
    -------
    str
        A URL of the form ``{endpoint}/deployments/{deployment_id}/directAccess/a2a/``.
    """
    base = endpoint.rstrip("/")
    return f"{base}/deployments/{deployment_id}/{DEPLOYMENT_A2A_PATH}/"

build_deployment_agent_card_url

build_deployment_agent_card_url(endpoint: str, deployment_id: str) -> str

Construct the agent card registry URL for a DataRobot deployment.

Parameters

endpoint: DataRobot API endpoint base URL, e.g. https://app.datarobot.com/api/v2. A trailing slash is stripped before composing the URL. deployment_id: The DataRobot deployment ID.

Returns

str A URL of the form {endpoint}/deployments/{deployment_id}/agentCard/.

Source code in datarobot_genai/dragent/deployment_urls.py
def build_deployment_agent_card_url(endpoint: str, deployment_id: str) -> str:
    """Construct the agent card registry URL for a DataRobot deployment.

    Parameters
    ----------
    endpoint:
        DataRobot API endpoint base URL, e.g. ``https://app.datarobot.com/api/v2``.
        A trailing slash is stripped before composing the URL.
    deployment_id:
        The DataRobot deployment ID.

    Returns
    -------
    str
        A URL of the form ``{endpoint}/deployments/{deployment_id}/agentCard/``.
    """
    base = endpoint.rstrip("/")
    return f"{base}/deployments/{deployment_id}/agentCard/"

build_workload_a2a_url

build_workload_a2a_url(endpoint: str, workload_id: str) -> str

Construct the A2A URL for a DataRobot workload.

Parameters

endpoint: DataRobot API endpoint base URL, e.g. https://app.datarobot.com/api/v2. A trailing slash is stripped before composing the URL. workload_id: The DataRobot workload ID.

Returns

str A URL of the form {endpoint}/endpoints/workloads/{workload_id}/a2a/.

Source code in datarobot_genai/dragent/deployment_urls.py
def build_workload_a2a_url(endpoint: str, workload_id: str) -> str:
    """Construct the A2A URL for a DataRobot workload.

    Parameters
    ----------
    endpoint:
        DataRobot API endpoint base URL, e.g. ``https://app.datarobot.com/api/v2``.
        A trailing slash is stripped before composing the URL.
    workload_id:
        The DataRobot workload ID.

    Returns
    -------
    str
        A URL of the form ``{endpoint}/endpoints/workloads/{workload_id}/a2a/``.
    """
    base = endpoint.removesuffix("/")
    return f"{base}/endpoints/workloads/{workload_id}/{WORKLOAD_A2A_PATH}/"

build_workload_agent_card_url

build_workload_agent_card_url(endpoint: str, workload_id: str) -> str

Construct the agent card URL for a DataRobot workload.

Parameters

endpoint: DataRobot API endpoint base URL, e.g. https://app.datarobot.com/api/v2. A trailing slash is stripped before composing the URL. workload_id: The DataRobot workload ID.

Returns

str A URL of the form {endpoint}/workloads/{workload_id}/agentCard/.

Source code in datarobot_genai/dragent/deployment_urls.py
def build_workload_agent_card_url(endpoint: str, workload_id: str) -> str:
    """Construct the agent card URL for a DataRobot workload.

    Parameters
    ----------
    endpoint:
        DataRobot API endpoint base URL, e.g. ``https://app.datarobot.com/api/v2``.
        A trailing slash is stripped before composing the URL.
    workload_id:
        The DataRobot workload ID.

    Returns
    -------
    str
        A URL of the form ``{endpoint}/workloads/{workload_id}/agentCard/``.
    """
    base = endpoint.removesuffix("/")
    return f"{base}/workloads/{workload_id}/agentCard/"

build_agent_cards_registry_url

build_agent_cards_registry_url(endpoint: str) -> str

Construct the URL for the central agent card registry.

The central registry lists all agent cards within the user's organisation (tenant context) and requires only API-token authentication, not the per-agent AuthZ that the agent's own card endpoint demands.

Parameters

endpoint: DataRobot API endpoint base URL, e.g. https://app.datarobot.com/api/v2. A trailing slash is stripped before composing the URL.

Returns

str A URL of the form {endpoint}/agentCards/.

Source code in datarobot_genai/dragent/deployment_urls.py
def build_agent_cards_registry_url(endpoint: str) -> str:
    """Construct the URL for the central agent card registry.

    The central registry lists all agent cards within the user's organisation
    (tenant context) and requires only API-token authentication, not the
    per-agent AuthZ that the agent's own card endpoint demands.

    Parameters
    ----------
    endpoint:
        DataRobot API endpoint base URL, e.g. ``https://app.datarobot.com/api/v2``.
        A trailing slash is stripped before composing the URL.

    Returns
    -------
    str
        A URL of the form ``{endpoint}/agentCards/``.
    """
    base = endpoint.rstrip("/")
    return f"{base}/agentCards/"