Skip to content

Assistants API: inconsistency between API reference and a migration guide #1335

@amureki

Description

@amureki

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

Greetings fellows,

A migration guide for assistant file upload suggests using the following format:

"attachments": [
    {
      "file_id": "file-123",
      "tools": [
        { "type": "file_search" },
        { "type": "code_interpreter" }
      ]
    }
  ]

However, the API reference shows something else:
https://platform.openai.com/docs/api-reference/messages/createMessage#messages-createmessage-attachments

Whenever I am using the version explained in the migration guide, I get the following traceback:

Failed to run listener function (error: Error code: 400 - {'error': {'message': "Missing required parameter: 'attachments[0].tools'.", 'type': 'invalid_request_error', 'param': 'attachments[0].tools', 'code': 'missing_required_parameter'}})

To Reproduce

  1. Try to migrate existing code that uses assistants API with file uploads to the new version
  2. Get stuck. :(

Code snippets

I think, this is the suspected piece in the Python library that differs:
openai.types.beta.threads.message_create_params.Attachment

class Attachment(TypedDict, total=False):
    add_to: List[Literal["file_search", "code_interpreter"]]

    file_id: str
    """The ID of the file to attach to the message."""

It expects add_to and not a tools list.

OS

macOS

Python version

Python v3.12.1

Library version

openai v1.21.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions