OpenAI-Compatible API
Text Completions
OpenAI-compatible text completions (legacy prompt format)
POST
/
v1
/
completions
Text Completions
curl --request POST \
--url https://api.ajstudioz.co.in/v1/completions \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": {},
"stream": true,
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"stop": {}
}
'import requests
url = "https://api.ajstudioz.co.in/v1/completions"
payload = {
"model": "<string>",
"prompt": {},
"stream": True,
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"stop": {}
}
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: {},
stream: true,
max_tokens: 123,
temperature: 123,
top_p: 123,
stop: {}
})
};
fetch('https://api.ajstudioz.co.in/v1/completions', 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/completions",
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' => [
],
'stream' => true,
'max_tokens' => 123,
'temperature' => 123,
'top_p' => 123,
'stop' => [
]
]),
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/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": {},\n \"stream\": true,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": {}\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/completions")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": {},\n \"stream\": true,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ajstudioz.co.in/v1/completions")
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\": {},\n \"stream\": true,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "cmpl-d9f3kx2m",
"object": "text_completion",
"created": 1751760000,
"model": "gemma3:27b",
"choices": [
{
"text": " bright and full of promise. The kingdom of Verdania was known for three things: its azure mountains, its vibrant festivals, and the mysterious Oracle who lived in the ancient tower at the city's center.",
"index": 0,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 50,
"total_tokens": 62
}
}
Overview
Generate a text completion for a single prompt string. This is the legacy OpenAI-compatible format. For most use cases, prefer the Chat Completions endpoint.Request
Headers
string
required
Bearer token:
Bearer YOUR_API_KEYBody
string
required
Model identifier. See available models.
string or array
required
The prompt to complete. Can be a string or an array of strings for batch completions.
boolean
default:"false"
Stream the completion as Server-Sent Events.
integer
default:"16"
Maximum number of tokens to generate.
number
default:"1"
Sampling temperature (0–2).
number
default:"1"
Nucleus sampling probability.
string or array
Stop sequences.
Response
string
Unique completion ID.
string
"text_completion"integer
Unix timestamp.
string
The model used.
array
Completion results:
text— generated textindex— choice indexfinish_reason—"stop"or"length"
object
Token usage:
prompt_tokens, completion_tokens, total_tokens.Example
from openai import OpenAI
client = OpenAI(
base_url="https://api.ajstudioz.co.in/v1",
api_key="YOUR_API_KEY"
)
response = client.completions.create(
model="gemma3:27b",
prompt="The future of artificial intelligence is",
max_tokens=100,
temperature=0.8
)
print(response.choices[0].text)
curl https://api.ajstudioz.co.in/v1/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma3:27b",
"prompt": "Once upon a time in a land far away,",
"max_tokens": 200,
"temperature": 0.9
}'
{
"id": "cmpl-d9f3kx2m",
"object": "text_completion",
"created": 1751760000,
"model": "gemma3:27b",
"choices": [
{
"text": " bright and full of promise. The kingdom of Verdania was known for three things: its azure mountains, its vibrant festivals, and the mysterious Oracle who lived in the ancient tower at the city's center.",
"index": 0,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 50,
"total_tokens": 62
}
}
⌘I
Text Completions
curl --request POST \
--url https://api.ajstudioz.co.in/v1/completions \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": {},
"stream": true,
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"stop": {}
}
'import requests
url = "https://api.ajstudioz.co.in/v1/completions"
payload = {
"model": "<string>",
"prompt": {},
"stream": True,
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"stop": {}
}
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: {},
stream: true,
max_tokens: 123,
temperature: 123,
top_p: 123,
stop: {}
})
};
fetch('https://api.ajstudioz.co.in/v1/completions', 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/completions",
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' => [
],
'stream' => true,
'max_tokens' => 123,
'temperature' => 123,
'top_p' => 123,
'stop' => [
]
]),
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/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": {},\n \"stream\": true,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": {}\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/completions")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": {},\n \"stream\": true,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ajstudioz.co.in/v1/completions")
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\": {},\n \"stream\": true,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"stop\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "cmpl-d9f3kx2m",
"object": "text_completion",
"created": 1751760000,
"model": "gemma3:27b",
"choices": [
{
"text": " bright and full of promise. The kingdom of Verdania was known for three things: its azure mountains, its vibrant festivals, and the mysterious Oracle who lived in the ancient tower at the city's center.",
"index": 0,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 50,
"total_tokens": 62
}
}
