How do you call the Free AI API? Full reference
This page documents every endpoint of the free, keyless AI API. If you prefer not to read it, download the integration prompt and let your AI assistant write the code.
Base URL
https://api.apiaifree.com/v1
All requests use HTTPS. Request and response bodies are JSON in UTF-8, except for /ask, which returns plain text by default. Cross-origin requests are allowed from any website.
Authentication
There is none. The API has no keys, accounts or tokens. An Authorization header is accepted and ignored, so libraries that require a key work with any placeholder value such as free.
Chat completions
POST /v1/chat/completions is the main endpoint. It takes a conversation and returns the next assistant message.
Request parameters
| Field | Type | Description |
|---|---|---|
messages | array, required | Conversation so far. Each item has a role (system, user or assistant) and text content. |
model | string | Use free-ai. Any other value is accepted and mapped to the same model. |
max_tokens | integer | Maximum length of the answer. Default 1024, maximum 8192. |
temperature | number | Randomness from 0 to 2. Lower values give more predictable text. |
top_p | number | Nucleus sampling threshold, an alternative to temperature. |
stop | string or array | Sequences at which generation stops. |
seed | integer | Makes sampling repeatable for the same input. |
stream | boolean | Return the answer as Server-Sent Events. |
reasoning | boolean | Let the model think before answering. See below. |
response_format | object | {"type":"json_object"} asks for valid JSON output. |
Example request
curl https://api.apiaifree.com/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "free-ai", "max_tokens": 300, "temperature": 0.7, "messages": [ {"role": "system", "content": "You answer in one short paragraph."}, {"role": "user", "content": "Why is the sky blue?"} ] }'
Example response
{
"id": "chatcmpl-8vlcqzR9pSE5FVxh",
"object": "chat.completion",
"model": "free-ai",
"choices": [{
"index": 0,
"finish_reason": "stop",
"message": {"role": "assistant", "content": "Sunlight is scattered by air molecules…"}
}],
"usage": {"prompt_tokens": 74, "completion_tokens": 58, "total_tokens": 132}
}The answer text is in choices[0].message.content. A finish_reason of length means the answer was cut by max_tokens.
Streaming
With "stream": true the response has the content type text/event-stream. Each event is a line starting with data: that carries a JSON chunk; the new text is in choices[0].delta.content. The stream ends with data: [DONE].
const res = await fetch("https://api.apiaifree.com/v1/chat/completions", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ model: "free-ai", stream: true, messages: [{ role: "user", content: "Tell me a short story." }] }), }); const reader = res.body.getReader(), dec = new TextDecoder(); let buf = ""; while (true) { const { done, value } = await reader.read(); if (done) break; buf += dec.decode(value, { stream: true }); const lines = buf.split("\n"); buf = lines.pop(); for (const line of lines) { if (!line.startsWith("data:") || line.includes("[DONE]")) continue; const text = JSON.parse(line.slice(5)).choices?.[0]?.delta?.content; if (text) process.stdout.write(text); } }
Reasoning mode
By default the model answers straight away. Send "reasoning": true to let it work through the problem first. Thinking consumes output tokens, so set max_tokens to at least 2000; with a small limit the visible answer can come back empty. The thinking text is returned separately in choices[0].message.reasoning_content.
The /ask endpoint
GET /ask or POST /ask answers a single question and returns plain text. It exists for shell scripts, spreadsheets, webhooks and other places where building JSON is inconvenient.
| Parameter | Description |
|---|---|
q | The question, URL-encoded. Required. |
system | Optional instructions for the model. |
max_tokens | Optional answer length, default 1024. |
format | Set to json to receive {"answer": "…"} instead of text. |
curl "https://api.apiaifree.com/ask?q=Give+me+a+synonym+for+fast" curl "https://api.apiaifree.com/ask?q=Name+three+colors&format=json"
Text completions
POST /v1/completions continues a raw string passed in the prompt field, without chat roles. It accepts the same sampling parameters and returns the text in choices[0].text. Use it for autocomplete-style tasks; for everything else prefer chat completions.
Models and health
GET /v1/models returns a list with one entry, free-ai. GET /health returns {"status":"ok"} with status 200 when the model server is reachable, and status 503 when it is not. Poll it before long batch jobs.
Limits
| Limit | Value |
|---|---|
| Requests per day or per minute | Not limited |
| Parallel connections per IP address | 8 |
| Request body | 1 MB |
| Input across all messages | 120,000 characters |
| Output per request | 8,192 tokens |
| Request timeout | 300 seconds |
| Modalities | Text in, text out |
Errors and retries
Errors use the familiar shape {"error": {"message": "…", "type": "…", "code": 400}} together with a matching HTTP status.
| Status | Meaning | What to do |
|---|---|---|
| 400 | Invalid JSON or missing messages | Fix the request body |
| 404 | Unknown endpoint | Check the path |
| 405 | Wrong HTTP method | Use POST for completions |
| 413 | Body or input too large | Shorten the conversation |
| 429 | More than 8 parallel connections | Wait for a running request to finish |
| 503 | Model busy or temporarily offline | Retry after 2–5 seconds, up to three times |
A simple exponential backoff covers both 429 and 503. Set your HTTP client timeout to at least 120 seconds, because long answers take time to generate.
SDKs and tools
Any client that speaks the chat completions format can use the API by overriding the base URL.
Python SDK
from openai import OpenAI client = OpenAI(base_url="https://api.apiaifree.com/v1", api_key="free")
JavaScript SDK
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.apiaifree.com/v1", apiKey: "free" });
LangChain, n8n and other tools
Choose the “OpenAI-compatible” or “custom base URL” option, enter https://api.apiaifree.com/v1, type any text into the key field and set the model to free-ai.