ollamaapidoc.comIntegration
API Documentation
Start making requests to our uncensored LLM API in seconds. This guide covers the OpenAI-compatible endpoints, authentication, and streaming setup you need to integrate immediately.
Base URL and Authentication
The API lives at https://api.ollamaapidoc.com/v1. You authenticate using a Bearer token in the Authorization header. Generate your key instantly via Google or email on the dashboard. No phone number required. The key works with standard OpenAI SDKs by setting the base URL.
Your First Request
Send a POST request to /v1/chat/completions with the model ID uncensored. This endpoint handles text input and text output. It supports streaming, JSON mode, and function calling. You can test connectivity without spending credit by checking the models endpoint first.
curl https://api.ollamaapidoc.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "list all installed models"}]
}'
The response returns standard OpenAI formatting. Errors return appropriate HTTP codes. Check the body for error details if something fails. Streaming responses use Server-Sent Events.
Python SDK Integration
Install the official OpenAI library. Configure the client with your base URL and API key. Call the chat completions endpoint. The code remains identical to standard OpenAI usage. This ensures easy migration for existing projects. You can adjust parameters like temperature and top_p directly in the call.
from openai import OpenAI
client = OpenAI(base_url="https://api.ollamaapidoc.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)
Handle exceptions for rate limits or invalid keys. The library streams tokens if you set stream to true. This approach keeps your codebase clean and compatible.
Node.js SDK Setup
Use the openai npm package. Initialize the client with the custom base URL. Pass your API key. The syntax mirrors the Python example. This consistency reduces debugging time. You can send multiple messages in a conversation history array.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.ollamaapidoc.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);
Parse the response carefully. The API returns structured JSON. Error handling is crucial for production apps. Catch network errors and API-specific errors separately. This ensures your app stays responsive during high traffic.
Streaming and JSON Mode
Enable streaming by setting the stream parameter to true. The API sends tokens via Server-Sent Events. You receive partial responses in real-time. This improves user experience for long outputs. You can also enforce JSON output using response_format. This is useful for structured data extraction.
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)
Function calling works similarly. Define tools in your request. The model returns tool calls. Parse these calls in your code. Execute them and feed results back to the model. This loop enables complex workflows.
Limits, Errors, and Context
The context window is 100,000 tokens. Max output is 16,000 tokens per request. Errors include 401 for invalid keys and 402 for insufficient credit. Rate limits cap at 300 requests per minute. Handle these gracefully in your app. The API never uses your prompts for training. Privacy is maintained. Credit does not expire.
Common questions
How do I get started with the ollama API doc?
Create an account and generate an API key. Use the base URL provided in the dashboard. Send your first POST request to the chat completions endpoint. The process takes less than two minutes.
What happens if I hit the rate limit?
You receive a 429 Too Many Requests error. The limit is 300 requests per minute per key. You can switch to a new key if needed. Wait a minute and retry. Streaming responses count towards the limit.
Can I use this with OpenAI SDKs?
Yes. The API is fully OpenAI-compatible. Set the base URL to our endpoint. Pass your API key. The code works exactly like standard OpenAI integration. This allows easy switching between providers.
Get your key in seconds
Register, copy the key, update your base URL. That is all the configuration required.