Skip to main content
Fhddos’s embeddings endpoint converts text into high-dimensional vectors using Google’s Gemini embedding models. These vectors capture semantic meaning, so similar texts produce similar vectors — making them the foundation for semantic search, retrieval-augmented generation (RAG), recommendation systems, and text classification. Authenticate with your Fhddos token; no Google API key is needed.

Set Up Your Environment

export BASE_URL="https://aiapi.fhddos.com"
export TOKEN="your-fhddos-token"

Generate Embeddings: POST /v1/embeddings

Single Input

curl -X POST "$BASE_URL/v1/embeddings" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-004",
    "input": "The quick brown fox jumps over the lazy dog"
  }'

Response

{
  "object": "list",
  "data": [
    {
      "embedding": [0.0123, -0.0456, 0.0789, "..."],
      "index": 0,
      "object": "embedding"
    }
  ],
  "model": "text-embedding-004",
  "usage": {
    "prompt_tokens": 9,
    "total_tokens": 9
  }
}
The embedding array contains the full vector. For text-embedding-004 and gemini-embedding-001, this is a 768-dimensional float array.

Batch Input

Pass an array of strings to embed multiple texts in a single request:
curl -X POST "$BASE_URL/v1/embeddings" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-004",
    "input": [
      "How do I reset my password?",
      "Where can I find my invoice?",
      "What are your support hours?"
    ]
  }'
The response data array contains one embedding object per input string, each with a matching index.

Available Models

ModelDimensionsDescription
text-embedding-004768General-purpose text embedding — recommended starting point
gemini-embedding-001768Gemini native embedding model

SDK Examples

from openai import OpenAI

client = OpenAI(
    api_key="your-fhddos-token",
    base_url="https://aiapi.fhddos.com/v1"
)

response = client.embeddings.create(
    model="text-embedding-004",
    input="The quick brown fox jumps over the lazy dog"
)

vector = response.data[0].embedding
print(f"Vector dimensions: {len(vector)}")
print(f"First 5 values: {vector[:5]}")

Common Use Cases

Semantic Search

Embed your document corpus and a user’s query, then rank documents by cosine similarity to surface the most relevant results — without keyword matching.

Retrieval-Augmented Generation (RAG)

Store chunk embeddings in a vector database (Pinecone, pgvector, Weaviate). At query time, retrieve the top-k nearest chunks and pass them as context to a Gemini chat model.

Text Clustering & Deduplication

Group similar documents together or detect near-duplicate content by comparing embedding distances across your dataset.

Recommendation Systems

Compute similarity between item descriptions or user preference vectors to power content or product recommendations.

Measuring Similarity

Use cosine similarity to compare two embedding vectors. Values close to 1.0 indicate high semantic similarity; values near 0 indicate unrelated content.
import numpy as np
from openai import OpenAI

client = OpenAI(
    api_key="your-fhddos-token",
    base_url="https://aiapi.fhddos.com/v1"
)

def embed(text: str) -> list[float]:
    resp = client.embeddings.create(model="text-embedding-004", input=text)
    return resp.data[0].embedding

def cosine_similarity(a: list[float], b: list[float]) -> float:
    a, b = np.array(a), np.array(b)
    return float(np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b)))

vec_a = embed("How do I cancel my subscription?")
vec_b = embed("Steps to unsubscribe from the service")
vec_c = embed("What is the capital of France?")

print(cosine_similarity(vec_a, vec_b))  # High — semantically similar
print(cosine_similarity(vec_a, vec_c))  # Low  — unrelated topics