Skip to content
Primary navigation

Retrieve vector store file content

client.vectorStores.files.content(stringfileID, FileContentParams { vector_store_id } params, RequestOptionsoptions?): Page<FileContentResponse { text, type } >
GET/vector_stores/{vector_store_id}/files/{file_id}/content

Retrieve the parsed contents of a vector store file.

ParametersExpand Collapse
fileID: string
params: FileContentParams { vector_store_id }
vector_store_id: string

The ID of the vector store.

ReturnsExpand Collapse
FileContentResponse { text, type }
text?: string

The text content

type?: string

The content type (currently only "text")

Retrieve vector store file content

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const fileContentResponse of client.vectorStores.files.content('file-abc123', {
  vector_store_id: 'vs_abc123',
})) {
  console.log(fileContentResponse.text);
}
{
  "file_id": "file-abc123",
  "filename": "example.txt",
  "attributes": {"key": "value"},
  "content": [
    {"type": "text", "text": "..."},
    ...
  ]
}
Returns Examples
{
  "file_id": "file-abc123",
  "filename": "example.txt",
  "attributes": {"key": "value"},
  "content": [
    {"type": "text", "text": "..."},
    ...
  ]
}