Ollama-Compatible API
Embeddings
Generate vector embeddings for text (Ollama-compatible)
POST
/
api
/
embeddings
Embeddings
curl --request POST \
--url https://api.ajstudioz.co.in/api/embeddings \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"options": {}
}
'import requests
url = "https://api.ajstudioz.co.in/api/embeddings"
payload = {
"model": "<string>",
"prompt": "<string>",
"options": {}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', prompt: '<string>', options: {}})
};
fetch('https://api.ajstudioz.co.in/api/embeddings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ajstudioz.co.in/api/embeddings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'prompt' => '<string>',
'options' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ajstudioz.co.in/api/embeddings"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"options\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ajstudioz.co.in/api/embeddings")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"options\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ajstudioz.co.in/api/embeddings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"options\": {}\n}"
response = http.request(request)
puts response.read_body{
"embedding": [0.1284, -0.4321, 0.8901, 0.2345, -0.6789, 0.1234, 0.5678, -0.3456, 0.7890, 0.4567, "..."]
}
Overview
Generate a vector embedding for a given text input. Compatible with Ollama’sPOST /api/embeddings format.
Request
Headers
string
required
Bearer token:
Bearer YOUR_API_KEYBody
string
required
The model to use for generating embeddings. Recommended:
gemma3:4b, gemma3:12b.string
required
The text to generate embeddings for.
object
Optional model parameters (e.g.,
temperature).Response
array
The vector embedding as an array of floating point numbers. Dimensionality depends on the model.
Example
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"
}'
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]}")
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
{
"embedding": [0.1284, -0.4321, 0.8901, 0.2345, -0.6789, 0.1234, 0.5678, -0.3456, 0.7890, 0.4567, "..."]
}
⌘I
Embeddings
curl --request POST \
--url https://api.ajstudioz.co.in/api/embeddings \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"options": {}
}
'import requests
url = "https://api.ajstudioz.co.in/api/embeddings"
payload = {
"model": "<string>",
"prompt": "<string>",
"options": {}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', prompt: '<string>', options: {}})
};
fetch('https://api.ajstudioz.co.in/api/embeddings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ajstudioz.co.in/api/embeddings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'prompt' => '<string>',
'options' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ajstudioz.co.in/api/embeddings"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"options\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ajstudioz.co.in/api/embeddings")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"options\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ajstudioz.co.in/api/embeddings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"options\": {}\n}"
response = http.request(request)
puts response.read_body{
"embedding": [0.1284, -0.4321, 0.8901, 0.2345, -0.6789, 0.1234, 0.5678, -0.3456, 0.7890, 0.4567, "..."]
}
