Ollama API Documentation: Endpoint Reference
This page documents the OpenAI-compatible API for uncensored inference. It works with standard SDKs by changing the base URL and API key.
Base URL and Authentication
The base URL for all requests is https://api.ollamaapidocumentation.com/v1. You authenticate using a bearer token passed in the Authorization header. Your key is generated on the dashboard and works immediately.
- Use the official OpenAI SDKs or any compatible client.
- Set the base URL to the value above.
- Include your API key in the header.
Authentication is strict. If the key is missing or invalid, the API returns a 401 error. This ensures your usage is tracked accurately for billing.
Chat Completions Endpoint: POST /v1/chat/completions
Send messages to the model via POST /v1/chat/completions. The endpoint accepts a JSON body with a model field set to "uncensored" and a messages array.
This endpoint handles text generation. It does not support images, audio, or video. You can stream responses or wait for the full result.
Errors like 402 indicate insufficient credit. Requests are charged by real token usage. Refusals due to credit are free.
Model Listing: GET /v1/models
Retrieve available models using GET /v1/models. This returns a list of model objects. The only available model ID is "uncensored".
This endpoint helps verify connectivity. It confirms the base URL is correct. It also shows the model name and object type.
Use this to debug connection issues before sending heavy payloads.
Parameters: Temperature, Top P, and Seed
Control generation with temperature, top_p, and seed. The seed parameter ensures deterministic outputs. Use it for debugging or consistent results.
Set temperature between 0 and 2. Lower values make responses more predictable. Higher values increase randomness. The top_p parameter filters tokens by cumulative probability.
These parameters work exactly like the OpenAI API. You can combine them for precise control over style.
Streaming Responses and Token Usage
Enable streaming by setting stream: true. The API returns Server-Sent Events (SSE). Each chunk contains partial text.
The final chunk includes the token usage statistics. This allows you to calculate costs accurately. You can process tokens as they arrive.
Streaming reduces perceived latency. It is ideal for chat interfaces. The server pushes data until the response is complete.
Limits, Errors, and Context Window
The context window is 100,000 tokens. This includes both input and output. You can generate up to 16,000 tokens per request. The default max output is 2,048 tokens.
Rate limits are 300 requests per minute. You can have 8 concurrent requests. The request body size is limited to 8 MB.
Errors include 401 for invalid keys and 429 for rate limits. Credit errors return 402. These errors are clear and actionable.
cURL
curl https://api.ollamaapidocumentation.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "list files in the current directory"}]
}'Python
from openai import OpenAI
client = OpenAI(base_url="https://api.ollamaapidocumentation.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)Node.js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.ollamaapidocumentation.com/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);Streaming
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)Common questions
What is the base URL for the ollama API documentation?
The base URL is HTTPS://api.ollamaapidocumentation.com/v1. You must set this in your SDK configuration to use the uncensored LLM API.
How do I handle errors like 401 or 402?
A 401 error means your API key is invalid or missing. A 402 error indicates you have no prepaid credit. Top up with crypto to continue.
What is the context window size?
The context window is 100,000 tokens. This limit includes both the prompt and the completion. You can set max_tokens up to 16,000.
Get your key in seconds
Sign up, grab the key, swap the base URL. Done.