Restructure inference docs (#2225)

* Break Inference page into several pages

* Make all inference code snippets testable and clean up

* Make more snippets testable

* Edits

* Document automatic query and passage prefix injection in Cloud Inference

Qdrant Cloud Inference silently applies model-specific prefixes (e.g.
"query: "/"passage: " for E5, BGE-style instruction prefix for BGE/mxbai/
Snowflake arctic-embed) so users don't need to manage them manually.
Add a section explaining this behavior, the idempotency guarantee, and
the scope (Qdrant-hosted models only; external providers handle their own).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Document short query optimization in Cloud Inference

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Update links

* Expand on external provider API key usage

* Add section about external provider API keys

* Default to header for external API keys

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Abdon Pijpelink
2026-06-24 08:11:03 +02:00
committed by GitHub
co-authored by Claude Sonnet 4.6
parent 90d072eb03
commit 478b96554f
250 changed files with 3259 additions and 2187 deletions
@@ -0,0 +1,34 @@
```go
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "<your-collection>",
Points: []*qdrant.PointStruct{
{
Id: qdrant.NewIDNum(1),
Vectors: qdrant.NewVectorsDocument(&qdrant.Document{
Text: "Recipe for baking chocolate chip cookies",
Model: "<the-model-to-use>",
}),
Payload: qdrant.NewValueMap(map[string]any{
"topic": "cooking",
"type": "dessert",
}),
},
},
})
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "<your-collection>",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{
Text: "How to bake cookies?",
Model: "<the-model-to-use>",
}),
),
})
```
@@ -0,0 +1,46 @@
```java
import static io.qdrant.client.PointIdFactory.id;
import static io.qdrant.client.QueryFactory.nearest;
import static io.qdrant.client.ValueFactory.value;
import static io.qdrant.client.VectorsFactory.vectors;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Points;
import io.qdrant.client.grpc.Points.Document;
import io.qdrant.client.grpc.Points.PointStruct;
import java.util.List;
import java.util.Map;
client
.upsertAsync(
"<your-collection>",
List.of(
PointStruct.newBuilder()
.setId(id(1))
.setVectors(
vectors(
Document.newBuilder()
.setText("Recipe for baking chocolate chip cookies")
.setModel("<the-model-to-use>")
.build()))
.putAllPayload(Map.of("topic", value("cooking"), "type", value("dessert")))
.build()))
.get();
List<Points.ScoredPoint> points =
client
.queryAsync(
Points.QueryPoints.newBuilder()
.setCollectionName("<your-collection>")
.setQuery(
nearest(
Document.newBuilder()
.setText("How to bake cookies?")
.setModel("<the-model-to-use>")
.build()))
.build())
.get();
System.out.printf(points.toString());
```
@@ -0,0 +1,38 @@
```rust
use qdrant_client::{
Payload, Qdrant,
qdrant::{Document, PointStruct, Query, QueryPointsBuilder, UpsertPointsBuilder},
};
let points = vec![PointStruct::new(
1,
Document {
text: "Recipe for baking chocolate chip cookies".into(),
model: "<the-model-to-use>".into(),
..Default::default()
},
Payload::try_from(serde_json::json!(
{"topic": "cooking", "type": "dessert"}
))?,
)];
client
.upsert_points(UpsertPointsBuilder::new("<your-collection>", points).wait(true))
.await?;
let query_document = Document {
text: "How to bake cookies?".into(),
model: "<the-model-to-use>".into(),
..Default::default()
};
let result = client
.query(
QueryPointsBuilder::new("<your-collection>")
.query(Query::new_nearest(query_document))
.build(),
)
.await?;
println!("Result: {:?}", result);
```
@@ -1,11 +1,6 @@
```typescript
import {QdrantClient} from "@qdrant/js-client-rest";
const client = new QdrantClient({
url: 'https://xyz-example.qdrant.io:6333',
apiKey: '<paste-your-api-key-here>',
});
const points = [
{
id: 1,
@@ -0,0 +1,48 @@
package snippet
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
func Main() {
// @hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "xyz-example.qdrant.io",
Port: 6334,
APIKey: "<paste-your-api-key-here>",
UseTLS: true,
})
// @hide-end
if err != nil { panic(err) } // @hide
defer client.Close() // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "<your-collection>",
Points: []*qdrant.PointStruct{
{
Id: qdrant.NewIDNum(1),
Vectors: qdrant.NewVectorsDocument(&qdrant.Document{
Text: "Recipe for baking chocolate chip cookies",
Model: "<the-model-to-use>",
}),
Payload: qdrant.NewValueMap(map[string]any{
"topic": "cooking",
"type": "dessert",
}),
},
},
})
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "<your-collection>",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{
Text: "How to bake cookies?",
Model: "<the-model-to-use>",
}),
),
})
}
@@ -1,58 +0,0 @@
```go
package main
import (
"context"
"log"
"time"
"github.com/qdrant/go-client/qdrant"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
client, err := qdrant.NewClient(&qdrant.Config{
Host: "xyz-example.qdrant.io",
Port: 6334,
APIKey: "<paste-your-api-key-here>",
UseTLS: true,
})
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer client.Close()
_, err = client.Upsert(ctx, &qdrant.UpsertPoints{
CollectionName: "<your-collection>",
Points: []*qdrant.PointStruct{
{
Id: qdrant.NewIDNum(1),
Vectors: qdrant.NewVectorsDocument(&qdrant.Document{
Text: "Recipe for baking chocolate chip cookies",
Model: "<the-model-to-use>",
}),
Payload: qdrant.NewValueMap(map[string]any{
"topic": "cooking",
"type": "dessert",
}),
},
},
})
if err != nil {
log.Fatalf("error creating point: %v", err)
}
points, err := client.Query(ctx, &qdrant.QueryPoints{
CollectionName: "<your-collection>",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{
Text: "How to bake cookies?",
Model: "<the-model-to-use>",
}),
),
})
log.Printf("List of points: %s", points)
}
```
@@ -0,0 +1,58 @@
package com.example.snippets_amalgamation;
import static io.qdrant.client.PointIdFactory.id;
import static io.qdrant.client.QueryFactory.nearest;
import static io.qdrant.client.ValueFactory.value;
import static io.qdrant.client.VectorsFactory.vectors;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Points;
import io.qdrant.client.grpc.Points.Document;
import io.qdrant.client.grpc.Points.PointStruct;
import java.util.List;
import java.util.Map;
public class Snippet {
public static void run() throws Exception {
// @hide-start
QdrantClient client =
new QdrantClient(
QdrantGrpcClient.newBuilder("xyz-example.qdrant.io", 6334, true)
.withApiKey("<paste-your-api-key-here>")
.build());
// @hide-end
client
.upsertAsync(
"<your-collection>",
List.of(
PointStruct.newBuilder()
.setId(id(1))
.setVectors(
vectors(
Document.newBuilder()
.setText("Recipe for baking chocolate chip cookies")
.setModel("<the-model-to-use>")
.build()))
.putAllPayload(Map.of("topic", value("cooking"), "type", value("dessert")))
.build()))
.get();
List<Points.ScoredPoint> points =
client
.queryAsync(
Points.QueryPoints.newBuilder()
.setCollectionName("<your-collection>")
.setQuery(
nearest(
Document.newBuilder()
.setText("How to bake cookies?")
.setModel("<the-model-to-use>")
.build()))
.build())
.get();
System.out.printf(points.toString());
}
}
@@ -1,58 +0,0 @@
```java
package org.example;
import static io.qdrant.client.PointIdFactory.id;
import static io.qdrant.client.QueryFactory.nearest;
import static io.qdrant.client.ValueFactory.value;
import static io.qdrant.client.VectorsFactory.vectors;
import io.qdrant.client.grpc.Points;
import io.qdrant.client.grpc.Points.Document;
import io.qdrant.client.grpc.Points.PointStruct;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
public class Main {
public static void main(String[] args)
throws ExecutionException, InterruptedException {
QdrantClient client =
new QdrantClient(
QdrantGrpcClient.newBuilder("xyz-example.qdrant.io", 6334, true)
.withApiKey("<paste-your-api-key-here>")
.build());
client
.upsertAsync(
"<your-collection>",
List.of(
PointStruct.newBuilder()
.setId(id(1))
.setVectors(
vectors(
Document.newBuilder()
.setText("Recipe for baking chocolate chip cookies")
.setModel("<the-model-to-use>")
.build()))
.putAllPayload(Map.of("topic", value("cooking"), "type", value("dessert")))
.build()))
.get();
List <Points.ScoredPoint> points =
client
.queryAsync(
Points.QueryPoints.newBuilder()
.setCollectionName("<your-collection>")
.setQuery(
nearest(
Document.newBuilder()
.setText("How to bake cookies?")
.setModel("<the-model-to-use>")
.build()))
.build())
.get();
System.out.printf(points.toString());
}
}
```
@@ -1,47 +0,0 @@
```rust
use qdrant_client::qdrant::Query;
use qdrant_client::qdrant::QueryPointsBuilder;
use qdrant_client::Payload;
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{Document};
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
#[tokio::main]
async fn main() {
let client = Qdrant::from_url("https://xyz-example.qdrant.io:6334")
.api_key("<paste-your-api-key-here>")
.build()
.unwrap();
let points = vec![
PointStruct::new(
1,
Document::new(
"Recipe for baking chocolate chip cookies",
"<the-model-to-use>"
),
Payload::try_from(serde_json::json!(
{"topic": "cooking", "type": "dessert"}
)).unwrap(),
)
];
let upsert_request = UpsertPointsBuilder::new(
"<your-collection>",
points
).wait(true);
let _ = client.upsert_points(upsert_request).await;
let query_document = Document::new(
"How to bake cookies?",
"<the-model-to-use>"
);
let query_request = QueryPointsBuilder::new("<your-collection>")
.query(Query::new_nearest(query_document));
let result = client.query(query_request).await.unwrap();
println!("Result: {:?}", result);
}
```
@@ -0,0 +1,46 @@
use qdrant_client::{
Payload, Qdrant,
qdrant::{Document, PointStruct, Query, QueryPointsBuilder, UpsertPointsBuilder},
};
pub async fn main() -> anyhow::Result<()> {
// @hide-start
let client = Qdrant::from_url("https://xyz-example.qdrant.io:6334")
.api_key("<paste-your-api-key-here>")
.build()?;
// @hide-end
let points = vec![PointStruct::new(
1,
Document {
text: "Recipe for baking chocolate chip cookies".into(),
model: "<the-model-to-use>".into(),
..Default::default()
},
Payload::try_from(serde_json::json!(
{"topic": "cooking", "type": "dessert"}
))?,
)];
client
.upsert_points(UpsertPointsBuilder::new("<your-collection>", points).wait(true))
.await?;
let query_document = Document {
text: "How to bake cookies?".into(),
model: "<the-model-to-use>".into(),
..Default::default()
};
let result = client
.query(
QueryPointsBuilder::new("<your-collection>")
.query(Query::new_nearest(query_document))
.build(),
)
.await?;
println!("Result: {:?}", result);
Ok(())
}
@@ -1,10 +1,11 @@
import {QdrantClient} from "@qdrant/js-client-rest";
// @hide-start
const client = new QdrantClient({
url: 'https://xyz-example.qdrant.io:6333',
apiKey: '<paste-your-api-key-here>',
});
// @hide-end
const points = [
{
id: 1,