> ## Documentation Index
> Fetch the complete documentation index at: https://student-213fb9fc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Embeddings

> Generate vector embeddings for text (Ollama-compatible)

## Overview

Generate a vector embedding for a given text input. Compatible with Ollama's `POST /api/embeddings` format.

## Request

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token: `Bearer YOUR_API_KEY`
</ParamField>

### Body

<ParamField body="model" type="string" required>
  The model to use for generating embeddings. Recommended: `gemma3:4b`, `gemma3:12b`.
</ParamField>

<ParamField body="prompt" type="string" required>
  The text to generate embeddings for.
</ParamField>

<ParamField body="options" type="object">
  Optional model parameters (e.g., `temperature`).
</ParamField>

***

## Response

<ResponseField name="embedding" type="array">
  The vector embedding as an array of floating point numbers. Dimensionality depends on the model.
</ResponseField>

***

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.ajstudioz.co.in/api/embeddings \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gemma3:4b",
      "prompt": "AJ STUDIOZ Cloud Infra provides frontier AI inference"
    }'
  ```

  ```python Python theme={null}
  from ollama import Client

  client = Client(
      host="https://api.ajstudioz.co.in",
      headers={"Authorization": "Bearer YOUR_API_KEY"}
  )

  result = client.embeddings(
      model="gemma3:4b",
      prompt="The quick brown fox jumps over the lazy dog"
  )

  embedding = result.embedding
  print(f"Embedding dimension: {len(embedding)}")
  print(f"Sample values: {embedding[:5]}")
  ```

  ```python Cosine Similarity theme={null}
  from ollama import Client
  import numpy as np

  client = Client(
      host="https://api.ajstudioz.co.in",
      headers={"Authorization": "Bearer YOUR_API_KEY"}
  )

  def embed(text):
      return client.embeddings(model="gemma3:4b", prompt=text).embedding

  def cosine_sim(a, b):
      a, b = np.array(a), np.array(b)
      return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))

  # Compare sentences
  e1 = embed("The cat sat on the mat")
  e2 = embed("A feline rested on the rug")
  e3 = embed("Stock markets surged today")

  print(f"Similar sentences: {cosine_sim(e1, e2):.4f}")   # High
  print(f"Different topics: {cosine_sim(e1, e3):.4f}")    # Low
  ```
</CodeGroup>

<ResponseExample>
  ```json Response theme={null}
  {
    "embedding": [0.1284, -0.4321, 0.8901, 0.2345, -0.6789, 0.1234, 0.5678, -0.3456, 0.7890, 0.4567, "..."]
  }
  ```
</ResponseExample>
