Skip to content

How to insert a file uploaded to openAI into a conversation #1570

Closed as not planned
@Bimbimz

Description

@Bimbimz

Confirm this is a feature request for the Node library and not the underlying OpenAI API.

  • This is a feature request for the Node library

Describe the feature or improvement you're requesting

hello how to insert a file uploaded to openAI into a conversation?

const file = await client.files.create({
        file: await fetch(url),
        purpose: 'assistants'
    })
    console.log(file.id)
const stream = await client.chat.completions.create({
        model: 'gpt-4.1',
        stream: true,
        messages: [
            {
                role: 'user',
                content: [
                    { type: 'text', text: 'what is file?' },
                    { type: 'file', file_id: 'file-xxx' }
                ]
            }
        ]
    })

    for await (const chunk of stream) {
        process.stdout.write(chunk.choices[0]?.delta?.content || '')
    }
    res.end()

I am new to openAI, and where can I make questions like this in the future?

thanks

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions