Files
List Files
Returns a list of the files that your account has access to. orq.ai sorts and returns the files by their creation dates, placing the most recently created files at the top.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.files.list(limit=10)
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.files.list({
limit: 10,
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"limit": Optional[int],
"starting_after": Optional[str],
"ending_before": Optional[str],
"project_id": Optional[str],
}
{
limit?: number;
startingAfter?: string;
endingBefore?: string;
projectId?: string;
}
Show Response
Show Response
{
"object": str,
"data": {
"file_id": str,
"purpose": Literal["FILE_PURPOSE_UNSPECIFIED", "FILE_PURPOSE_RETRIEVAL", "FILE_PURPOSE_KNOWLEDGE_DATASOURCE", "FILE_PURPOSE_BATCH"],
"file_name": str,
"bytes_": str,
"created_at": date,
"project_id": str,
},
"has_more": bool,
}
{
object: string;
data: {
fileId: string;
purpose: string;
fileName: string;
bytes: string;
createdAt: Date;
projectId: string;
};
hasMore: boolean;
}
Create a File
Files are used to upload documents that can be used with features like Deployments.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.files.create(filename="example.file", content="<value>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.files.create({
filename: "example.file",
content: "<value>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"filename": str, # required
"content": str, # required
"purpose": Optional[Literal["FILE_PURPOSE_UNSPECIFIED", "FILE_PURPOSE_RETRIEVAL", "FILE_PURPOSE_KNOWLEDGE_DATASOURCE", "FILE_PURPOSE_BATCH"]],
"content_type": Optional[str],
"project_id": Optional[str],
}
{
filename: string; // required
content: string; // required
purpose?: string;
contentType?: string;
projectId?: string;
}
Show Response
Show Response
{
"file": {
"file_id": str,
"purpose": Literal["FILE_PURPOSE_UNSPECIFIED", "FILE_PURPOSE_RETRIEVAL", "FILE_PURPOSE_KNOWLEDGE_DATASOURCE", "FILE_PURPOSE_BATCH"],
"file_name": str,
"bytes_": str,
"created_at": date,
"project_id": str,
},
}
{
file: {
fileId: string;
purpose: string;
fileName: string;
bytes: string;
createdAt: Date;
projectId: string;
};
}
Get Content
Returns a presigned URL for downloading the file content by file ID.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.files.get_content(file_id_or_path="<value>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.files.getContent({
fileIdOrPath: "<value>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"file_id_or_path": str, # required
}
{
fileIdOrPath: string; // required
}
Show Response
Show Response
{
"download_url": str,
}
{
downloadUrl: string;
}
Retrieve a File
Retrieves the details of an existing file object. After you supply a unique file ID, orq.ai returns the corresponding file object.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.files.get(file_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.files.get({
fileId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"file_id": str, # required
}
{
fileId: string; // required
}
Show Response
Show Response
{
"file": {
"file_id": str,
"purpose": Literal["FILE_PURPOSE_UNSPECIFIED", "FILE_PURPOSE_RETRIEVAL", "FILE_PURPOSE_KNOWLEDGE_DATASOURCE", "FILE_PURPOSE_BATCH"],
"file_name": str,
"bytes_": str,
"created_at": date,
"project_id": str,
},
}
{
file: {
fileId: string;
purpose: string;
fileName: string;
bytes: string;
createdAt: Date;
projectId: string;
};
}
Delete a File
Permanently deletes a file and its stored content from the project.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.files.delete(file_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.files.delete({
fileId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"file_id": str, # required
}
{
fileId: string; // required
}
Update a File
Updates the metadata of an existing file object.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.files.update(file_id="<id>", file_name="example.file")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.files.update({
fileId: "<id>",
updateFileRequest: {
fileName: "example.file",
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"file_id": str, # required
"file_name": str, # required
}
{
fileId: string; // required
updateFileRequest: { // required
fileName: string; // required
};
}
Show Response
Show Response
{
"file": {
"file_id": str,
"purpose": Literal["FILE_PURPOSE_UNSPECIFIED", "FILE_PURPOSE_RETRIEVAL", "FILE_PURPOSE_KNOWLEDGE_DATASOURCE", "FILE_PURPOSE_BATCH"],
"file_name": str,
"bytes_": str,
"created_at": date,
"project_id": str,
},
}
{
file: {
fileId: string;
purpose: string;
fileName: string;
bytes: string;
createdAt: Date;
projectId: string;
};
}