EN ▾

Ollama API Docs: Quickstart Guide

This guide provides the concrete details for our OpenAI-compatible API, allowing you to swap in our uncensored model without changing your existing client code.

Base URL and Authentication

The base URL is HTTPS://api.ollamaapidocs.com/v1. Pass your key in the standard Authorization header.

curl https://api.ollamaapidocs.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "List installed models in the local directory"}]
  }'

Chat Completions Endpoint

Send POST requests to /v1/chat/completions with the model set to uncensored.

from openai import OpenAI

client = OpenAI(base_url="https://api.ollamaapidocs.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)

Streaming and Tools Support

Enable streaming by setting stream to true. The API returns tokens via Server-Sent Events and supports function calling.

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)

JSON Mode and Parameters

Use response_format json_object for strict JSON output. You can also adjust temperature, top_p, and stop sequences.

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.ollamaapidocs.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);

Rate Limits and Constraints

The limit is 300 requests per minute per key. Each request supports a context window of 100,000 tokens.

curl https://api.ollamaapidocs.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "List installed models in the local directory"}]
  }'

Errors and Context Window

Handle 401 for invalid keys, 402 for no credit, and 429 for rate limits. The model supports a 100,000 token context window.

from openai import OpenAI

client = OpenAI(base_url="https://api.ollamaapidocs.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)

Common questions

What is the ollama API docs for this service?

This guide covers the base URL, authentication, and endpoints for our hosted API. It allows you to use standard OpenAI SDKs with our uncensored model.

How do I handle streaming responses?

Set the stream parameter to true in your request. The API returns tokens via Server-Sent Events, allowing real-time processing.

What happens if I exceed the rate limit?

You will receive a 429 status code. The limit is 300 requests per minute per key, with a maximum of 8 concurrent requests.

Generate your API key

Sign up, copy your key, and update the base URL. That’s all you need to start.

Create key