Bridge by Wekoya / Docs / Media

Embeddings

Updated

Turn text into vectors for search, recommendations and "chat with your documents", on OpenAI's POST /v1/embeddings. gemini-embedding-2 (₦297 per million tokens, 8,192 tokens a text) or gemini-embedding-001 (₦222.75, 2,048 a text). Up to 2,048 texts a request. Vectors come back unit length, 3,072 numbers unless you ask for fewer. gemini-embedding-001 does not report its token count, so it is billed on an estimate, marked "usage_status": "estimated".

result = client.embeddings.create(
    model="gemini-embedding-2",
    input=["How do I pay my electricity bill?", "Buy airtime"],
    dimensions=768,                         # optional: 128 to 3,072
    extra_body={"task_type": "RETRIEVAL_QUERY"},  # optional: what the vectors are for
)
vector = result.data[0].embedding           # unit length: cosine similarity is a dot product