### Install and Basic Help Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/SKILL.md Install the Kaggle CLI using pip and display the main help message. ```bash pip install kaggle kaggle --help ``` -------------------------------- ### Basic kernel-metadata.json Example Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/kernels_metadata.md This is a fundamental example of the kernel-metadata.json file, outlining essential fields for defining a Kaggle Kernel. ```json { "id": "timoboz/my-awesome-kernel", "id_no": 12345, "title": "My Awesome Kernel", "code_file": "my-awesome-kernel.ipynb", "language": "python", "kernel_type": "notebook", "is_private": "false", "enable_gpu": "false", "enable_internet": "false", "machine_shape": "", "dataset_sources": ["timoboz/my-awesome-dataset"], "competition_sources": [], "kernel_sources": [], "model_sources": [] } ``` -------------------------------- ### Install Kaggle CLI Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/README.md Install the kaggle package using pip. Ensure Python 3.11+ and pip are installed. ```sh pip install kaggle ``` -------------------------------- ### Basic model-metadata.json Example Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/models_metadata.md This is a fundamental example of the 'model-metadata.json' file used to define a Kaggle model. Ensure all placeholder values are replaced with actual information. ```json { "ownerSlug": "INSERT_OWNER_SLUG_HERE", "title": "INSERT_TITLE_HERE", "slug": "INSERT_SLUG_HERE", "subtitle": "", "isPrivate": true, "description": "Model Card Markdown, see below", "publishTime": "", "provenanceSources": "" } ``` -------------------------------- ### Basic model-instance-metadata.json Example Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/models_metadata.md This is a fundamental example of the 'model-instance-metadata.json' file used to define a model variation. Ensure all placeholder values are replaced with actual information. ```json { "ownerSlug": "INSERT_OWNER_SLUG_HERE", "modelSlug": "INSERT_EXISTING_MODEL_SLUG_HERE", "instanceSlug": "INSERT_INSTANCE_SLUG_HERE", "framework": "INSERT_FRAMEWORK_HERE", "overview": "", "usage": "Usage Markdown, see below", "licenseName": "Apache 2.0", "fineTunable": False, "trainingData": [], "modelInstanceType": "Unspecified", "baseModelInstance": "", "externalBaseModelUrl": "" } ``` -------------------------------- ### Full End-to-End Benchmark Workflow Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/benchmarks.md Provides a step-by-step guide for a common end-to-end workflow involving setting up a benchmark, writing a task file, and pushing the task to the server. ```bash # 1. Setup kaggle b init -y # 2. Write your task in task.py (see task file format above) # 3. Push kaggle b t push my-task -f task.py --wait ``` -------------------------------- ### Initialize Kaggle Benchmarks with Custom Files Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Initializes the benchmark environment using custom file paths for environment variables and the example task script. Use `-y` for automatic confirmation. ```bash kaggle b init -y --env-file my_project/.env --example-file my_project/my_task.py ``` -------------------------------- ### List All Benchmark Tasks Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Lists all benchmark tasks owned by the current user. Use this to get an overview of your tasks. ```bash kaggle b t list ``` -------------------------------- ### Enter Kaggle CLI Development Shell Source: https://github.com/kaggle/kaggle-cli/blob/main/README.md Start an interactive shell environment for running multiple Kaggle CLI commands. Useful for development and testing. ```sh hatch shell ``` ```sh # Inside the shell, you can run many commands kaggle datasets list kaggle competitions list ... ``` -------------------------------- ### Run Kaggle OAuth Login Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/auth.md Initiates the Kaggle OAuth login flow to store credentials. Use `--no-launch-browser` to get an auth URL instead of opening a browser. ```bash kaggle auth login ``` ```bash kaggle auth login --no-launch-browser ``` ```bash kaggle auth login --force ``` -------------------------------- ### Download Kernel Output from a Specific Page Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/kernels.md Retrieves kernel output files starting from a specific page, identified by a page token. Use --page-token to specify the starting page. ```bash kaggle kernels output --page-token ``` -------------------------------- ### dataset-metadata.json with File Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/datasets_metadata.md An advanced `dataset-metadata.json` example that includes detailed file metadata, schema definitions, keywords, and other dataset properties. Use this for richer dataset descriptions. ```json { "title": "My Awesome Dataset", "subtitle": "My awesomer subtitle", "description": "My awesomest description", "id": "timoboz/my-awesome-dataset", "id_no": 12345, "licenses": [{"name": "CC0-1.0"}], "resources": [ { "path": "my-awesome-data.csv", "description": "This is my awesome data!", "schema": { "fields": [ { "name": "StringField", "description": "String field description", "type": "string" }, { "name": "NumberField", "description": "Number field description", "type": "number" }, { "name": "DateTimeField", "description": "Date time field description", "type": "datetime" } ] } }, { "path": "my-awesome-extra-file.txt", "description": "This is my awesome extra file!" } ], "keywords": [ "beginner", "tutorial" ], "expectedUpdateFrequency": "monthly", "userSpecifiedSources": "World Bank and OECD ([link](http://data.worldbank.org/indicator/NY.GDP.MKTP.CD))", "image": "relative/path/to/new/image.png" } ``` -------------------------------- ### Model Slug Normalization Examples Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/benchmarks.md Demonstrates the flexible input formats for model names accepted by the CLI and how they are normalized to a canonical slug for server communication and clean output/directory structures. ```bash # Canonical Slugs (recommended): gemini-2.5-pro or claude-sonnet-4 # With Provider Prefix: google/gemini-2.5-pro or anthropic/claude-sonnet-4 # With Version/Proxy @ symbols: anthropic/claude-haiku-4-5@20251001 or claude-sonnet-4-6@default ``` ```bash # Status Display: claude-haiku-4-5-20251001 and gemini-2.0-flash-lite-001 # Hierarchical Downloads: .///claude-haiku-4-5-20251001// ``` -------------------------------- ### Define and Run a Benchmark Task Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/benchmarks.md Defines a simple benchmark task using the @kbench.task decorator and then runs it with a specified LLM. Ensure the kbench library is installed and configured. ```python # %% @kbench.task(name="sample-task") def sample_task(llm): response = llm.prompt("What is 2 + 2?") kbench.assertions.assert_in("4", response, expectation="Should contain 4") sample_task.run(kbench.llm) ``` -------------------------------- ### Create Placeholder for Updated Model Files Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Create or update model files for a new version of an existing model variation. This example creates a placeholder for updated JAX model parameters. ```bash # In the my-new-model directory ``` ```bash echo "Updated JAX model parameters for V2" > flax_model_v2.params ``` -------------------------------- ### Download All Competition Files Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/competitions.md Downloads all files for the 'titanic' competition to the current directory, overwriting existing files, quietly. Use this to get all competition data. ```bash kaggle competitions download titanic -w -o -q ``` -------------------------------- ### Download Specific File Types from Kernel Output Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/kernels.md Downloads only files matching a specified regex pattern from a kernel's output. This example filters for PNG files. ```bash kaggle kernels output --file-pattern ".*\.png$" ``` -------------------------------- ### View or Download Competition Leaderboard Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/competitions.md Inspects or downloads competition leaderboard data. Use `--show` to display top rows or `--download` to get the full leaderboard. The `-p` flag specifies the download directory. ```bash kaggle competitions leaderboard titanic --show ``` ```bash kaggle c leaderboard titanic --download -p leaderboards ``` -------------------------------- ### Task Name Normalization Example Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/benchmarks.md Illustrates how the Kaggle CLI automatically normalizes task names to URL-safe slugs. A warning is printed when normalization occurs, suggesting the use of the generated slug in future commands. ```bash ⚠ Warning: task name 'My Test Task' was normalized to slug 'my-test-task'. Use 'my-test-task' in future commands. ``` -------------------------------- ### Initialize Kaggle Benchmarks Environment Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Initializes the local benchmark development environment by fetching credentials and default variables, and generating starter files. Use `-y` for automatic confirmation. ```bash kaggle b init -y ``` -------------------------------- ### kaggle models get Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/models.md Gets model metadata for a specified model handle and optionally downloads it to a folder. ```APIDOC ## kaggle models get ### Description Gets model metadata for a specified model handle and optionally downloads it to a folder. ### Usage ```bash kaggle models get [options] ``` ### Arguments - ``: Model handle in `/` format. ### Options - `-p, --path `: Folder to download model metadata to. ### Examples ```bash kaggle models get google/gemma -p metadata ``` ### Purpose Download metadata for an existing model. ``` -------------------------------- ### Download Competition Data Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/simulation_competitions.md Download the starter kit and any provided data for the competition. Use the -p flag to specify a download directory. ```bash kaggle competitions download connectx -p connectx-data ``` -------------------------------- ### Initialize Dataset Metadata File Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/datasets.md Create a template `dataset-metadata.json` file in a specified folder for defining a new Kaggle dataset. ```bash kaggle datasets init -p tests/dataset ``` -------------------------------- ### Create and Navigate to Competition Directory Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Use these bash commands to create a new directory for your competition files and change into it. ```bash mkdir titanic-competition cd titanic-competition ``` -------------------------------- ### Initialize Kaggle Benchmarks Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/benchmarks.md Initializes Kaggle benchmarks, typically for authentication or setting up credentials. ```bash kaggle b init -y ``` ```bash # or just: kaggle b auth -y ``` -------------------------------- ### Get Model Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/models.md Downloads metadata for an existing model. Specify the model handle and an optional path to save the metadata. ```bash kaggle models get google/gemma -p metadata ``` -------------------------------- ### kaggle models init Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/models.md Creates a starter `model-metadata.json` file in a specified folder to bootstrap model metadata before creation. ```APIDOC ## kaggle models init ### Description Creates a starter `model-metadata.json` file in a specified folder to bootstrap model metadata before creation. ### Usage ```bash kaggle models init [options] ``` ### Options - `-p, --path `: Folder where metadata will be written. ### Examples ```bash kaggle models init -p my-model ``` ### Purpose Bootstrap model metadata before creation. ``` -------------------------------- ### Initialize Dataset Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/datasets.md Bootstrap metadata before creating a dataset. This command generates a starter `dataset-metadata.json` file in a specified folder. ```bash kaggle datasets init -p my-dataset ``` -------------------------------- ### Get Existing Model Metadata with Kaggle API Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/models_metadata.md Retrieve the metadata for an existing Kaggle model using its owner and slug. ```bash kaggle models get username/model-slug ``` -------------------------------- ### Get Model Variation Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/model_variations.md Downloads the `model-instance-metadata.json` file for a specified model variation. The model variation is identified by its URL suffix. ```bash kaggle models variations get $KAGGLE_DEVELOPER/test-model/jax/main -p tmp ``` -------------------------------- ### Push Benchmark Task to Kaggle (Recommended) Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/benchmarks.md Pushes a local benchmark task file to Kaggle and waits for server-side creation to complete. This is the recommended approach for ensuring the task is ready. ```bash kaggle b t push my-task -f task.py --wait ``` -------------------------------- ### Get Kaggle Kernel Status Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/kernels.md Displays the status of the latest run for a specified Kaggle kernel. This indicates if the kernel is running, completed, or failed. ```bash kaggle kernels status kerneler/sqlite-global-default ``` -------------------------------- ### Unzip Competition Files Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Extract the contents of the downloaded competition zip file to access individual data files. Ensure you have an unzip utility installed. ```bash # Make sure you have unzip installed, or use your OS's GUI to extract # The actual zip file name might vary based on the competition. unzip titanic.zip ``` -------------------------------- ### Create and Navigate to Analysis Directory Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Create a new directory for analyzing a dataset and navigate into it. This is a common practice before downloading data. ```bash mkdir iris-dataset-analysis cd iris-dataset-analysis ``` -------------------------------- ### List messages for a competition topic Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/competitions.md Basic usage to list messages for a specific competition and topic ID. Ensure you have the Kaggle CLI installed and configured. ```bash kaggle competitions topic-messages titanic 12345 ``` -------------------------------- ### Create and Navigate to Dataset Directory Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Use these commands to create a new directory for your dataset and navigate into it. This is the first step in creating a new dataset. ```bash mkdir my-new-dataset cd my-new-dataset ``` -------------------------------- ### Push Task to Server and Run Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/benchmarks.md Pushes a task file to the server, waits for completion, then runs the task against a specified model and waits again. Finally, it downloads the results. ```bash kaggle b t push my-task -f task.py --wait && kaggle b t run my-task -m gemini-2.5-pro --wait && kaggle b t download my-task -o ./results ``` -------------------------------- ### Get Kernel Logs Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/kernels.md Prints execution logs from the latest kernel run. Use `--follow` to continuously poll for new log lines. ```bash kaggle kernels logs owner/kernel-slug ``` ```bash kaggle k logs owner/kernel-slug --follow --interval 10 ``` -------------------------------- ### Initialize Kernel Metadata File Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/kernels.md Initializes a kernel-metadata.json file in a specified folder. ```bash kaggle kernels init -p tests/kernel ``` -------------------------------- ### Run Hatch Commands Inside Docker Source: https://github.com/kaggle/kaggle-cli/blob/main/README.md Execute hatch commands within a Docker container for a consistent environment. This example shows running lint:all. ```sh # Use default Python version ./docker-hatch run lint:all ``` -------------------------------- ### Initialize New Model with Kaggle API Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/models_metadata.md Use this command to initialize a new model and generate the basic 'model-metadata.json' file using the Kaggle CLI. ```bash kaggle models init -p /path/to/model ``` -------------------------------- ### Kaggle CLI Help Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/README.md Display the help message to list all available commands in the Kaggle CLI. ```sh kaggle --help ``` -------------------------------- ### Create Sample Data File Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Generate a sample CSV file with header and a few rows of data. This file will be uploaded as part of your new dataset. ```bash echo "id,col_a,col_b,col_c" > sample_data.csv echo "1,0.5,0.2,0.8" >> sample_data.csv echo "2,0.1,0.7,0.3" >> sample_data.csv echo "3,0.9,0.4,0.6" >> sample_data.csv ``` -------------------------------- ### Unzip Downloaded Dataset Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Extract the contents of a downloaded dataset ZIP archive. This makes the data files accessible for analysis. Ensure you have an unzip utility installed. ```bash # Make sure you have unzip installed, or use your OS's GUI to extract # The actual zip file name might vary based on the dataset. # For uciml/iris, it's iris.zip unzip iris.zip ``` -------------------------------- ### Get Kaggle Dataset Creation Status Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/datasets.md Check the creation status of a dataset after initiating a create or version update operation. Requires the dataset URL suffix. ```bash kaggle datasets status ``` ```bash kaggle datasets status goefft/public-datasets-with-file-types-and-columns ``` -------------------------------- ### Download Competition Files Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Download all necessary competition files, such as training data and sample submissions, using the Kaggle CLI. ```bash kaggle competitions download -c titanic ``` -------------------------------- ### Get Dataset Creation Status Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/datasets.md Check the completion status of dataset creation or versioning. The `--format` option allows specifying output formats like `json`. ```bash kaggle datasets status owner/dataset ``` ```bash kaggle d status owner/dataset --format json ``` -------------------------------- ### Quick Push-Run-Download Sequence Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/benchmarks.md A streamlined command to push a task, run it, and download results sequentially, waiting for each step to complete. ```bash # Push and wait, then run and wait, all in sequence kaggle b t push my-task -f task.py --wait && kaggle b t run my-task -m gemini-2.5-pro --wait && kaggle b t download my-task -o ./results ``` -------------------------------- ### Download and Unzip Dataset with Options Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/datasets.md Download a dataset, extract its contents to a specified path, overwrite existing files, and suppress output. ```bash kaggle datasets download goefft/public-datasets-with-file-types-and-columns -p tmp --unzip -o -q ``` -------------------------------- ### Initialize Dataset Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md This command creates a `dataset-metadata.json` file in your current directory, which is required for dataset creation. You will need to edit this file with your dataset's title and slug. ```bash kaggle datasets init ``` -------------------------------- ### Get Model Variation Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/model_variations.md Downloads metadata for a specific model variation. The variation is identified by owner, model, framework, and variation slug. Metadata is saved to the specified folder. ```bash kaggle models variations get google/gemma/pytorch/7b -p metadata ``` -------------------------------- ### Create Kaggle Dataset Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Upload your dataset files (e.g., `sample_data.csv`) and metadata (`dataset-metadata.json`) to Kaggle. Add `--public` to make the dataset public immediately. ```bash kaggle datasets create -p . ``` -------------------------------- ### Run Production Tests Source: https://github.com/kaggle/kaggle-cli/blob/main/README.md Execute tests against the live kaggle.com server. Ensure your environment is set up correctly. ```sh # Run against kaggle.com hatch run test:prod ``` -------------------------------- ### Create New Model Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Upload your model files and metadata to Kaggle. Ensure model-metadata.json is correctly configured before running. ```bash kaggle models create -p . ``` -------------------------------- ### List messages with sorting and page size Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/competitions.md Advanced usage to list messages for a competition topic, specifying the sort order and the maximum number of messages to retrieve. Use '-1' for page-size to get all messages. ```bash kaggle competitions topic-messages titanic 12345 --sort-by old -n 50 ``` -------------------------------- ### Download Benchmark Task Outputs with Source Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Downloads output files for a benchmark task, including the kernel session's source notebooks. Use this when you need both the results and the code used to generate them. ```bash kaggle b t download my-task --include-source ``` -------------------------------- ### Initialize Model Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/models.md Creates a template model-metadata.json file in a specified directory. This file is essential for defining your model's details before creation. ```bash mkdir tmp kaggle models init -p tmp ``` -------------------------------- ### Pull Kernel Code Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/kernels.md Pulls source code from a Kaggle kernel. Can download to a specific path (`-p`) or the current working directory (`-w`). Metadata can also be generated during the pull (`-m`). `kaggle k get` is an alias. ```bash kaggle kernels pull owner/kernel-slug -p pulled kaggle kernels get owner/kernel-slug -w -m kaggle k pull owner/kernel-slug/3 -w -m ``` -------------------------------- ### Initialize Model Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md This command generates a model-metadata.json file in the current directory, which is necessary for creating a new model. ```bash kaggle models init ``` -------------------------------- ### Create a New Kaggle Dataset Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/datasets.md Use this command to upload local data files and metadata to create a new dataset on Kaggle. Ensure the dataset-metadata.json file is properly edited before execution. ```bash kaggle datasets create -p ``` ```bash # Example: Edit dataset-metadata.json first # sed -i 's/INSERT_TITLE_HERE/My Dataset Title/' tests/dataset/dataset-metadata.json # sed -i 's/INSERT_SLUG_HERE/my-dataset-slug/' tests/dataset/dataset-metadata.json kaggle datasets create -p tests/dataset --public -q -t -r skip ``` -------------------------------- ### Create Local Directory for Model Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Use this command to create a new directory for your model project and navigate into it. ```bash mkdir my-new-model cd my-new-model ``` -------------------------------- ### Create a New Dataset Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/datasets.md Upload local files and metadata to create a Kaggle dataset. Options include making the dataset public, suppressing output, and handling tabular data. ```bash kaggle datasets create -p my-dataset -u -q -t -r skip ``` -------------------------------- ### Download Competition Dataset Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Use this command to download the dataset for a specific Kaggle competition. Replace `` with the actual competition identifier. ```bash kaggle competitions download -c ``` -------------------------------- ### Run Integration Tests Source: https://github.com/kaggle/kaggle-cli/blob/main/README.md Execute integration tests locally after setting up Kaggle credentials. Refer to authentication instructions. ```sh hatch run test:integration ``` -------------------------------- ### Download Run Outputs to a Custom Directory Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/benchmarks.md Download the run outputs for a benchmark task to a specified local directory. Use the -o option to set the output path. ```bash kaggle b t download my-task -o ./results ``` -------------------------------- ### Authenticate Kaggle Benchmarks Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Fetches Model Proxy credentials and persists them to an environment file. Use the `-y` flag to skip confirmation prompts. ```bash kaggle b auth -y ``` -------------------------------- ### Submit to Standard Competition Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/competitions.md Submits 'sample_submission.csv' to the 'house-prices-advanced-regression-techniques' competition with a 'Test message'. Use this for standard competition submissions. ```bash kaggle competitions submit house-prices-advanced-regression-techniques -f sample_submission.csv -m "Test message" ``` -------------------------------- ### Initialize New Model Variation with Kaggle API Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/models_metadata.md Use this command to initialize a new model variation and generate the basic 'model-instance-metadata.json' file using the Kaggle CLI. ```bash kaggle models variations init -p /path/to/model-variation ``` -------------------------------- ### Push a Kaggle Kernel Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/kernels.md Uploads a local kernel file and its metadata to Kaggle, then runs the kernel. Specify the path to the folder containing the kernel file and metadata. ```bash kaggle kernels push -p ``` ```bash kaggle kernels push -p tests/kernel ``` -------------------------------- ### Redirect Kaggle Competition Leaderboard to File Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/competitions.md Downloads the entire leaderboard for a competition and redirects the output to a text file. ```bash kaggle competitions leaderboard titanic > leaderboard.txt ``` -------------------------------- ### Kaggle CLI Authentication Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/SKILL.md Demonstrates various methods for authenticating with the Kaggle API. ```bash kaggle auth login # or set KAGGLE_API_TOKEN # or place an access token in ~/.kaggle/access_token # or use legacy ~/.kaggle/kaggle.json credentials ``` -------------------------------- ### Push a benchmark task and return immediately Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Use this command to create or update a benchmark task from a local Python file and receive confirmation without waiting for the process to complete. ```bash kaggle b t push my-task -f benchmark.py ``` -------------------------------- ### Push a benchmark task with datasets and wait for completion Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Combines pushing a benchmark task with attached datasets and waiting for its creation to finish. Ensures datasets are correctly associated and the task is ready. ```bash kaggle b t push my-task -f benchmark.py --wait -d kaggle/titanic ``` -------------------------------- ### Create Local Directory for Kernel Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Use this command to create a new directory for your kernel project and navigate into it. ```bash mkdir my-kernel-project cd my-kernel-project ``` -------------------------------- ### Kaggle CLI Authentication Command Hierarchy Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/auth.md Shows the available subcommands under `kaggle auth`. ```text kaggle auth ├── login ├── print-access-token └── revoke ``` -------------------------------- ### Pull a Kaggle Kernel with Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/kernels.md Downloads the code and metadata for a specified Kaggle kernel into a target folder. Use the -m flag to include metadata. ```bash kaggle kernels pull -p tests/kernel $KAGGLE_DEVELOPER/exercise-as-with -m ``` -------------------------------- ### Copy Sample Submission Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Create your submission file by copying the provided sample submission. In a real scenario, this file would be generated from model predictions. ```bash cp gender_submission.csv my_submission.csv ``` -------------------------------- ### Download Kaggle Competition Leaderboard Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/competitions.md Downloads the entire leaderboard for a competition to a specified folder, quietly. ```bash kaggle competitions leaderboard titanic -d -p leaders -q ``` -------------------------------- ### Download Competition Files Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/competitions.md Downloads competition data files. Use `-f` to specify a single file and `-p` to set the download directory. The `-w` flag downloads to the current working path, and `-o` forces the download. ```bash kaggle competitions download titanic ``` ```bash kaggle competitions download titanic -f train.csv -p data ``` ```bash kaggle c download -w -o -q ``` -------------------------------- ### List Competition Topics Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/simulation_competitions.md Browse the competition's discussion forum to see participant conversations. Sort and paginate results for better organization. ```bash kaggle competitions topics list connectx ``` ```bash kaggle competitions topics list connectx -s top --page-size 10 ``` -------------------------------- ### Run a benchmark task with interactive model selection Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Executes a previously pushed benchmark task. If no models are specified, an interactive prompt will appear to select models for the run. ```bash kaggle b t run my-task ``` -------------------------------- ### Download All Benchmark Task Outputs Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Downloads output files for all completed runs of a benchmark task. Use this to retrieve results from your tasks. ```bash kaggle b t download my-task ``` -------------------------------- ### View Kaggle CLI Configuration Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/configuration.md Displays the current configuration values for the Kaggle CLI. Use this to inspect your current settings. ```bash kaggle config view ``` -------------------------------- ### Create Placeholder Model File Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Create a placeholder file for model parameters within your model directory. This is a preparatory step before initializing model variation metadata. ```bash # In the my-new-model directory ``` ```bash echo "This is a placeholder for JAX model parameters" > flax_model.params ``` -------------------------------- ### Push a benchmark task and wait for creation to finish Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md This command pushes a benchmark task and waits for its creation to complete before returning. Useful for ensuring the task is ready before proceeding. ```bash kaggle b t push my-task -f benchmark.py --wait ``` -------------------------------- ### Push a benchmark task with attached Kaggle datasets Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md This command pushes a benchmark task and attaches specified Kaggle datasets to its underlying notebook. Datasets are mounted at `/kaggle/input//` by default. ```bash kaggle b t push my-task -f benchmark.py -d kaggle/titanic -d user/my-dataset ``` -------------------------------- ### List Competition Files Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/competitions.md Lists data files for a specified competition. The `-q` flag suppresses extra output, and `-v` outputs in CSV format. ```bash kaggle competitions files titanic ``` ```bash kaggle c files titanic --page-size 3 -v -q ``` -------------------------------- ### Pull Existing Kernel with Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Download an existing kernel along with its metadata. The -m flag is required for pushing updates later. ```bash # Replace YOUR_USERNAME with your actual Kaggle username kaggle kernels pull YOUR_USERNAME/my-cli-test-kernel -m ``` -------------------------------- ### List Available Benchmark Models Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Retrieves and displays a table of all models that are available for use in benchmark tasks. This command is useful for discovering valid model slugs for other benchmark operations. ```bash kaggle b t models ``` -------------------------------- ### List Datasets by License and Tags Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/datasets.md Filter datasets by license type, associated tags, and a search term. ```bash kaggle datasets list --license odb --tags internet --search telco ``` -------------------------------- ### Publish a Benchmark Task Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/benchmarks.md Publishes a benchmark task, optionally including its backing notebook. This command is idempotent; re-publishing an already public task will succeed without changes. Unpublishing is not supported. ```bash kaggle benchmarks tasks publish [options] ``` ```bash # Publish a task and its backing notebook (default) kaggle b t publish my-task ``` ```bash # Publish without the backing notebook kaggle b t publish my-task --no-publish-backing-notebook ``` -------------------------------- ### Load Environment Variables and Run Locally Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/benchmarks.md Sources a .env file to load environment variables and then runs a task file locally using Python. ```bash # Source the .env file to set MODEL_PROXY_URL, MODEL_PROXY_API_KEY, etc. set -a && source .env && set +a # Run your task file directly with Python python task.py ``` -------------------------------- ### List Kernels Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/kernels.md Lists available kernels with various filtering and sorting options. Use `kaggle k` as a shorthand. ```bash kaggle kernels list kaggle kernels list --user kaggle --language python --sort-by dateRun kaggle k list -m -v ``` -------------------------------- ### Submit Agent via Notebook Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/simulation_competitions.md Submit an agent using an existing Kaggle notebook. Specify the notebook reference, the agent file, and a version tag. ```bash kaggle competitions submit connectx -k YOUR_USERNAME/connectx-agent -f submission.tar.gz -v 1 -m "Notebook agent v1" ``` -------------------------------- ### List All Kaggle Forums Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/forums.md Lists all available discussion forums on Kaggle. Use the -v flag to output in CSV format. ```bash kaggle forums -v ``` -------------------------------- ### Create a new version for a model variation Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/model_variations_versions.md Upload a new file snapshot for an existing variation. Specify the local folder containing the new files with `-p`, add notes with `-n`, and control progress output with `-q`. The `--dir-mode` option (`skip`, `zip`, `tar`) determines how directories are handled. ```bash kaggle models variations versions create owner/model/jax/main -p tmp -n "Updated files" -q -r skip ``` -------------------------------- ### Download Competition Leaderboard Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Retrieve the leaderboard for a Kaggle competition. Replace `` with the competition's identifier. ```bash kaggle competitions leaderboard ``` -------------------------------- ### Download Specific Model Outputs to Custom Directory Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Downloads output files for a specific model of a benchmark task into a designated directory. Use this for organized retrieval of model-specific results. ```bash kaggle b t download my-task -m gemini-2.5-pro -o ./results ``` -------------------------------- ### List Kaggle Forums Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/forums.md Lists all available Kaggle discussion forums. Use this to find forum slugs for subsequent commands. ```bash kaggle forums kaggle forums list -v kaggle f list -q ``` -------------------------------- ### Initialize Model Variation Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/model_variations.md Initializes a `model-instance-metadata.json` file for a new model variation. This file requires editing with owner, parent model, variation slugs, and framework details. ```bash kaggle models variations init -p tmp ``` -------------------------------- ### Publish Kaggle Benchmark Task Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Publishes a benchmark task and its backing notebook. Use the --no-publish-backing-notebook flag to publish only the task metadata. ```bash kaggle b t publish my-task ``` ```bash kaggle b t publish my-task --no-publish-backing-notebook ``` -------------------------------- ### Show Kaggle CLI Quota in CSV Format Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/quota.md Displays the current weekly GPU and TPU accelerator quota in CSV format. Use this option for programmatic parsing of quota information. ```bash kaggle quota -v ``` -------------------------------- ### Run Kaggle CLI Command from Source (One-liner) Source: https://github.com/kaggle/kaggle-cli/blob/main/README.md Execute a single Kaggle CLI command directly using hatch. This is useful for quick checks or single operations. ```sh hatch run kaggle datasets list ``` -------------------------------- ### List Input Directory Files in Kaggle Source: https://github.com/kaggle/kaggle-cli/blob/main/tests/kernel/testing-x.ipynb This snippet shows how to iterate through the '/kaggle/input' directory and print the full path of all files found. It's useful for understanding the data available in your Kaggle environment. ```python # This Python 3 environment comes with many helpful analytics libraries installed # It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python # For example, here's several helpful packages to load import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) # Input data files are available in the read-only "../input/" directory # For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory import os for dirname, _, filenames in os.walk('/kaggle/input'): for filename in filenames: print(os.path.join(dirname, filename)) # You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All" # You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session ``` -------------------------------- ### Submit Multi-File Agent Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/simulation_competitions.md Bundle multiple agent files (including main.py at the root) into a submission.tar.gz archive for submission. This is for agents spanning several files. ```bash tar -czf submission.tar.gz main.py helper.py model_weights.pkl kaggle competitions submit connectx -f submission.tar.gz -m "Multi-file agent v1" ``` -------------------------------- ### Pull a Kaggle Kernel to Current Directory Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/kernels.md Downloads the code for a specified Kaggle kernel directly into the current working directory. Use the --wp flag for this. ```bash kaggle kernels pull --wp $KAGGLE_DEVELOPER/exercise-as-with ``` -------------------------------- ### List Kaggle Benchmark Discussion Topics Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/benchmarks.md Lists discussion topics for a specified benchmark. Supports sorting and searching. ```bash kaggle benchmarks topics list kaggle/chess ``` -------------------------------- ### Create a New Kaggle Model Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/models.md Creates a new model on Kaggle using a local model-metadata.json file and associated model files. Ensure the metadata file is properly edited before execution. ```bash # Example: Edit model-metadata.json first # sed -i 's/INSERT_OWNER_SLUG_HERE/your-username/' tmp/model-metadata.json # sed -i 's/INSERT_TITLE_HERE/My Awesome Model/' tmp/model-metadata.json # sed -i 's/INSERT_SLUG_HERE/my-awesome-model/' tmp/model-metadata.json kaggle models create -p tmp ``` -------------------------------- ### Download Simulation Episode Replay Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/competitions.md Downloads the replay artifact for a simulation episode. Specify a destination folder using the -p option. ```bash kaggle competitions replay -p replays ``` ```bash kaggle competitions replay 987654 -p replays ``` -------------------------------- ### Kaggle CLI Authentication - OAuth Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/README.md Initiate the OAuth login flow for Kaggle user authentication. ```sh kaggle auth login ``` -------------------------------- ### List Available Datasets Source: https://github.com/kaggle/kaggle-cli/blob/main/skills/references/datasets.md Use this command to find dataset handles in / format. Various options are available for filtering and sorting. ```bash kaggle datasets list kaggle datasets list -s "bird observation" --file-type csv kaggle d list --user kaggle --sort-by votes -v ``` -------------------------------- ### Initialize Model Variation Metadata Source: https://github.com/kaggle/kaggle-cli/blob/main/docs/tutorials.md Initialize the metadata for a new model variation. This command creates the `model-instance-metadata.json` file in the current directory. ```bash # Still in the my-new-model directory ``` ```bash kaggle models variations init ```