Skip to content

models.list() throw a pydantic validation error #343

@rogthefrog

Description

@rogthefrog

Describe the bug

These two calls throw an error:

import together
client = together.Together()
client.models.list()

or

together.Models.list()

The error:

<stdin>:1: DeprecationWarning: Call to deprecated function list.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "XXX/.venv/lib/python3.12/site-packages/together/legacy/base.py", line 25, in new_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "XXX/.venv/lib/python3.12/site-packages/together/legacy/models.py", line 23, in list
    return [item.model_dump(exclude_none=True) for item in client.models.list()]
                                                           ^^^^^^^^^^^^^^^^^^^^
  File "XXX/.venv/lib/python3.12/site-packages/together/resources/models.py", line 43, in list
    return [ModelObject(**model) for model in response.data]
            ^^^^^^^^^^^^^^^^^^^^
  File "XXX/.venv/lib/python3.12/site-packages/pydantic/main.py", line 253, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ModelObject
type
  Input should be 'chat', 'language', 'code', 'image', 'embedding' or 'moderation' [type=enum, input_value='audio', input_type=str]
    For further information visit https://errors.pydantic.dev/2.11/v/enum

To Reproduce
Steps to reproduce the behavior: run the examples above.

I'm experiencing the error above using the together client 1.5.7 or 1.2.5.

The first example I listed is out of the official documentation on github.

Expected behavior

I expect a list of models to be returned.

Desktop (please complete the following information):

Linux (Kubuntu 24.04), python 3.12.3
MacOS 15.3.1 (24D70), python 3.12.4

Additional context
Code we wrote a month ago using these calls used to work, and now it's broken :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions