File search
Retrieval over documents your customer uploaded, not the public corpora — a store, a few files, and a tool the model calls when a question needs them.
Three pieces. A vector store is a named bucket you create. Files you upload into it are chunked and embedded automatically — you never touch an embedding yourself. And file_search is a built-in tool: name your store on the request, and the model decides mid-answer when a question needs to search it.
file_search. Pricing is set by your platform operator and may not be published yet — check Pricing.Create a store
/v1/vector_stores| Parameter | Type | Description |
|---|---|---|
| name Required | string | A name for the store — yours to choose, shown back on every read. |
| owner Optional | string | A label for your own bookkeeping. Stored and returned as-is; nothing here enforces access with it. |
{
"id": "vs_9a2f1e7c3b0d5a41e6f2",
"name": "vendor-contracts",
"object": "vector_store"
}Upload files into it
/v1/filesSent as multipart/form-data, not JSON — two fields, file and vector_store_id.
.docx, and anything else is read as plain UTF-8 text, which is exactly right for .txt, .md, .csv, .json and source code, and exactly wrong for a legacy .doc, .xlsx or .pptx — those are binary formats that will decode into noise, not an error, and quietly pollute the store. Convert those to PDF or plain text first.{
"id": "file_2c88a1f0d94b7e315a02",
"filename": "contract.pdf",
"bytes": 84213,
"chunks": 41,
"vector_store_id": "vs_9a2f1e7c3b0d5a41e6f2"
}Each file is split into roughly 900-character passages with 150 characters of overlap at every boundary, cut on paragraph breaks where it can — so a sentence that starts in one chunk and finishes in the next still retrieves for either half.
Create and upload, together
# Create the store.
STORE=$(curl https://api.data.larsima.com/v1/vector_stores \
-H "Authorization: Bearer $DATA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "vendor-contracts"}')
echo "$STORE"
STORE_ID=$(echo "$STORE" | python3 -c 'import json, sys; print(json.load(sys.stdin)["id"])')
# Upload a file into it. Multipart, not JSON.
curl https://api.data.larsima.com/v1/files \
-H "Authorization: Bearer $DATA_API_KEY" \
-F "vector_store_id=$STORE_ID" \
-F "file=@contract.pdf"import os
import requests
API = "https://api.data.larsima.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['DATA_API_KEY']}"}
# Create the store.
store = requests.post(f"{API}/vector_stores", headers=HEADERS,
json={"name": "vendor-contracts"}).json()
print(store["id"])
# Upload a file into it. Multipart, not JSON: the body carries
# the file bytes.
with open("contract.pdf", "rb") as f:
up = requests.post(f"{API}/files", headers=HEADERS,
files={"file": ("contract.pdf", f)},
data={"vector_store_id": store["id"]})
print(up.json())import { readFile } from "node:fs/promises";
const API = "https://api.data.larsima.com/v1";
const KEY = process.env.DATA_API_KEY;
// Create the store.
const storeRes = await fetch(`${API}/vector_stores`, {
method: "POST",
headers: { Authorization: `Bearer ${KEY}`,
"Content-Type": "application/json" },
body: JSON.stringify({ name: "vendor-contracts" }),
});
const store = await storeRes.json();
console.log(store.id);
// Upload a file into it. Multipart, not JSON.
const bytes = await readFile("contract.pdf");
const form = new FormData();
form.append("vector_store_id", store.id);
form.append("file", new Blob([bytes]), "contract.pdf");
const upRes = await fetch(`${API}/files`, {
method: "POST",
headers: { Authorization: `Bearer ${KEY}` },
body: form,
});
console.log(await upRes.json());import { readFile } from "node:fs/promises";
const API = "https://api.data.larsima.com/v1";
const KEY = process.env.DATA_API_KEY as string;
// Create the store.
const storeRes = await fetch(`${API}/vector_stores`, {
method: "POST",
headers: { Authorization: `Bearer ${KEY}`,
"Content-Type": "application/json" },
body: JSON.stringify({ name: "vendor-contracts" }),
});
const store = (await storeRes.json()) as { id: string };
console.log(store.id);
// Upload a file into it. Multipart, not JSON.
const bytes = await readFile("contract.pdf");
const form = new FormData();
form.append("vector_store_id", store.id);
form.append("file", new Blob([bytes]), "contract.pdf");
const upRes = await fetch(`${API}/files`, {
method: "POST",
headers: { Authorization: `Bearer ${KEY}` },
body: form,
});
console.log(await upRes.json());package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
const api = "https://api.data.larsima.com/v1"
func main() {
key := os.Getenv("DATA_API_KEY")
// Create the store.
body, _ := json.Marshal(map[string]string{
"name": "vendor-contracts"})
req, _ := http.NewRequest("POST", api+"/vector_stores",
bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+key)
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
raw, _ := io.ReadAll(resp.Body)
resp.Body.Close()
var store map[string]any
json.Unmarshal(raw, &store)
fmt.Println(store["id"])
// Upload a file into it. Multipart, not JSON.
var buf bytes.Buffer
w := multipart.NewWriter(&buf)
w.WriteField("vector_store_id", store["id"].(string))
part, _ := w.CreateFormFile("file", "contract.pdf")
f, _ := os.Open("contract.pdf")
io.Copy(part, f)
f.Close()
w.Close()
up, _ := http.NewRequest("POST", api+"/files", &buf)
up.Header.Set("Authorization", "Bearer "+key)
up.Header.Set("Content-Type", w.FormDataContentType())
upResp, _ := http.DefaultClient.Do(up)
upRaw, _ := io.ReadAll(upResp.Body)
upResp.Body.Close()
fmt.Println(string(upRaw))
}// Cargo.toml: reqwest = { version = "0.12", features =
// ["blocking", "json", "multipart"] }, serde_json = "1"
use serde_json::json;
use std::env;
fn main() {
let key = env::var("DATA_API_KEY").unwrap();
let api = "https://api.data.larsima.com/v1";
let client = reqwest::blocking::Client::new();
// Create the store.
let store: serde_json::Value = client
.post(format!("{api}/vector_stores"))
.bearer_auth(&key)
.json(&json!({"name": "vendor-contracts"}))
.send().unwrap().json().unwrap();
let store_id = store["id"].as_str().unwrap().to_string();
println!("{store_id}");
// Upload a file into it. Multipart, not JSON.
let form = reqwest::blocking::multipart::Form::new()
.text("vector_store_id", store_id)
.file("file", "contract.pdf").unwrap();
let up: serde_json::Value = client.post(format!("{api}/files"))
.bearer_auth(&key).multipart(form)
.send().unwrap().json().unwrap();
println!("{up}");
}// Maven/Gradle: org.json:json:20240303
import org.json.JSONObject;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.UUID;
public class FileSearchUpload {
static final String API = "https://api.data.larsima.com/v1";
static final HttpClient CLIENT = HttpClient.newHttpClient();
static final String KEY = System.getenv("DATA_API_KEY");
public static void main(String[] args) throws Exception {
// Create the store.
HttpRequest createReq = HttpRequest
.newBuilder(URI.create(API + "/vector_stores"))
.header("Authorization", "Bearer " + KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(
new JSONObject().put("name", "vendor-contracts").toString()))
.build();
JSONObject store = new JSONObject(CLIENT.send(createReq,
HttpResponse.BodyHandlers.ofString()).body());
System.out.println(store.getString("id"));
// Upload a file into it. Multipart, not JSON --
// built by hand, since java.net.http has no
// multipart helper.
String boundary = UUID.randomUUID().toString();
byte[] fileBytes = Files.readAllBytes(Path.of("contract.pdf"));
String head = "--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"vector_store_id\"\r\n\r\n"
+ store.getString("id") + "\r\n"
+ "--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"file\"; filename=\"contract.pdf\"\r\n"
+ "Content-Type: application/pdf\r\n\r\n";
String tail = "\r\n--" + boundary + "--\r\n";
byte[] body = concat(head.getBytes(), fileBytes,
tail.getBytes());
HttpRequest upReq = HttpRequest.newBuilder(
URI.create(API + "/files"))
.header("Authorization", "Bearer " + KEY)
.header("Content-Type",
"multipart/form-data; boundary=" + boundary)
.POST(HttpRequest.BodyPublishers.ofByteArray(body))
.build();
System.out.println(CLIENT.send(upReq,
HttpResponse.BodyHandlers.ofString()).body());
}
static byte[] concat(byte[]... parts) {
int len = 0;
for (byte[] p : parts) len += p.length;
byte[] out = new byte[len];
int pos = 0;
for (byte[] p : parts) {
System.arraycopy(p, 0, out, pos, p.length);
pos += p.length;
}
return out;
}
}using System.Net.Http.Headers;
using System.Text;
using System.Text.Json.Nodes;
const string Api = "https://api.data.larsima.com/v1";
var key = Environment.GetEnvironmentVariable("DATA_API_KEY");
var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", key);
// Create the store.
var createBody = new StringContent(
"{\"name\": \"vendor-contracts\"}", Encoding.UTF8,
"application/json");
var storeRes = await http.PostAsync($"{Api}/vector_stores", createBody);
var store = JsonNode.Parse(
await storeRes.Content.ReadAsStringAsync())!.AsObject();
Console.WriteLine(store["id"]);
// Upload a file into it. Multipart, not JSON.
using var form = new MultipartFormDataContent();
form.Add(new StringContent(store["id"]!.GetValue<string>()),
"vector_store_id");
form.Add(new ByteArrayContent(
await File.ReadAllBytesAsync("contract.pdf")),
"file", "contract.pdf");
var upRes = await http.PostAsync($"{Api}/files", form);
Console.WriteLine(await upRes.Content.ReadAsStringAsync());<?php
$api = "https://api.data.larsima.com/v1";
$key = getenv("DATA_API_KEY");
// Create the store.
$ch = curl_init("$api/vector_stores");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer $key",
"Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(
["name" => "vendor-contracts"]),
]);
$store = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $store["id"], "\n";
// Upload a file into it. Multipart, not JSON -- CURLFile
// streams it.
$ch = curl_init("$api/files");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer $key"],
CURLOPT_POSTFIELDS => [
"vector_store_id" => $store["id"],
"file" => new CURLFile("contract.pdf"),
],
]);
print_r(json_decode(curl_exec($ch), true));
curl_close($ch);require "json"
require "net/http"
require "securerandom"
require "uri"
API = "https://api.data.larsima.com/v1"
KEY = ENV.fetch("DATA_API_KEY")
def post_json(path, body)
uri = URI("#{API}#{path}")
req = Net::HTTP::Post.new(uri,
"Authorization" => "Bearer #{KEY}",
"Content-Type" => "application/json")
req.body = body.to_json
JSON.parse(Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }.body)
end
# Create the store.
store = post_json("/vector_stores", { name: "vendor-contracts" })
puts store["id"]
# Upload a file into it. Multipart, not JSON -- built by
# hand, since net/http has no multipart helper in the
# standard library.
boundary = SecureRandom.hex(16)
file_bytes = File.binread("contract.pdf")
body = +""
body << "--#{boundary}\r\n"
body << "Content-Disposition: form-data; name=\"vector_store_id\"\r\n\r\n"
body << "#{store['id']}\r\n"
body << "--#{boundary}\r\n"
body << "Content-Disposition: form-data; name=\"file\"; filename=\"contract.pdf\"\r\n"
body << "Content-Type: application/pdf\r\n\r\n"
body << file_bytes
body << "\r\n--#{boundary}--\r\n"
uri = URI("#{API}/files")
req = Net::HTTP::Post.new(uri,
"Authorization" => "Bearer #{KEY}",
"Content-Type" => "multipart/form-data; boundary=#{boundary}")
req.body = body
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
puts res.bodySearch it from a chat completion
[{ "type": "file_search", "vector_store_ids": ["vs_9a2f1e7c3b0d5a41e6f2"] }]data-auto and data-general execute file_search (the law models do not); data-auto is the model every example on this page uses.curl https://api.data.larsima.com/v1/chat/completions \
-H "Authorization: Bearer $DATA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "data-auto",
"messages": [{"role": "user", "content":
"What is the termination notice period in the vendor contract? Name which file it came from."}],
"tools": [{"type": "file_search",
"vector_store_ids": ["vs_9a2f1e7c3b0d5a41e6f2"]}]
}'import os
import requests
API = "https://api.data.larsima.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['DATA_API_KEY']}",
"Content-Type": "application/json"}
res = requests.post(f"{API}/chat/completions", headers=HEADERS, json={
"model": "data-auto",
"messages": [{"role": "user", "content":
"What is the termination notice period in the vendor "
"contract? Name which file it came from."}],
"tools": [{"type": "file_search",
"vector_store_ids": ["vs_9a2f1e7c3b0d5a41e6f2"]}],
})
print(res.json()["choices"][0]["message"]["content"])const API = "https://api.data.larsima.com/v1";
const res = await fetch(`${API}/chat/completions`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DATA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "data-auto",
messages: [{ role: "user", content:
"What is the termination notice period in the vendor " +
"contract? Name which file it came from." }],
tools: [{ type: "file_search",
vector_store_ids: ["vs_9a2f1e7c3b0d5a41e6f2"] }],
}),
});
const out = await res.json();
console.log(out.choices[0].message.content);const API = "https://api.data.larsima.com/v1";
const res = await fetch(`${API}/chat/completions`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DATA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "data-auto",
messages: [{ role: "user", content:
"What is the termination notice period in the vendor " +
"contract? Name which file it came from." }],
tools: [{ type: "file_search",
vector_store_ids: ["vs_9a2f1e7c3b0d5a41e6f2"] }],
}),
});
const out = (await res.json()) as any;
console.log(out.choices[0].message.content);package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body, _ := json.Marshal(map[string]any{
"model": "data-auto",
"messages": []map[string]string{{"role": "user", "content":
"What is the termination notice period in the vendor " +
"contract? Name which file it came from."}},
"tools": []map[string]any{{"type": "file_search",
"vector_store_ids": []string{"vs_9a2f1e7c3b0d5a41e6f2"}}},
})
req, _ := http.NewRequest("POST",
"https://api.data.larsima.com/v1/chat/completions",
bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("DATA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
raw, _ := io.ReadAll(resp.Body)
var out map[string]any
json.Unmarshal(raw, &out)
choice := out["choices"].([]any)[0].(map[string]any)
fmt.Println(choice["message"].(map[string]any)["content"])
}use serde_json::json;
use std::env;
fn main() {
let key = env::var("DATA_API_KEY").unwrap();
let client = reqwest::blocking::Client::new();
let out: serde_json::Value = client
.post("https://api.data.larsima.com/v1/chat/completions")
.bearer_auth(key)
.json(&json!({
"model": "data-auto",
"messages": [{"role": "user", "content":
"What is the termination notice period in the vendor contract? Name which file it came from."}],
"tools": [{"type": "file_search",
"vector_store_ids": ["vs_9a2f1e7c3b0d5a41e6f2"]}]
}))
.send().unwrap().json().unwrap();
println!("{}", out["choices"][0]["message"]["content"]);
}import org.json.JSONArray;
import org.json.JSONObject;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class FileSearchQuery {
public static void main(String[] args) throws Exception {
JSONObject body = new JSONObject()
.put("model", "data-auto")
.put("messages", new JSONArray().put(new JSONObject()
.put("role", "user")
.put("content",
"What is the termination notice period in the vendor contract? Name which file it came from.")))
.put("tools", new JSONArray().put(new JSONObject()
.put("type", "file_search")
.put("vector_store_ids", new JSONArray()
.put("vs_9a2f1e7c3b0d5a41e6f2"))));
HttpRequest req = HttpRequest.newBuilder(URI.create(
"https://api.data.larsima.com/v1/chat/completions"))
.header("Authorization", "Bearer " + System.getenv("DATA_API_KEY"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body.toString()))
.build();
HttpResponse<String> res = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
JSONObject out = new JSONObject(res.body());
System.out.println(out.getJSONArray("choices")
.getJSONObject(0).getJSONObject("message")
.getString("content"));
}
}using System.Net.Http.Headers;
using System.Text;
using System.Text.Json.Nodes;
var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer",
Environment.GetEnvironmentVariable("DATA_API_KEY"));
var body = new JsonObject {
["model"] = "data-auto",
["messages"] = new JsonArray {
new JsonObject { ["role"] = "user", ["content"] =
"What is the termination notice period in the vendor contract? " +
"Name which file it came from." },
},
["tools"] = new JsonArray {
new JsonObject { ["type"] = "file_search",
["vector_store_ids"] = new JsonArray {
"vs_9a2f1e7c3b0d5a41e6f2" } },
},
};
var res = await http.PostAsync(
"https://api.data.larsima.com/v1/chat/completions",
new StringContent(body.ToJsonString(), Encoding.UTF8,
"application/json"));
var out = JsonNode.Parse(
await res.Content.ReadAsStringAsync())!.AsObject();
Console.WriteLine(out["choices"]![0]!["message"]!["content"]);<?php
$ch = curl_init("https://api.data.larsima.com/v1/chat/completions");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("DATA_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"model" => "data-auto",
"messages" => [["role" => "user", "content" =>
"What is the termination notice period in the vendor contract? " .
"Name which file it came from."]],
"tools" => [["type" => "file_search",
"vector_store_ids" => ["vs_9a2f1e7c3b0d5a41e6f2"]]],
]),
]);
$out = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $out["choices"][0]["message"]["content"], "\n";require "json"
require "net/http"
require "uri"
uri = URI("https://api.data.larsima.com/v1/chat/completions")
req = Net::HTTP::Post.new(uri,
"Authorization" => "Bearer #{ENV.fetch('DATA_API_KEY')}",
"Content-Type" => "application/json")
req.body = {
model: "data-auto",
messages: [{ role: "user", content:
"What is the termination notice period in the vendor "\
"contract? Name which file it came from." }],
tools: [{ type: "file_search",
vector_store_ids: ["vs_9a2f1e7c3b0d5a41e6f2"] }],
}.to_json
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
puts JSON.parse(res.body)["choices"][0]["message"]["content"]Search it from the Responses API
POST /v1/responses takes the same tool, written the OpenAI Responses way, and answers with a proper response object: a file_search_call item recording the query, then the answer as an output_text message whose annotations carry a file_citation (file_id and filename) for each file the search returned. response.output_text in the OpenAI SDK works as usual. Add "include": ["file_search_call.results"] to also get the matched passages back on the file_search_call. stream: true is supported; the answer is produced first and then delivered as the standard event sequence, so expect it to arrive after the search and the model have finished, not token by token.
vector_store_ids must be a store your organization owns. An unknown id returns 404 with code vector_store_not_found, and a file_search with no vector_store_ids returns 400 — the request is refused rather than answered from the model's memory.curl https://api.data.larsima.com/v1/responses \
-H "Authorization: Bearer $DATA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "data-auto",
"input": "What is the termination notice period in the vendor contract? Name which file it came from.",
"tools": [{"type": "file_search",
"vector_store_ids": ["vs_9a2f1e7c3b0d5a41e6f2"]}]
}'import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["DATA_API_KEY"],
base_url="https://api.data.larsima.com/v1")
resp = client.responses.create(
model="data-auto",
input="What is the termination notice period in the vendor "
"contract? Name which file it came from.",
tools=[{"type": "file_search",
"vector_store_ids": ["vs_9a2f1e7c3b0d5a41e6f2"]}],
)
print(resp.output_text)
# Files the answer is grounded in:
for a in resp.output[-1].content[0].annotations:
print(a.type, a.file_id, a.filename)Citing what comes back
Each hit the model sees carries a filename, a similarity score, and the matched passage — nothing tracks page or paragraph numbers, because extraction does not keep them. Cite by filename: ask the model, in your system prompt, to name the source file for every fact it pulls from a search.
| Field | Type | Meaning |
|---|---|---|
filename | string | The uploaded file the passage came from. |
score | number | Cosine similarity to the query, 0 to 1 — higher is closer. |
text | string | The matched passage itself, up to roughly 900 characters. |
List and delete a store
/v1/vector_stores/v1/vector_stores/{id}Deleting a store deletes its files and their chunks with it — there is no separate step.
curl https://api.data.larsima.com/v1/vector_stores \
-H "Authorization: Bearer $DATA_API_KEY"
curl -X DELETE https://api.data.larsima.com/v1/vector_stores/vs_9a2f1e7c3b0d5a41e6f2 \
-H "Authorization: Bearer $DATA_API_KEY"import os
import requests
API = "https://api.data.larsima.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['DATA_API_KEY']}"}
stores = requests.get(f"{API}/vector_stores", headers=HEADERS).json()
for s in stores["data"]:
print(s["id"], s["name"], s["files"], "files")
requests.delete(f"{API}/vector_stores/{stores['data'][0]['id']}",
headers=HEADERS)const API = "https://api.data.larsima.com/v1";
const HEADERS = { Authorization: `Bearer ${process.env.DATA_API_KEY}` };
const stores = await (await fetch(`${API}/vector_stores`,
{ headers: HEADERS })).json();
for (const s of stores.data) console.log(s.id, s.name, s.files, "files");
await fetch(`${API}/vector_stores/${stores.data[0].id}`,
{ method: "DELETE", headers: HEADERS });const API = "https://api.data.larsima.com/v1";
const HEADERS = { Authorization: `Bearer ${process.env.DATA_API_KEY}` };
const stores = await (await fetch(`${API}/vector_stores`,
{ headers: HEADERS })).json() as { data: Record<string, unknown>[] };
for (const s of stores.data) console.log(s.id, s.name, s.files, "files");
await fetch(`${API}/vector_stores/${stores.data[0].id}`,
{ method: "DELETE", headers: HEADERS });package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
const api = "https://api.data.larsima.com/v1"
func main() {
key := os.Getenv("DATA_API_KEY")
req, _ := http.NewRequest("GET", api+"/vector_stores", nil)
req.Header.Set("Authorization", "Bearer "+key)
resp, _ := http.DefaultClient.Do(req)
raw, _ := io.ReadAll(resp.Body)
resp.Body.Close()
var stores map[string]any
json.Unmarshal(raw, &stores)
data := stores["data"].([]any)
for _, s := range data {
row := s.(map[string]any)
fmt.Println(row["id"], row["name"], row["files"], "files")
}
first := data[0].(map[string]any)["id"].(string)
del, _ := http.NewRequest("DELETE",
api+"/vector_stores/"+first, nil)
del.Header.Set("Authorization", "Bearer "+key)
http.DefaultClient.Do(del)
}use std::env;
fn main() {
let key = env::var("DATA_API_KEY").unwrap();
let client = reqwest::blocking::Client::new();
let api = "https://api.data.larsima.com/v1";
let stores: serde_json::Value = client
.get(format!("{api}/vector_stores"))
.bearer_auth(&key).send().unwrap().json().unwrap();
for s in stores["data"].as_array().unwrap() {
println!("{} {} {} files", s["id"], s["name"], s["files"]);
}
let first = stores["data"][0]["id"].as_str().unwrap();
client.delete(format!("{api}/vector_stores/{first}"))
.bearer_auth(&key).send().unwrap();
}import org.json.JSONArray;
import org.json.JSONObject;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class ListStores {
public static void main(String[] args) throws Exception {
String api = "https://api.data.larsima.com/v1";
String key = System.getenv("DATA_API_KEY");
HttpClient client = HttpClient.newHttpClient();
HttpRequest listReq = HttpRequest.newBuilder(
URI.create(api + "/vector_stores"))
.header("Authorization", "Bearer " + key)
.GET().build();
JSONObject stores = new JSONObject(client.send(listReq,
HttpResponse.BodyHandlers.ofString()).body());
JSONArray data = stores.getJSONArray("data");
for (int i = 0; i < data.length(); i++) {
JSONObject s = data.getJSONObject(i);
System.out.println(s.getString("id") + " "
+ s.getString("name") + " " + s.getInt("files") + " files");
}
String first = data.getJSONObject(0).getString("id");
HttpRequest delReq = HttpRequest.newBuilder(
URI.create(api + "/vector_stores/" + first))
.header("Authorization", "Bearer " + key)
.DELETE().build();
client.send(delReq, HttpResponse.BodyHandlers.ofString());
}
}using System.Net.Http.Headers;
using System.Text.Json.Nodes;
const string Api = "https://api.data.larsima.com/v1";
var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer",
Environment.GetEnvironmentVariable("DATA_API_KEY"));
var stores = JsonNode.Parse(
await http.GetStringAsync($"{Api}/vector_stores"))!.AsObject();
foreach (var s in stores["data"]!.AsArray())
Console.WriteLine($"{s!["id"]} {s["name"]} {s["files"]} files");
var first = stores["data"]![0]!["id"]!.GetValue<string>();
await http.DeleteAsync($"{Api}/vector_stores/{first}");<?php
$api = "https://api.data.larsima.com/v1";
$key = getenv("DATA_API_KEY");
$headers = ["Authorization: Bearer $key"];
$ch = curl_init("$api/vector_stores");
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers]);
$stores = json_decode(curl_exec($ch), true);
curl_close($ch);
foreach ($stores["data"] as $s) {
echo "{$s['id']} {$s['name']} {$s['files']} files\n";
}
$ch = curl_init("$api/vector_stores/{$stores['data'][0]['id']}");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers,
]);
curl_exec($ch);
curl_close($ch);require "json"
require "net/http"
require "uri"
API = "https://api.data.larsima.com/v1"
KEY = ENV.fetch("DATA_API_KEY")
uri = URI("#{API}/vector_stores")
req = Net::HTTP::Get.new(uri, "Authorization" => "Bearer #{KEY}")
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
stores = JSON.parse(res.body)
stores["data"].each { |s| puts "#{s['id']} #{s['name']} #{s['files']} files" }
del_uri = URI("#{API}/vector_stores/#{stores['data'][0]['id']}")
del_req = Net::HTTP::Delete.new(del_uri, "Authorization" => "Bearer #{KEY}")
Net::HTTP.start(del_uri.host, del_uri.port, use_ssl: true) { |http| http.request(del_req) }