OpenAI-Compatible API
Embeddings (OpenAI)
Generate text embeddings via the OpenAI-compatible endpoint
POST
/
v1
/
embeddings
Embeddings (OpenAI)
curl --request POST \
--url https://api.ajstudioz.co.in/v1/embeddings \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": {},
"encoding_format": "<string>"
}
'import requests
url = "https://api.ajstudioz.co.in/v1/embeddings"
payload = {
"model": "<string>",
"input": {},
"encoding_format": "<string>"
}
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>', input: {}, encoding_format: '<string>'})
};
fetch('https://api.ajstudioz.co.in/v1/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/v1/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>',
'input' => [
],
'encoding_format' => '<string>'
]),
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/v1/embeddings"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": {},\n \"encoding_format\": \"<string>\"\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/v1/embeddings")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": {},\n \"encoding_format\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ajstudioz.co.in/v1/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 \"input\": {},\n \"encoding_format\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.1234, -0.5678, 0.9012, 0.3456, -0.7890, "..."]
}
],
"model": "gemma3:4b",
"usage": {
"prompt_tokens": 10,
"total_tokens": 10
}
}
Overview
Generate vector embeddings for a given input text, fully compatible with the OpenAI/v1/embeddings format. Use with tools like LangChain, LlamaIndex, or any RAG pipeline.
Request
Headers
string
required
Bearer token:
Bearer YOUR_API_KEYBody
string
required
Model to use. Recommended embedding models:
gemma3:4b, gemma3:12b.string or array
required
Text to embed. Can be a single string or array of strings for batch embedding.
string
default:"float"
Format for the returned embeddings. Options:
"float" or "base64".Response
string
"list"array
Array of embedding objects:
object—"embedding"index— index of the inputembedding— the vector as an array of floats
string
The model used.
object
Token counts:
prompt_tokens, total_tokens.Examples
from openai import OpenAI
client = OpenAI(
base_url="https://api.ajstudioz.co.in/v1",
api_key="YOUR_API_KEY"
)
response = client.embeddings.create(
model="gemma3:4b",
input="AJ STUDIOZ provides cloud AI inference at scale"
)
embedding = response.data[0].embedding
print(f"Dimensions: {len(embedding)}")
from openai import OpenAI
client = OpenAI(
base_url="https://api.ajstudioz.co.in/v1",
api_key="YOUR_API_KEY"
)
texts = [
"The quick brown fox",
"Machine learning is transforming industries",
"Cloud computing enables scalable AI"
]
response = client.embeddings.create(
model="gemma3:4b",
input=texts
)
for item in response.data:
print(f"[{item.index}] dim={len(item.embedding)} first5={item.embedding[:5]}")
from openai import OpenAI
import numpy as np
client = OpenAI(
base_url="https://api.ajstudioz.co.in/v1",
api_key="YOUR_API_KEY"
)
# Embed documents
docs = [
"AJ STUDIOZ supports Ollama and OpenAI APIs.",
"Models available include Gemma, Qwen, and DeepSeek.",
"You can use function calling with supported models.",
]
doc_embeddings = [
client.embeddings.create(model="gemma3:4b", input=d).data[0].embedding
for d in docs
]
# Embed query
query = "What APIs does AJ STUDIOZ support?"
query_embedding = client.embeddings.create(
model="gemma3:4b", input=query
).data[0].embedding
# Find most similar
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))
scores = [cosine_sim(query_embedding, de) for de in doc_embeddings]
best_idx = np.argmax(scores)
print(f"Most relevant: {docs[best_idx]} (score: {scores[best_idx]:.4f})")
curl https://api.ajstudioz.co.in/v1/embeddings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma3:4b",
"input": "The sky is blue because of Rayleigh scattering"
}'
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.1234, -0.5678, 0.9012, 0.3456, -0.7890, "..."]
}
],
"model": "gemma3:4b",
"usage": {
"prompt_tokens": 10,
"total_tokens": 10
}
}
⌘I
Embeddings (OpenAI)
curl --request POST \
--url https://api.ajstudioz.co.in/v1/embeddings \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": {},
"encoding_format": "<string>"
}
'import requests
url = "https://api.ajstudioz.co.in/v1/embeddings"
payload = {
"model": "<string>",
"input": {},
"encoding_format": "<string>"
}
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>', input: {}, encoding_format: '<string>'})
};
fetch('https://api.ajstudioz.co.in/v1/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/v1/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>',
'input' => [
],
'encoding_format' => '<string>'
]),
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/v1/embeddings"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": {},\n \"encoding_format\": \"<string>\"\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/v1/embeddings")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": {},\n \"encoding_format\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ajstudioz.co.in/v1/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 \"input\": {},\n \"encoding_format\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.1234, -0.5678, 0.9012, 0.3456, -0.7890, "..."]
}
],
"model": "gemma3:4b",
"usage": {
"prompt_tokens": 10,
"total_tokens": 10
}
}
