{"id":7138,"library":"datarobot","title":"DataRobot Python Client","description":"The DataRobot Python Client Library (v3.13.0) provides a programmatic interface for interacting with the DataRobot AI Platform, enabling users to manage projects, create models, perform predictions, and automate MLOps workflows. It follows a regular release cadence, typically monthly or bi-monthly, aligning with platform updates.","status":"active","version":"3.13.0","language":"en","source_language":"en","source_url":"https://github.com/datarobot/datarobot-public-api-client","tags":["machine learning","api client","data science","datarobot","mlops"],"install":[{"cmd":"pip install datarobot","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"While 'from datarobot import Client' works, the recommended and common practice is 'import datarobot as dr' and then using 'dr.Client()' to maintain consistency with other DataRobot objects like 'dr.Project' or 'dr.Model'.","wrong":"from datarobot import Client","symbol":"Client","correct":"import datarobot as dr\ndr.Client()"},{"symbol":"Project","correct":"import datarobot as dr\ndr.Project"},{"symbol":"Deployment","correct":"import datarobot as dr\ndr.Deployment"}],"quickstart":{"code":"import datarobot as dr\nimport os\n\n# Configure client using environment variables\n# DATAROBOT_ENDPOINT e.g., 'https://app.datarobot.com/api/v2'\n# DATAROBOT_API_TOKEN\n# DATAROBOT_USERNAME (optional, for specific auth methods)\n# DATAROBOT_PASSWORD (optional, for specific auth methods)\n\n# For testing, ensure these are set in your environment or provide defaults.\nendpoint = os.environ.get('DATAROBOT_ENDPOINT', 'YOUR_DATAROBOT_ENDPOINT')\ntoken = os.environ.get('DATAROBOT_API_TOKEN', 'YOUR_DATAROBOT_API_TOKEN')\n\nif 'YOUR_DATAROBOT_ENDPOINT' in endpoint or 'YOUR_DATAROBOT_API_TOKEN' in token:\n    print(\"Please set DATAROBOT_ENDPOINT and DATAROBOT_API_TOKEN environment variables or replace placeholders.\")\nelse:\n    try:\n        # Client auto-discovers config from environment variables by default.\n        # Explicit config can be passed via dr.Client(token='...', endpoint='...').\n        dr.Client()\n        print(\"Successfully connected to DataRobot.\")\n\n        # List first 5 projects\n        projects = dr.Project.list(max_projects=5)\n        if projects:\n            print(\"\\nFirst 5 projects:\")\n            for p in projects:\n                print(f\" - {p.name} (ID: {p.id})\")\n        else:\n            print(\"No projects found in your account.\")\n\n    except dr.errors.ClientInitializationError as e:\n        print(f\"Error initializing DataRobot client: {e}\")\n        print(\"Ensure DATAROBOT_ENDPOINT and DATAROBOT_API_TOKEN environment variables are correctly set.\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the DataRobot client, which by default reads configuration from environment variables (DATAROBOT_ENDPOINT, DATAROBOT_API_TOKEN). It then lists the first five projects accessible to the authenticated user. Ensure your environment variables are set for successful execution."},"warnings":[{"fix":"For versions 3.0 and newer, set `DATAROBOT_ENDPOINT` and `DATAROBOT_API_TOKEN` environment variables. If you need to explicitly pass them, use `dr.Client(endpoint='...', token='...')`.","message":"The `datarobot.Client` initialization changed significantly in version 3.0. Prior versions often required explicitly passing `endpoint` and `token` arguments to the `Client` constructor. Version 3.0+ defaults to auto-discovery from environment variables (DATAROBOT_ENDPOINT, DATAROBOT_API_TOKEN) or a configuration file.","severity":"breaking","affected_versions":"<3.0 to 3.0+"},{"fix":"Consult the DataRobot Python Client documentation for your specific version, especially for `Project.get_recommended_model().predict()` or `Deployment.predict()`, to ensure correct method signatures and return types.","message":"Methods for interacting with the prediction API (e.g., `predict_raw`) may have changed signatures or availability across major versions, particularly regarding how data is passed and results are retrieved.","severity":"breaking","affected_versions":"<3.0 to 3.0+"},{"fix":"Set the `REQUESTS_CA_BUNDLE` environment variable to the path of your corporate CA certificate bundle or `CURL_CA_BUNDLE` for similar effect. Alternatively, you might need to configure proxy settings via `HTTP_PROXY` and `HTTPS_PROXY` environment variables. As a last resort (not recommended for production), `dr.Client(verify_ssl=False)` can temporarily bypass SSL verification.","message":"Connecting from corporate networks can often lead to `SSLError` due to proxy configurations or custom CA certificates. The Python `requests` library (used by DataRobot client) might not trust these certificates by default.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For large dataset uploads, consider using `dr.Dataset.create_from_file(filepath, max_wait=3600)` and ensure your client timeout is sufficient. For downloading predictions, use methods that allow for streaming or chunking, or retrieve predictions from a prediction server/deployment directly.","message":"When working with large datasets, uploading or downloading them directly through the client can be slow or hit memory limits. DataRobot provides specific methods for large data handling.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Set the `DATAROBOT_API_TOKEN` and `DATAROBOT_ENDPOINT` environment variables. For example: `export DATAROBOT_API_TOKEN='your_token'` and `export DATAROBOT_ENDPOINT='https://app.datarobot.com/api/v2'`. Alternatively, initialize the client with `dr.Client(token='your_token', endpoint='your_endpoint')`.","cause":"The DataRobot client could not find the necessary API token or endpoint to establish a connection. This often happens if environment variables (`DATAROBOT_API_TOKEN`, `DATAROBOT_ENDPOINT`) are not set, or if they are not passed explicitly to `dr.Client()`.","error":"datarobot.errors.ClientInitializationError: API token or endpoint not provided"},{"fix":"Configure the `REQUESTS_CA_BUNDLE` environment variable to point to your corporate CA certificate bundle. For example: `export REQUESTS_CA_BUNDLE='/etc/ssl/certs/ca-certificates.crt'`. You may also need to set proxy environment variables (`HTTP_PROXY`, `HTTPS_PROXY`).","cause":"SSL certificate verification failed, typically due to a corporate proxy or firewall interfering with the TLS handshake. Python's `requests` library does not trust the custom certificates presented by the proxy.","error":"requests.exceptions.SSLError: HTTPSConnectionPool(...) Max retries exceeded with url: (...) Caused by SSLError(CertificateError(...))"},{"fix":"Ensure you have the latest version of the `datarobot` library by running `pip install --upgrade datarobot`. Check your project directory for any files named `datarobot.py` that might shadow the installed package. Confirm you are using `import datarobot as dr` and then `dr.Client()`.","cause":"This error usually indicates an outdated version of the `datarobot` library, a conflict with a local file named `datarobot.py`, or an incorrect import pattern.","error":"AttributeError: module 'datarobot' has no attribute 'Client'"},{"fix":"Verify the project ID is correct. Ensure the API token belongs to a user with appropriate permissions to view or interact with the project. You can list all projects to which you have access using `dr.Project.list()` to find correct IDs.","cause":"The specified project ID does not exist, is incorrect, or the authenticated user does not have permission to access it.","error":"datarobot.errors.NotFound: No such project found with ID '...'"}]}