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

# Models API

For a brief overview of GraphQL itself, please consult our introduction.

### Querying for Models

Models belong to a `Space`. Because of this, you can either query for models off of a `Space` node or a `Model` node directly.

<Info>
  The model or space id is in the url when you visit the corresponding page. The format looks like this: `spaces/:``space`**\_id**`/models/:``model_id``.`

  You can also query for a list of models given the space id. More details here.
</Info>

<CodeGroup>
  ```graphql Query Model Directly theme={null}
  query {
    node(id: "model_id") {
      ... on Model {
        name
        modelType
        uri
      }
    }
  }
  ```

  ```graphql Query by Space theme={null}
  query {
    node(id: "space_id") {
      ... on Space {
        models(first: 50) {
          edges {
            node {
              id
              name
            }
          }
        }
      }
    }
  }
  ```
</CodeGroup>

The `ModelsConnection` off of `Space` provides a convenient way for you to pull models that match the given criteria. If you have a large number of models, you will have to use pagination to pull the complete list. This data can then be structured to your liking and be exported to the platform of your choosing.

### Model Versions

You can query for `modelVersions` using the model node. If you have a large number of versions, you will have to use pagination to pull the complete list.

```graphql theme={null}
query getModelVersion($modelID: ID!) {
        model: node(id: $modelID) {
            ... on Model {
                id
                name
                modelType
                modelVersions(first:1) {
                    edges {
                        node {
                          modelVersionBatches{
                            edges{
                              node{
                                id
                              }
                            }
                          }
                        }
                    }
                }
            }
        }
    }
```

**Variables**

```json theme={null}
{"modelID": "model_id"}
```

### Model Schema

You can query your model's schema through the [Arize GraphQL API](/ax/graphql-reference). The `ModelSchema` type contains important information about your models such as `features` , `tags`, `predictions` and `actuals` which is useful when programmatically creating Monitors.

For more examples see the [Monitors API documentation](/ax/graphql-reference/apis/monitors-api).

<Info>
  Querying a Model's schema can return the equivalent of thousands of REST requests, resulting in a high computation cost on our servers. Be mindful of your complexity score to ensure your call falls within our complexity cost limit. More details here.
</Info>

```graphql theme={null}
query {
  node(id: "model_id") {
    ... on Model {
      name
      modelSchema {
        features(first: 10) {
          edges {
            node {
              dimension {
                name
              }
            }
          }
        }
      }
    }
  }
}
```

### Tracing Schema

You can query your project's schema through [Arize GraphQL API](/ax/graphql-reference). The `tracingSchema` type contains important information about your application such as `spanProperties` , `llmEvals`, and `annotations.`

```graphql theme={null}
query TraciningSchemaQuery(
  $id: ID!, 
  $startTime: DateTime!, 
  $endTime: DateTime!) {
  model: node(id: $id) {
    ... on Model {
      tracingSchema(startTime: $startTime, endTime: $endTime) {
        spanProperties(first: 50) {
          edges {
            node {
              dimension {
                name
                dataType
                category
              }
            }
          }
        }
        llmEvals(first: 50) {
          edges {
            node {
              dimension {
                name
                dataType
                category
              }
            }
          }
        }
        annotations(first: 50) {
          edges {
            node {
              dimension {
                name
                dataType
                category
              }
            }
          }
        }
      }
    }
  }
}
```

**Variables**

```json theme={null}
{
  "id": "MODEL_ID",
  "startTime": "2024-08-14T06:00:00.000Z",
  "endTime": "2024-09-13T17:59:59.999Z"
}
```

### Dimension Configuration

You can query binning information relating to your model's `features`, `actuals`, `predictions` and `tags` .

<Tabs>
  <Tab title="Query by Model Schema">
    ```graphql theme={null}
    query {
      node(id: "model_id") {
        ... on Model {
          name
          modelSchema {
            features(first: 10) {
              edges {
                node {
                  dimensionConfig {
                    id
                    dimensionName
                    dimensionCategory
                    numBins
                    binOption
                    bins
                  }
                }
              }
            }
          }
        }
      }
    }
    ```
  </Tab>

  <Tab title="Create / Update a Dimension Configuration">
    ```graphql theme={null}
    mutation CreateOrUpdateDimensionConfiguration(
      $input: UpdateDimensionConfigMutationInput!
    ) {
      updateDimensionConfig(input: $input) {
        dimensionConfig {
          dimensionName
          binOption
          numBins
          bins
          id
        }
      }
    }
    ```

    **variables**

    ```json theme={null}
    {
      "input": {
        "modelId": "model_id",
        "dimensionName": "dimension_name",
        "dimensionCategory": "featureLabel",
        "binOption": "equalWidth",
        "numBins": 4
      }
    }
    ```
  </Tab>
</Tabs>

### Dimension Details

```graphql theme={null}
query getDimensionDetails($modelId: ID!) {
  node(id: $modelId) {
    ... on Model {
      name
      tracingSchema {
        spanProperties(first: 50, searchTerm: $dimensionName) {
          edges {
            node {
              dimension {
                id
                name
                dataType
                category
              }
            }
          }
        }
      }
    }
  }
}
```

**variables**

```json theme={null}
{
  "modelId": "MODEL_ID"
}
```
