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

# Models

> SDK methods to register, list, retrieve, and manage models in the TrueFoundry model registry.

## Methods

<Accordion title="get">
  Get a model by its ID.

  #### Parameters

  <ParamField body="id" type="str" required />

  #### Returns

  <ResponseField name="GetModelResponse" type="GetModelResponse">
    [🔗 GetModelResponse](/docs/truefoundry_sdk/types#getmodelresponse)

    The model data
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.models.get(
      id="id_value",
  )
  ```
</Accordion>

<Accordion title="delete">
  Delete a model by its ID.

  #### Parameters

  <ParamField body="id" type="str" required />

  #### Returns

  <ResponseField name="EmptyResponse" type="EmptyResponse">
    [🔗 EmptyResponse](/docs/truefoundry_sdk/types#emptyresponse)

    Empty response indicating successful deletion
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.models.delete(
      id="id_value",
  )
  ```
</Accordion>

<Accordion title="list">
  List models with optional filtering by FQN, ML Repo, name, or run ID.

  #### Parameters

  <ParamField body="fqn" type="typing.Optional[str]">
    Fully qualified name to filter models by (format: 'model:{tenant_name}/{ml_repo_name}/{model_name}')
  </ParamField>

  <ParamField body="ml_repo_id" type="typing.Optional[str]">
    ID of the ML Repo to filter models by
  </ParamField>

  <ParamField body="name" type="typing.Optional[str]">
    Name of the model to filter by
  </ParamField>

  <ParamField body="offset" type="typing.Optional[int]">
    Number of models to skip for pagination
  </ParamField>

  <ParamField body="limit" type="typing.Optional[int]">
    Maximum number of models to return
  </ParamField>

  <ParamField body="run_id" type="typing.Optional[str]">
    ID of the run to filter models by
  </ParamField>

  <ParamField body="include_empty_models" type="typing.Optional[bool]">
    Whether to include models that have no versions
  </ParamField>

  #### Returns

  <ResponseField name="SyncPager[Model, ListModelsResponse]" type="SyncPager[Model, ListModelsResponse]">
    [🔗 ListModelsResponse](/docs/truefoundry_sdk/types#listmodelsresponse)

    List of models matching the query with pagination information
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.models.list(
      fqn="value",
      ml_repo_id="value",
      name="value",
      offset=10,
      limit=10,
      run_id="value",
      include_empty_models="value",
  )

  # Iterate through results
  for item in response:
      print(item.name)

  # Or paginate page by page
  for page in response.iter_pages():
      for item in page:
          print(item.name)
  ```
</Accordion>

<Accordion title="create_or_update">
  Create or update a model version.

  #### Parameters

  <ParamField body="manifest" type="ModelManifest" required>
    [🔗 ModelManifest](/docs/truefoundry_sdk/types#modelmanifest)

    Manifest containing metadata for the model to apply
  </ParamField>

  #### Returns

  <ResponseField name="GetModelVersionResponse" type="GetModelVersionResponse">
    [🔗 GetModelVersionResponse](/docs/truefoundry_sdk/types#getmodelversionresponse)

    The created or updated model version
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.models.create_or_update(
      manifest={"key": "value"},
  )
  ```
</Accordion>

<Accordion title="get_by_fqn">
  Get Model by FQN.

  #### Parameters

  <ParamField body="fqn" type="str" required>
    FQN of the model
  </ParamField>

  #### Returns

  <ResponseField name="GetModelResponse" type="GetModelResponse">
    [🔗 GetModelResponse](/docs/truefoundry_sdk/types#getmodelresponse)

    Model details
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.models.get_by_fqn(
      fqn="value",
  )
  ```
</Accordion>
