DEVELOPER FIELD NOTES / DOCS CHECKED 2026-09-23
Ollama · local
API endpoint & setup.
Start Ollama and download a model first. localhost refers to the machine running your code. The local OpenAI SDK requires a key value, but Ollama ignores it; use ollama.
SDK base URL
http://localhost:11434/v1Full request endpoint · POST
http://localhost:11434/v1/chat/completionsRead the official Ollama · local documentation ↗ · Checked 2026-09-23; no live API call made.
A small starting point.
Start Ollama locally and download your chosen model. Set AI_MODEL to its exact installed name; replace YOUR_MODEL_ID in cURL. The placeholder SDK key ollama is not a secret.
Python
# pip install openai
import os
from openai import OpenAI
client = OpenAI(
api_key="ollama",
base_url="http://localhost:11434/v1",
)
response = client.chat.completions.create(
model=os.environ["AI_MODEL"], messages=[{"role": "user", "content": "Hello!"}]
)
print(response)Node.js
// npm install openai
// Server-side Node.js; never expose API keys in a browser.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "ollama",
baseURL: "http://localhost:11434/v1",
});
const response = await client.chat.completions.create({
"model": process.env.AI_MODEL,
"messages": [
{
"role": "user",
"content": "Hello!"
}
]
});
console.log(response);cURL
curl 'http://localhost:11434/v1/chat/completions' \
-H "Content-Type: application/json" \
--data '{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Hello!"
}
]
}'Before moving this into production.
Check model availability, billing, rate limits and supported parameters in the provider documentation. Start with a small request from your backend. Keep keys out of client-side JavaScript and source control.
These examples show the request shape and configuration. They do not test your credentials or guarantee access to a model.
Compare other AI API endpoints →