Skip to content

Grep File

$ llamacloud-prod beta:retrieval grep
POST/api/v1/retrieval/files/grep

Grep within a file’s parsed content using a regex pattern.

ParametersExpand Collapse
--file-id: string

Body param: ID of the file to grep.

--index-id: string

Body param: ID of the index the file belongs to.

--pattern: string

Body param: Regex pattern to search for.

--organization-id: optional string

Query param

--project-id: optional string

Query param

--context-chars: optional number

Body param: Number of characters of context to include before and after the matched pattern in the content field of the response

--limit: optional number

Body param: Maximum number of matches to return.

ReturnsExpand Collapse
BetaRetrievalGrepResponse: object { matches }

Grep results for a file.

matches: array of object { content, end_char, start_char }

Regex matches found in the file.

content: string

Matched text content.

end_char: number

End character offset of the match.

start_char: number

Start character offset of the match.

Grep File

llamacloud-prod beta:retrieval grep \
  --api-key 'My API Key' \
  --file-id file_id \
  --index-id idx-abc123 \
  --pattern 'revenue|profit'
{
  "matches": [
    {
      "content": "content",
      "end_char": 0,
      "start_char": 0
    }
  ]
}
Returns Examples
{
  "matches": [
    {
      "content": "content",
      "end_char": 0,
      "start_char": 0
    }
  ]
}