Files
landing_page/qdrant-landing/content/documentation/headless/snippets/cloud-inference/simple/rust.rs
T
Abdon PijpelinkandClaude Sonnet 4.6 478b96554f 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>
2026-06-24 08:11:03 +02:00

47 lines
1.2 KiB
Rust

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(())
}