Skip to content

Is using experimental_attachments required? file parts aren't working. #6623

Closed
@pieterbeulque

Description

@pieterbeulque

Description

I'm doing a pretty standard streamText on the back-end with useChat() on the front-end.

If I send this from the client, the LLM tells me it can't access any files.

append({
  role: "user",
  content: "what is in this file?"
  parts: [
    { type: "text", text: "what is in this file?" },
    { type: "file", mimeType: "application/pdf", data: "data:application/pdf;base64,…" }
  ]
})

but if I do this

append({
  role: "user",
  content: "what is in this file?"
  parts: [
    { type: "text", text: "what is in this file?" }
  ]
},
{
  experimental_attachments: [
    { name: "file", contentType: "application/pdf", data: "data:application/pdf;base64,…" }
  ]
})

it works.

I'm probably doing something wrong, but shouldn't the former also work?

AI SDK Version

ai@4.3.16
@ai-sdk/google@1.2.19

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions