Ollama-Compatible API
Generate
Generate a text completion for a given prompt (Ollama-compatible)
POST
/
api
/
generate
Generate
curl --request POST \
--url https://api.ajstudioz.co.in/api/generate \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"stream": true,
"system": "<string>",
"options": {},
"context": [
{}
],
"raw": true
}
'import requests
url = "https://api.ajstudioz.co.in/api/generate"
payload = {
"model": "<string>",
"prompt": "<string>",
"stream": True,
"system": "<string>",
"options": {},
"context": [{}],
"raw": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': '<content-type>'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
stream: true,
system: '<string>',
options: {},
context: [{}],
raw: true
})
};
fetch('https://api.ajstudioz.co.in/api/generate', 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/generate",
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>',
'stream' => true,
'system' => '<string>',
'options' => [
],
'context' => [
[
]
],
'raw' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$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/generate"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"stream\": true,\n \"system\": \"<string>\",\n \"options\": {},\n \"context\": [\n {}\n ],\n \"raw\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "<content-type>")
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/generate")
.header("Authorization", "<authorization>")
.header("Content-Type", "<content-type>")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"stream\": true,\n \"system\": \"<string>\",\n \"options\": {},\n \"context\": [\n {}\n ],\n \"raw\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ajstudioz.co.in/api/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"stream\": true,\n \"system\": \"<string>\",\n \"options\": {},\n \"context\": [\n {}\n ],\n \"raw\": true\n}"
response = http.request(request)
puts response.read_body{
"model": "gemma3:27b",
"created_at": "2026-03-07T12:00:00Z",
"response": "The sky appears blue because of a phenomenon called Rayleigh scattering. When sunlight enters Earth's atmosphere, it collides with gas molecules. Sunlight consists of all colors of the visible spectrum, but blue light has a shorter wavelength and is scattered more readily than other colors. This scattered blue light reaches our eyes from all directions across the sky, making it appear blue.",
"done": true,
"done_reason": "stop",
"context": [1, 2, 3, 4, 5],
"total_duration": 4523456789,
"load_duration": 456789,
"prompt_eval_count": 9,
"prompt_eval_duration": 234567890,
"eval_count": 82,
"eval_duration": 4288888899
}
Overview
Generate a response for a given prompt with a provided model. This is the basic text completion endpoint, compatible with the Ollama/api/generate format.
Request
Headers
string
required
Bearer token:
Bearer YOUR_API_KEYstring
required
application/jsonBody
string
required
The model name to use. See available models.Example:
"gemma3:27b", "deepseek-v3.2", "kimi-k2:1t"string
required
The prompt to generate a response for.
boolean
default:"true"
If
true, responses are streamed as they are generated. If false, the full response is returned in one request.string
System message to set the behavior of the assistant.
object
Model parameter overrides. Supports the following fields:
temperature(float) — sampling temperature (0–2)top_p(float) — nucleus samplingtop_k(integer) — top-k samplingnum_predict(integer) — max tokens to generatestop(array of strings) — stop sequences
array
The context returned from a previous request, used to keep a short conversational memory.
boolean
default:"false"
If
true, no formatting is applied to the prompt. Use only when applying your own custom prompt template.Response
string
The model used for generation.
string
ISO 8601 timestamp of when the response was generated.
string
The generated text. Empty if streaming is in progress.
boolean
true when generation is complete.string
Reason generation stopped. One of:
stop, length, error.array
An encoding of the conversation for use in the next request (to keep memory).
integer
Total time in nanoseconds.
integer
Number of tokens generated.
Examples
curl https://api.ajstudioz.co.in/api/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma3:27b",
"prompt": "Why is the sky blue?",
"stream": false
}'
from ollama import Client
client = Client(
host="https://api.ajstudioz.co.in",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
response = client.generate(
model="gemma3:27b",
prompt="Why is the sky blue?"
)
print(response["response"])
from ollama import Client
client = Client(
host="https://api.ajstudioz.co.in",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
stream = client.generate(
model="deepseek-v3.2",
prompt="Explain machine learning in simple terms.",
stream=True
)
for chunk in stream:
print(chunk["response"], end="", flush=True)
{
"model": "gemma3:27b",
"created_at": "2026-03-07T12:00:00Z",
"response": "The sky appears blue because of a phenomenon called Rayleigh scattering. When sunlight enters Earth's atmosphere, it collides with gas molecules. Sunlight consists of all colors of the visible spectrum, but blue light has a shorter wavelength and is scattered more readily than other colors. This scattered blue light reaches our eyes from all directions across the sky, making it appear blue.",
"done": true,
"done_reason": "stop",
"context": [1, 2, 3, 4, 5],
"total_duration": 4523456789,
"load_duration": 456789,
"prompt_eval_count": 9,
"prompt_eval_duration": 234567890,
"eval_count": 82,
"eval_duration": 4288888899
}
⌘I
Generate
curl --request POST \
--url https://api.ajstudioz.co.in/api/generate \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"stream": true,
"system": "<string>",
"options": {},
"context": [
{}
],
"raw": true
}
'import requests
url = "https://api.ajstudioz.co.in/api/generate"
payload = {
"model": "<string>",
"prompt": "<string>",
"stream": True,
"system": "<string>",
"options": {},
"context": [{}],
"raw": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': '<content-type>'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
stream: true,
system: '<string>',
options: {},
context: [{}],
raw: true
})
};
fetch('https://api.ajstudioz.co.in/api/generate', 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/generate",
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>',
'stream' => true,
'system' => '<string>',
'options' => [
],
'context' => [
[
]
],
'raw' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$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/generate"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"stream\": true,\n \"system\": \"<string>\",\n \"options\": {},\n \"context\": [\n {}\n ],\n \"raw\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "<content-type>")
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/generate")
.header("Authorization", "<authorization>")
.header("Content-Type", "<content-type>")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"stream\": true,\n \"system\": \"<string>\",\n \"options\": {},\n \"context\": [\n {}\n ],\n \"raw\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ajstudioz.co.in/api/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"stream\": true,\n \"system\": \"<string>\",\n \"options\": {},\n \"context\": [\n {}\n ],\n \"raw\": true\n}"
response = http.request(request)
puts response.read_body{
"model": "gemma3:27b",
"created_at": "2026-03-07T12:00:00Z",
"response": "The sky appears blue because of a phenomenon called Rayleigh scattering. When sunlight enters Earth's atmosphere, it collides with gas molecules. Sunlight consists of all colors of the visible spectrum, but blue light has a shorter wavelength and is scattered more readily than other colors. This scattered blue light reaches our eyes from all directions across the sky, making it appear blue.",
"done": true,
"done_reason": "stop",
"context": [1, 2, 3, 4, 5],
"total_duration": 4523456789,
"load_duration": 456789,
"prompt_eval_count": 9,
"prompt_eval_duration": 234567890,
"eval_count": 82,
"eval_duration": 4288888899
}
