Files
landing_page/qdrant-landing/content/documentation/headless/snippets/inference/openrouter-query/java.java
T
2026-01-22 12:20:34 +01:00

36 lines
1.5 KiB
Java

package com.example.snippets_amalgamation;
import static io.qdrant.client.QueryFactory.nearest;
import static io.qdrant.client.ValueFactory.value;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Points.Document;
import io.qdrant.client.grpc.Points.QueryPoints;
import java.util.Map;
public class Snippet {
public static void run() throws Exception {
QdrantClient client =
new QdrantClient(
QdrantGrpcClient.newBuilder("xyz-example.qdrant.io", 6334, true)
.withApiKey("<your-openrouter-key>")
.build());
client
.queryAsync(
QueryPoints.newBuilder()
.setCollectionName("{collection_name}")
.setQuery(
nearest(
Document.newBuilder()
.setModel("openrouter/mistralai/mistral-embed-2312")
.setText("How to bake cookies?")
.putAllOptions(
Map.of(
"openrouter-api-key",
value("<YOUR_OPENROUTER_API_KEY>")))
.build()))
.build())
.get();
}
}