> ## Documentation Index
> Fetch the complete documentation index at: https://rasa.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Model Download API for CI Integration

> GraphQL API for retrieving download URLs for trained models and input data from Rasa Studio for CI/CD integration.

## Introduction

The Model Download API provides external access to retrieve download URLs for artifacts generated in Rasa Studio, facilitating CI/CD integration.
Built with GraphQL, this API allows queries to request trained assistant models and associated input data in YAML format.

## Requirements

* Required API Role `Model download urls`. See [Authorization](/docs/reference/api/studio/api-authorization) to learn how to get an access token.

  <img src="https://mintcdn.com/rasa-43f32701/XHj2VCWI4cZ6KSTn/images/legacy/studio/security/keycloak-service-accounts-roles-model-download-urls.png?fit=max&auto=format&n=XHj2VCWI4cZ6KSTn&q=85&s=f5ec11e8e975a57aea51bc91bef743b6" alt="image" width="2550" height="1096" data-path="images/legacy/studio/security/keycloak-service-accounts-roles-model-download-urls.png" />
* Assistant API ID. See [authorization guide for configuration](/docs/studio/installation/setup-guides/authorization-guide) for more details.

  <img src="https://mintcdn.com/rasa-43f32701/3m_1rqabZkSRtSZi/images/legacy/studio/tutorial/studio-assistant-api-id.png?fit=max&auto=format&n=3m_1rqabZkSRtSZi&q=85&s=ff2bf9d3b50e3df58912916485677f85" alt="image" width="2329" height="1708" data-path="images/legacy/studio/tutorial/studio-assistant-api-id.png" />
* Assistant Version Name. See [user guide for training](/docs/studio/test/train-your-assistant) for more details.

  <img src="https://mintcdn.com/rasa-43f32701/3m_1rqabZkSRtSZi/images/legacy/studio/tutorial/studio-assistant-version-name.png?fit=max&auto=format&n=3m_1rqabZkSRtSZi&q=85&s=73757a8974c8daab4e9f5f177d717672" alt="image" width="2548" height="1956" data-path="images/legacy/studio/tutorial/studio-assistant-version-name.png" />

## Available APIs

### Query: `ModelDownloadUrls`

**Schema:**

```graphql theme={null}
  type Query {
    modelDownloadUrls(input: ModelDownloadUrlsInput!): ModelDownloadUrlsOutput!
  }

  input ModelDownloadUrlsInput {
    assistantId: ID!
    assistantVersionName: ID
  }

  type ModelDownloadUrlsOutput {
    modelFileUrl: String!
    modelInputUrl: String!
  }
```

#### Input: `ModelDownloadUrlsInput`

| Field                  | Description                                                     |
| ---------------------- | --------------------------------------------------------------- |
| `assistantId`          | Unique identifier of the assistant.                             |
| `assistantVersionName` | Optional version of the trained assistant. Default is `latest`. |

#### Output: `ModelDownloadUrlsOutput`

| Field           | Description                                                       |
| --------------- | ----------------------------------------------------------------- |
| `modelFileUrl`  | Url to download the model file `<assistant-version-name>.tar.gz`. |
| `modelInputUrl` | Url to download the model input data in YAML format.              |

## Usage

The query can be used to fetch the download URLs for the trained model and the input data in YAML format for a assistant.

### Example `curl` Request

Request the Model Download API using e.g. `curl`:

```bash theme={null}
curl -X POST https://<api-url>/api/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access-token>" \
-d '{
    "query": "query ModelDownloadUrls($input: ModelDownloadUrlsInput!) { modelDownloadUrls(input: $input) { modelFileUrl modelInputUrl } }",
    "variables": {
      "input": {
        "assistantId": "<assistant-id>",
        "assistantVersionName": "<assistant-version-name>"
      }
    }
  }'
```

### Example Response

The response will contain the download URLs for the trained model and the model input data.

```bash theme={null}
{"data":
  {"modelDownloadUrls":
    {
      "modelFileUrl":"https://<api-url>/api/v1/download/model-file/<assistant-version-name>",
      "modelInputUrl":"https://<api-url>/api/v1/download/model-input/<assistant-version-name>"
    }
  }
}
```

### Download model file

To download the model file, request the `modelFileUrl` with authorization header.

```bash theme={null}
curl "https://<api-url>/api/v1/download/model-file/<assistant-version-name>" \
    -H "Authorization: Bearer <access-token>" \
    -O -J
```

The downloaded model file `<assistant-version-name>.tar.gz` can be used to deploy the trained model.

### Download model input data

To download the model input YAML files, request the `modelInputUrl` with authorization header.

```bash theme={null}
curl "https://<api-url>/api/v1/download/model-input/<assistant-version-name>" \
    -H "Authorization: Bearer <access-token>" \
    -O -J
```

The downloaded model input zipped directory `<assistant-version-name>_model-input.tar.gz` contains the model input data in YAML format:

* `data/flows.yaml`
* `data/nlu.yaml`
* `config.yaml`
* `credentials.yaml`
* `domain.yaml`
* `endpoints.yaml`


## Related topics

- [Studio Change Log](/docs/reference/changelogs/studio-changelog.md)
- [Setting Up CI/CD](/docs/pro/deploy/ci-cd.md)
- [Rasa MCP Tools API Reference](/docs/reference/api/rasa-mcp-tools.md)
- [Authorization](/docs/reference/api/studio/api-authorization.md)
- [Model Storage](/docs/reference/integrations/model-storage.md)
